21w37a: Compile pass

This commit is contained in:
modmuss50 2021-09-17 18:42:42 +01:00
parent 46582230fb
commit 5553aff888
22 changed files with 92 additions and 329 deletions
build.gradle
fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension
fabric-entity-events-v1/src
main/java/net/fabricmc/fabric/mixin/entity/event
testmod/java/net/fabricmc/fabric/test/entity/event
fabric-events-interaction-v0/src/main/java/net/fabricmc/fabric/mixin/event/interaction
fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client
fabric-networking-blockentity-v0
build.gradle
src/main
java/net/fabricmc/fabric
resources
fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync
fabric-renderer-api-v1
build.gradle
src/testmod/java/net/fabricmc/fabric/test/renderer/simple
fabric-structure-api-v1/src/testmod
settings.gradle
src/main/resources

View file

@ -9,7 +9,7 @@ plugins {
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "0.9.50" apply false
id "fabric-loom" version "0.10.11" apply false
id "org.cadixdev.licenser" version "0.6.1"
id "org.ajoberstar.grgit" version "3.1.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
@ -20,10 +20,10 @@ def ENV = System.getenv()
class Globals {
static def baseVersion = "0.40.1"
static def mcVersion = "1.17.1"
static def yarnVersion = "+build.46"
static def loaderVersion = "0.11.6"
static def preRelease = false
static def mcVersion = "21w37a"
static def yarnVersion = "+build.8"
static def loaderVersion = "0.11.7"
static def preRelease = true
}
version = Globals.baseVersion + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
@ -257,6 +257,9 @@ subprojects {
setupRepositories(repositories)
}
// Required as moduleDependencies modifies the pom
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
javadoc.enabled = false
}
@ -296,6 +299,8 @@ publishing {
setupRepositories(repositories)
}
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
void setupRepositories(RepositoryHandler repositories) {
//repositories.mavenLocal() // uncomment for testing
def ENV = System.getenv()

View file

@ -96,7 +96,7 @@ public class FabricDimensionTest implements ModInitializer {
private int swapTargeted(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity player = context.getSource().getPlayer();
ServerWorld serverWorld = player.getServerWorld();
ServerWorld serverWorld = player.getWorld();
ServerWorld modWorld = getModWorld(context);
if (serverWorld != modWorld) {

View file

@ -26,8 +26,11 @@ import net.minecraft.block.BlockState;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.biome.source.util.MultiNoiseUtil;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.StructuresConfig;
@ -63,7 +66,25 @@ public class VoidChunkGenerator extends ChunkGenerator {
}
@Override
public void buildSurface(ChunkRegion region, Chunk chunk) {
public MultiNoiseUtil.MultiNoiseSampler method_38277() {
return null;
}
@Override
public void carve(ChunkRegion chunkRegion, long l, BiomeAccess biomeAccess, StructureAccessor structureAccessor, Chunk chunk, GenerationStep.Carver carver) {
}
@Override
public void buildSurface(ChunkRegion region, StructureAccessor structureAccessor, Chunk chunk) {
}
@Override
public void populateEntities(ChunkRegion region) {
}
@Override
public int getWorldHeight() {
return 0;
}
@Override
@ -71,6 +92,16 @@ public class VoidChunkGenerator extends ChunkGenerator {
return CompletableFuture.completedFuture(chunk);
}
@Override
public int getSeaLevel() {
return 0;
}
@Override
public int getMinimumY() {
return 0;
}
@Override
public int getHeight(int x, int z, Heightmap.Type heightmapType, HeightLimitView heightLimitView) {
return 0;

View file

@ -53,7 +53,7 @@ import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
@Mixin(ServerPlayerEntity.class)
abstract class ServerPlayerEntityMixin extends LivingEntityMixin {
@Shadow
public abstract ServerWorld getServerWorld();
public abstract ServerWorld getWorld();
/**
* Minecraft by default does not call Entity#onKilledOther for a ServerPlayerEntity being killed.
@ -66,8 +66,8 @@ abstract class ServerPlayerEntityMixin extends LivingEntityMixin {
// If the damage source that killed the player was an entity, then fire the event.
if (attacker != null) {
attacker.onKilledOther(this.getServerWorld(), (ServerPlayerEntity) (Object) this);
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.invoker().afterKilledOtherEntity(this.getServerWorld(), attacker, (ServerPlayerEntity) (Object) this);
attacker.onKilledOther(this.getWorld(), (ServerPlayerEntity) (Object) this);
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.invoker().afterKilledOtherEntity(this.getWorld(), attacker, (ServerPlayerEntity) (Object) this);
}
}
@ -77,7 +77,7 @@ abstract class ServerPlayerEntityMixin extends LivingEntityMixin {
*/
@Inject(method = "worldChanged(Lnet/minecraft/server/world/ServerWorld;)V", at = @At("TAIL"))
private void afterWorldChanged(ServerWorld origin, CallbackInfo ci) {
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.invoker().afterChangeWorld((ServerPlayerEntity) (Object) this, origin, this.getServerWorld());
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.invoker().afterChangeWorld((ServerPlayerEntity) (Object) this, origin, this.getWorld());
}
@Inject(method = "copyFrom", at = @At("TAIL"))

View file

@ -70,7 +70,7 @@ public final class EntityEventTests implements ModInitializer {
});
ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> {
LOGGER.info("Respawned {}, [{}, {}]", oldPlayer.getGameProfile().getName(), oldPlayer.getServerWorld().getRegistryKey().getValue(), newPlayer.getServerWorld().getRegistryKey().getValue());
LOGGER.info("Respawned {}, [{}, {}]", oldPlayer.getGameProfile().getName(), oldPlayer.getWorld().getRegistryKey().getValue(), newPlayer.getWorld().getRegistryKey().getValue());
});
ServerPlayerEvents.ALLOW_DEATH.register((player, source, amount) -> {

View file

@ -64,10 +64,14 @@ public class MixinServerPlayerInteractionManager {
this.player.networkHandler.sendPacket(new BlockUpdateS2CPacket(world, pos));
if (world.getBlockState(pos).hasBlockEntity()) {
BlockEntityUpdateS2CPacket updatePacket = world.getBlockEntity(pos).toUpdatePacket();
BlockEntity blockEntity = world.getBlockEntity(pos);
if (updatePacket != null) {
this.player.networkHandler.sendPacket(updatePacket);
if (blockEntity != null) {
BlockEntityUpdateS2CPacket updatePacket = BlockEntityUpdateS2CPacket.method_38586(blockEntity);
if (updatePacket != null) {
this.player.networkHandler.sendPacket(updatePacket);
}
}
}

View file

@ -16,9 +16,8 @@
package net.fabricmc.fabric.mixin.event.lifecycle.client;
import java.util.BitSet;
import java.util.function.Consumer;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -28,11 +27,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.class_6603;
import net.minecraft.client.world.ClientChunkManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.world.biome.source.BiomeArray;
import net.minecraft.world.chunk.WorldChunk;
import net.fabricmc.api.EnvType;
@ -47,7 +46,7 @@ public abstract class ClientChunkManagerMixin {
private ClientWorld world;
@Inject(method = "loadChunkFromPacket", at = @At("TAIL"))
private void onChunkLoad(int x, int z, @Nullable BiomeArray biomes, PacketByteBuf buf, NbtCompound tag, BitSet verticalStripBitmask, CallbackInfoReturnable<WorldChunk> info) {
private void onChunkLoad(int x, int z, PacketByteBuf packetByteBuf, NbtCompound nbtCompound, Consumer<class_6603.class_6605> consumer, CallbackInfoReturnable<WorldChunk> info) {
ClientChunkEvents.CHUNK_LOAD.invoker().onChunkLoad(this.world, info.getReturnValue());
}

View file

@ -1,7 +0,0 @@
archivesBaseName = "fabric-networking-blockentity-v0"
version = getSubprojectVersion(project, "0.2.11")
moduleDependencies(project, [
'fabric-api-base'
])

View file

@ -1,52 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.block.entity;
import com.google.common.base.Preconditions;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
/**
* Implement this interface on a BlockEntity which you would like to be
* synchronized with the client side using the built-in engine methods.
*/
public interface BlockEntityClientSerializable {
void fromClientTag(NbtCompound tag);
NbtCompound toClientTag(NbtCompound tag);
/**
* When called on the server, schedules a BlockEntity sync to client.
* This will cause {@link #toClientTag(NbtCompound)} to be called on the
* server to generate the packet data, and then
* {@link #fromClientTag(NbtCompound)} on the client to decode that data.
*
* <p>This is preferable to
* {@link World#updateListeners(net.minecraft.util.math.BlockPos, net.minecraft.block.BlockState, net.minecraft.block.BlockState, int)}
* because it does not cause entities to update their pathing as a side effect.
*/
default void sync() {
World world = ((BlockEntity) this).getWorld();
Preconditions.checkNotNull(world); //Maintain distinct failure case from below
if (!(world instanceof ServerWorld)) throw new IllegalStateException("Cannot call sync() on the logical client! Did you check world.isClient first?");
((ServerWorld) world).getChunkManager().markForUpdate(((BlockEntity) this).getPos());
}
}

View file

@ -1,75 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.networking.blockentity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
@Mixin(BlockEntity.class)
public abstract class MixinBlockEntity {
@Shadow
public abstract BlockEntityType<?> getType();
@Shadow
public abstract BlockPos getPos();
@Inject(at = @At("HEAD"), method = "toUpdatePacket", cancellable = true)
public void toUpdatePacket(CallbackInfoReturnable<BlockEntityUpdateS2CPacket> info) {
Object self = this;
if (self instanceof BlockEntityClientSerializable) {
// Mojang's serialization of x/y/z into the update packet is redundant,
// as we have a separate fromClientTag() we don't do it.
// However, we use the "id" field for type discernment, as actionId
// is capped at 8 bits of size with the values presumably reserved
// by Mojang.
NbtCompound tag = new NbtCompound();
Identifier entityId = BlockEntityType.getId(getType());
if (entityId == null) {
throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!");
}
tag.putString("id", entityId.toString());
tag = ((BlockEntityClientSerializable) self).toClientTag(tag);
info.setReturnValue(new BlockEntityUpdateS2CPacket(getPos(), 127, tag));
info.cancel();
}
}
@Inject(at = @At("RETURN"), method = "toInitialChunkDataNbt", cancellable = true)
public void toInitialChunkDataTag(CallbackInfoReturnable<NbtCompound> info) {
Object self = this;
if (self instanceof BlockEntityClientSerializable && info.getReturnValue() != null) {
info.setReturnValue(((BlockEntityClientSerializable) self).toClientTag(info.getReturnValue()));
}
}
}

View file

@ -1,80 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.networking.blockentity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
@Mixin(ClientPlayNetworkHandler.class)
public class MixinClientPlayNetworkHandler {
@Unique
private static Logger FABRIC_LOGGER = LogManager.getLogger();
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;getBlockEntityType()I", ordinal = 0), method = "onBlockEntityUpdate", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
public void onBlockEntityUpdate(BlockEntityUpdateS2CPacket packet, CallbackInfo info, BlockPos blockPos, BlockEntity entity) {
if (entity instanceof BlockEntityClientSerializable) {
if (packet.getBlockEntityType() == 127) {
BlockEntityClientSerializable serializable = (BlockEntityClientSerializable) entity;
String id = packet.getNbt().getString("id");
if (id != null) {
Identifier otherIdObj = BlockEntityType.getId(entity.getType());
if (otherIdObj == null) {
FABRIC_LOGGER.error(entity.getClass() + " is missing a mapping! This is a bug!");
info.cancel();
return;
}
String otherId = otherIdObj.toString();
if (otherId.equals(id)) {
serializable.fromClientTag(packet.getNbt());
}
}
}
info.cancel();
}
}
@Redirect(method = "onChunkData", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/BlockEntity;readNbt(Lnet/minecraft/nbt/NbtCompound;)V"))
public void deserializeBlockEntityChunkData(BlockEntity blockEntity, NbtCompound tag) {
if (blockEntity instanceof BlockEntityClientSerializable) {
((BlockEntityClientSerializable) blockEntity).fromClientTag(tag);
} else {
blockEntity.readNbt(tag);
}
}
}

View file

@ -1,14 +0,0 @@
{
"required": true,
"package": "net.fabricmc.fabric.mixin.networking.blockentity",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinBlockEntity"
],
"client": [
"MixinClientPlayNetworkHandler"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -1,29 +0,0 @@
{
"schemaVersion": 1,
"id": "fabric-networking-blockentity-v0",
"name": "Fabric Networking Block Entity (v0)",
"version": "${version}",
"environment": "*",
"license": "Apache-2.0",
"icon": "assets/fabric-networking-blockentity-v0/icon.png",
"contact": {
"homepage": "https://fabricmc.net",
"irc": "irc://irc.esper.net:6667/fabric",
"issues": "https://github.com/FabricMC/fabric/issues",
"sources": "https://github.com/FabricMC/fabric"
},
"authors": [
"FabricMC"
],
"depends": {
"fabricloader": ">=0.4.0",
"fabric-api-base": "*"
},
"description": "Networking hooks for block entities.",
"mixins": [
"fabric-networking-blockentity-v0.mixins.json"
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -46,9 +46,9 @@ public class MixinMain {
return session;
}
@Redirect(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/dynamic/RegistryOps;method_36574(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/registry/DynamicRegistryManager;)Lnet/minecraft/util/dynamic/RegistryOps;"))
@Redirect(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/dynamic/RegistryOps;ofLoaded(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/registry/DynamicRegistryManager;)Lnet/minecraft/util/dynamic/RegistryOps;"))
private static RegistryOps<NbtElement> ofRegistryOps(DynamicOps<NbtElement> delegate, ResourceManager resourceManager, DynamicRegistryManager impl) {
RegistryOps<NbtElement> registryOps = RegistryOps.method_36574(delegate, resourceManager, impl);
RegistryOps<NbtElement> registryOps = RegistryOps.ofLoaded(delegate, resourceManager, impl);
PersistentDynamicRegistryHandler.remapDynamicRegistries((DynamicRegistryManager.Impl) impl, fabric_saveDir);
return registryOps;
}

View file

@ -8,7 +8,6 @@ moduleDependencies(project, [
dependencies {
testmodImplementation project(path: ':fabric-blockrenderlayer-v1', configuration: 'dev')
testmodImplementation project(path: ':fabric-models-v0', configuration: 'dev')
testmodImplementation project(path: ':fabric-networking-blockentity-v0', configuration: 'dev')
testmodImplementation project(path: ':fabric-object-builder-api-v1', configuration: 'dev')
testmodImplementation project(path: ':fabric-renderer-indigo', configuration: 'dev')
testmodImplementation project(path: ':fabric-rendering-data-attachment-v1', configuration: 'dev')

View file

@ -25,13 +25,13 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.server.world.ServerWorld;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
import net.fabricmc.fabric.api.util.NbtType;
import net.fabricmc.fabric.test.renderer.WorldRenderExtensions;
public final class FrameBlockEntity extends BlockEntity implements RenderAttachmentBlockEntity, BlockEntityClientSerializable {
public final class FrameBlockEntity extends BlockEntity implements RenderAttachmentBlockEntity {
@Nullable
private Block block = null;
@ -45,16 +45,20 @@ public final class FrameBlockEntity extends BlockEntity implements RenderAttachm
if (tag.contains("block", NbtType.STRING)) {
this.block = Registry.BLOCK.get(new Identifier(tag.getString("block")));
} else {
this.block = null;
}
if (this.getWorld() != null && this.getWorld().isClient()) {
WorldRenderExtensions.scheduleBlockRerender(this.getWorld(), this.getPos());
}
}
@Override
public NbtCompound writeNbt(NbtCompound tag) {
public void writeNbt(NbtCompound tag) {
if (this.block != null) {
tag.putString("block", Registry.BLOCK.getId(this.block).toString());
}
return super.writeNbt(tag);
}
@Override
@ -62,7 +66,7 @@ public final class FrameBlockEntity extends BlockEntity implements RenderAttachm
super.markDirty();
if (this.hasWorld() && !this.getWorld().isClient()) {
this.sync();
((ServerWorld) world).getChunkManager().markForUpdate(getPos());
}
}
@ -81,28 +85,4 @@ public final class FrameBlockEntity extends BlockEntity implements RenderAttachm
public Block getRenderAttachmentData() {
return this.block;
}
@Override
public void fromClientTag(NbtCompound tag) {
System.out.println("Received sync packet");
if (tag.contains("block", NbtType.STRING)) {
this.block = Registry.BLOCK.get(new Identifier(tag.getString("block")));
} else {
this.block = null;
}
if (this.getWorld() != null) {
WorldRenderExtensions.scheduleBlockRerender(this.getWorld(), this.getPos());
}
}
@Override
public NbtCompound toClientTag(NbtCompound tag) {
if (this.block != null) {
tag.putString("block", Registry.BLOCK.getId(this.block).toString());
}
return tag;
}
}

View file

@ -17,6 +17,7 @@
package net.fabricmc.fabric.test.structure;
import java.util.Random;
import java.util.function.Predicate;
import com.mojang.serialization.Codec;
import org.apache.logging.log4j.LogManager;
@ -26,7 +27,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.structure.StructureManager;
import net.minecraft.structure.StructurePieceType;
import net.minecraft.structure.StructurePieceWithDimensions;
import net.minecraft.structure.ShiftableStructurePiece;
import net.minecraft.structure.StructureStart;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
@ -82,7 +83,7 @@ public class StructureTest {
}
@Override
public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, ChunkPos chunkPos, Biome biome, DefaultFeatureConfig featureConfig, HeightLimitView heightLimitView) {
public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, ChunkPos chunkPos, DefaultFeatureConfig featureConfig, HeightLimitView heightLimitView, Predicate<Biome> predicate) {
int blockX = chunkPos.getStartX();
int blockZ = chunkPos.getStartZ();
int blockY = chunkGenerator.getHeight(blockX, blockZ, Heightmap.Type.WORLD_SURFACE_WG, heightLimitView);
@ -94,7 +95,7 @@ public class StructureTest {
}
}
public static class TestStructureGenerator extends StructurePieceWithDimensions {
public static class TestStructureGenerator extends ShiftableStructurePiece {
public TestStructureGenerator(Random random, int x, int y, int z) {
super(PIECE, x, y, z, 0, 48, 16, getRandomHorizontalDirection(random));
}

View file

@ -16,23 +16,25 @@
package net.fabricmc.fabric.test.structure.mixin;
import java.util.function.BiConsumer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.world.biome.DefaultBiomeCreator;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
import net.minecraft.world.gen.feature.ConfiguredStructureFeatures;
import net.fabricmc.fabric.test.structure.StructureTest;
@Mixin(DefaultBiomeCreator.class)
public class MixinDefaultBiomeCreator {
@ModifyVariable(method = "createPlains", ordinal = 0, at = @At(value = "STORE", ordinal = 0))
private static GenerationSettings.Builder addCustomStructure(GenerationSettings.Builder builder, boolean sunflower) {
if (!sunflower) {
builder.structureFeature(StructureTest.CONFIGURED_STRUCTURE);
}
return builder;
@Mixin(ConfiguredStructureFeatures.class)
public class MixinConfiguredStructureFeatures {
@Inject(method = "method_38571", at = @At("TAIL"))
private static void addStructuresToBiomes(BiConsumer<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> consumer, CallbackInfo ci) {
consumer.accept(StructureTest.CONFIGURED_STRUCTURE, BiomeKeys.PLAINS);
}
}

View file

@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_16",
"mixins": [
"ChunkSerializerMixin",
"MixinDefaultBiomeCreator"
"MixinConfiguredStructureFeatures"
],
"client": [
],

View file

@ -14,7 +14,7 @@ rootProject.name = "fabric-api"
include 'fabric-api-base'
include 'fabric-api-lookup-api-v1'
include 'fabric-biome-api-v1'
//include 'fabric-biome-api-v1'
include 'fabric-blockrenderlayer-v1'
include 'fabric-commands-v0'
include 'fabric-command-api-v1'
@ -37,7 +37,6 @@ include 'fabric-mining-levels-v0'
include 'fabric-models-v0'
include 'fabric-networking-v0'
include 'fabric-networking-api-v1'
include 'fabric-networking-blockentity-v0'
include 'fabric-object-builder-api-v1'
include 'fabric-object-builders-v0'
include 'fabric-particles-v1'

View file

@ -16,9 +16,9 @@
"FabricMC"
],
"depends": {
"fabricloader": ">=0.11.3",
"fabricloader": ">=0.11.7",
"java": ">=16",
"minecraft": "~1.17.1-rc"
"minecraft": "~1.18-alpha.21.37.a"
},
"description": "Core API module providing key hooks and intercompatibility features."
}