diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/tags/worldgen/biome/biome_tag_test.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/tags/worldgen/biome/biome_tag_test.json index 1eac8b22dc..5fd45b03d7 100644 --- a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/tags/worldgen/biome/biome_tag_test.json +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/tags/worldgen/biome/biome_tag_test.json @@ -1,5 +1,4 @@ { - "replace": false, "values": [ "fabric-biome-api-v1-testmod:custom_plains", "fabric-biome-api-v1-testmod:test_end_highlands" diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentPersistentState.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentPersistentState.java index 2a991a4e7f..6fe171659c 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentPersistentState.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentPersistentState.java @@ -16,11 +16,10 @@ package net.fabricmc.fabric.impl.attachment; -import net.minecraft.registry.RegistryWrapper; - import org.jetbrains.annotations.Nullable; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.PersistentState; @@ -38,8 +37,8 @@ public AttachmentPersistentState(ServerWorld world) { this.wasSerialized = worldTarget.fabric_hasPersistentAttachments(); } - public static AttachmentPersistentState read(ServerWorld world, @Nullable NbtCompound nbt) { - ((AttachmentTargetImpl) world).fabric_readAttachmentsFromNbt(nbt); + public static AttachmentPersistentState read(ServerWorld world, @Nullable NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { + ((AttachmentTargetImpl) world).fabric_readAttachmentsFromNbt(nbt, wrapperLookup); return new AttachmentPersistentState(world); } @@ -49,10 +48,9 @@ public boolean isDirty() { return wasSerialized || worldTarget.fabric_hasPersistentAttachments(); } - // TODO 1.20.5 Add WrapperLookup to API (?) @Override public NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { - worldTarget.fabric_writeAttachmentsToNbt(nbt); + worldTarget.fabric_writeAttachmentsToNbt(nbt, wrapperLookup); return nbt; } } diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentSerializingImpl.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentSerializingImpl.java index 983cbd673f..a851a56103 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentSerializingImpl.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentSerializingImpl.java @@ -27,6 +27,8 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtOps; +import net.minecraft.registry.RegistryOps; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.attachment.v1.AttachmentTarget; @@ -36,7 +38,7 @@ public class AttachmentSerializingImpl { private static final Logger LOGGER = LoggerFactory.getLogger("fabric-data-attachment-api-v1"); @SuppressWarnings("unchecked") - public static void serializeAttachmentData(NbtCompound nbt, @Nullable IdentityHashMap, ?> attachments) { + public static void serializeAttachmentData(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup, @Nullable IdentityHashMap, ?> attachments) { if (attachments == null) { return; } @@ -48,7 +50,8 @@ public static void serializeAttachmentData(NbtCompound nbt, @Nullable IdentityHa Codec codec = (Codec) type.persistenceCodec(); if (codec != null) { - codec.encodeStart(NbtOps.INSTANCE, entry.getValue()) + RegistryOps registryOps = RegistryOps.of(NbtOps.INSTANCE, wrapperLookup); + codec.encodeStart(registryOps, entry.getValue()) .get() .ifRight(partial -> { LOGGER.warn("Couldn't serialize attachment " + type.identifier() + ", skipping. Error:"); @@ -61,7 +64,7 @@ public static void serializeAttachmentData(NbtCompound nbt, @Nullable IdentityHa nbt.put(AttachmentTarget.NBT_ATTACHMENT_KEY, compound); } - public static IdentityHashMap, Object> deserializeAttachmentData(NbtCompound nbt) { + public static IdentityHashMap, Object> deserializeAttachmentData(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { var attachments = new IdentityHashMap, Object>(); if (nbt.contains(AttachmentTarget.NBT_ATTACHMENT_KEY, NbtElement.COMPOUND_TYPE)) { @@ -78,6 +81,7 @@ public static IdentityHashMap, Object> deserializeAttachmentDa Codec codec = type.persistenceCodec(); if (codec != null) { + RegistryOps registryOps = RegistryOps.of(NbtOps.INSTANCE, wrapperLookup); codec.parse(NbtOps.INSTANCE, compound.get(key)) .get() .ifRight(partial -> { diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentTargetImpl.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentTargetImpl.java index c46c7d7a66..c10d17f339 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentTargetImpl.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/AttachmentTargetImpl.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; import net.fabricmc.fabric.api.attachment.v1.AttachmentTarget; import net.fabricmc.fabric.api.attachment.v1.AttachmentType; @@ -53,11 +54,11 @@ static void copyOnRespawn(AttachmentTarget original, AttachmentTarget target, bo throw new UnsupportedOperationException("Implemented via mixin"); } - default void fabric_writeAttachmentsToNbt(NbtCompound nbt) { + default void fabric_writeAttachmentsToNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { throw new UnsupportedOperationException("Implemented via mixin"); } - default void fabric_readAttachmentsFromNbt(NbtCompound nbt) { + default void fabric_readAttachmentsFromNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { throw new UnsupportedOperationException("Implemented via mixin"); } diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/AttachmentTargetsMixin.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/AttachmentTargetsMixin.java index ede2717f25..bd1bef57cd 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/AttachmentTargetsMixin.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/AttachmentTargetsMixin.java @@ -25,6 +25,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.WorldChunk; @@ -85,13 +86,13 @@ public boolean hasAttached(AttachmentType type) { } @Override - public void fabric_writeAttachmentsToNbt(NbtCompound nbt) { - AttachmentSerializingImpl.serializeAttachmentData(nbt, fabric_dataAttachments); + public void fabric_writeAttachmentsToNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { + AttachmentSerializingImpl.serializeAttachmentData(nbt, wrapperLookup, fabric_dataAttachments); } @Override - public void fabric_readAttachmentsFromNbt(NbtCompound nbt) { - fabric_dataAttachments = AttachmentSerializingImpl.deserializeAttachmentData(nbt); + public void fabric_readAttachmentsFromNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { + fabric_dataAttachments = AttachmentSerializingImpl.deserializeAttachmentData(nbt, wrapperLookup); } @Override diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityMixin.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityMixin.java index 8fa2d9dde4..bc9dfd2fc7 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityMixin.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityMixin.java @@ -16,8 +16,6 @@ package net.fabricmc.fabric.mixin.attachment; -import net.minecraft.registry.RegistryWrapper; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -25,6 +23,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; import net.fabricmc.fabric.impl.attachment.AttachmentTargetImpl; @@ -35,14 +34,14 @@ abstract class BlockEntityMixin implements AttachmentTargetImpl { at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/BlockEntity;readNbt(Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)V") ) private static void readBlockEntityAttachments(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup, String string, BlockEntity blockEntity, CallbackInfoReturnable cir) { - ((AttachmentTargetImpl) blockEntity).fabric_readAttachmentsFromNbt(nbt); + ((AttachmentTargetImpl) blockEntity).fabric_readAttachmentsFromNbt(nbt, wrapperLookup); } @Inject( method = "createNbt", at = @At("RETURN") ) - private void writeBlockEntityAttachments(CallbackInfoReturnable cir) { - this.fabric_writeAttachmentsToNbt(cir.getReturnValue()); + private void writeBlockEntityAttachments(RegistryWrapper.WrapperLookup wrapperLookup, CallbackInfoReturnable cir) { + this.fabric_writeAttachmentsToNbt(cir.getReturnValue(), wrapperLookup); } } diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityUpdateS2CPacketMixin.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityUpdateS2CPacketMixin.java index 7309285c2f..19ef950b74 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityUpdateS2CPacketMixin.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockEntityUpdateS2CPacketMixin.java @@ -16,7 +16,7 @@ package net.fabricmc.fabric.mixin.attachment; -import java.util.function.Function; +import java.util.function.BiFunction; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -25,6 +25,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.registry.DynamicRegistryManager; import net.fabricmc.fabric.api.attachment.v1.AttachmentTarget; @@ -39,12 +40,12 @@ public class BlockEntityUpdateS2CPacketMixin { method = "create(Lnet/minecraft/block/entity/BlockEntity;)Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;", at = @At( value = "INVOKE", - target = "Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;create(Lnet/minecraft/block/entity/BlockEntity;Ljava/util/function/Function;)Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;" + target = "Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;create(Lnet/minecraft/block/entity/BlockEntity;Ljava/util/function/BiFunction;)Lnet/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket;" ) ) - private static Function stripPersistentAttachmentData(Function getter) { - return be -> { - NbtCompound nbt = getter.apply(be); + private static BiFunction stripPersistentAttachmentData(BiFunction getter) { + return (be, drm) -> { + NbtCompound nbt = getter.apply(be, drm); nbt.remove(AttachmentTarget.NBT_ATTACHMENT_KEY); return nbt; }; diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ChunkSerializerMixin.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ChunkSerializerMixin.java index b5792eb994..a06d8aed53 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ChunkSerializerMixin.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ChunkSerializerMixin.java @@ -43,7 +43,7 @@ abstract class ChunkSerializerMixin { method = "deserialize" ) private static WorldChunk readChunkAttachments(WorldChunk chunk, ServerWorld world, PointOfInterestStorage poiStorage, ChunkPos chunkPos, NbtCompound nbt) { - ((AttachmentTargetImpl) chunk).fabric_readAttachmentsFromNbt(nbt); + ((AttachmentTargetImpl) chunk).fabric_readAttachmentsFromNbt(nbt, world.getRegistryManager()); return chunk; } @@ -53,7 +53,7 @@ private static WorldChunk readChunkAttachments(WorldChunk chunk, ServerWorld wor ) private static void writeChunkAttachments(ServerWorld world, Chunk chunk, CallbackInfoReturnable cir) { if (chunk.getStatus().getChunkType() == ChunkStatus.ChunkType.LEVELCHUNK) { - ((AttachmentTargetImpl) chunk).fabric_writeAttachmentsToNbt(cir.getReturnValue()); + ((AttachmentTargetImpl) chunk).fabric_writeAttachmentsToNbt(cir.getReturnValue(), world.getRegistryManager()); } } } diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/EntityMixin.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/EntityMixin.java index 591aa2e6ba..d7b6bddd47 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/EntityMixin.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/EntityMixin.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.mixin.attachment; 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.CallbackInfo; @@ -24,17 +25,21 @@ import net.minecraft.entity.Entity; import net.minecraft.nbt.NbtCompound; +import net.minecraft.world.World; import net.fabricmc.fabric.impl.attachment.AttachmentTargetImpl; @Mixin(Entity.class) abstract class EntityMixin implements AttachmentTargetImpl { + @Shadow + public abstract World getWorld(); + @Inject( at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.readCustomDataFromNbt(Lnet/minecraft/nbt/NbtCompound;)V"), method = "readNbt" ) private void readEntityAttachments(NbtCompound nbt, CallbackInfo cir) { - this.fabric_readAttachmentsFromNbt(nbt); + this.fabric_readAttachmentsFromNbt(nbt, getWorld().getRegistryManager()); } @Inject( @@ -42,6 +47,6 @@ private void readEntityAttachments(NbtCompound nbt, CallbackInfo cir) { method = "writeNbt" ) private void writeEntityAttachments(NbtCompound nbt, CallbackInfoReturnable cir) { - this.fabric_writeAttachmentsToNbt(nbt); + this.fabric_writeAttachmentsToNbt(nbt, getWorld().getRegistryManager()); } } diff --git a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ServerWorldMixin.java b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ServerWorldMixin.java index ce59c7413d..8a6e8db2e7 100644 --- a/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ServerWorldMixin.java +++ b/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/ServerWorldMixin.java @@ -16,11 +16,14 @@ package net.fabricmc.fabric.mixin.attachment; +import org.spongepowered.asm.mixin.Final; 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.CallbackInfo; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.PersistentState; @@ -28,13 +31,17 @@ @Mixin(ServerWorld.class) abstract class ServerWorldMixin { + @Shadow + @Final + private MinecraftServer server; + @Inject(at = @At("TAIL"), method = "") private void createAttachmentsPersistentState(CallbackInfo ci) { // Force persistent state creation ServerWorld world = (ServerWorld) (Object) this; var type = new PersistentState.Type<>( () -> new AttachmentPersistentState(world), - (nbt, wrapperLookup) -> AttachmentPersistentState.read(world, nbt), + (nbt, wrapperLookup) -> AttachmentPersistentState.read(world, nbt, server.getRegistryManager()), null // Object builder API 12.1.0 and later makes this a no-op ); world.getPersistentStateManager().getOrCreate(type, AttachmentPersistentState.ID); diff --git a/fabric-data-attachment-api-v1/src/test/java/net/fabricmc/fabric/test/attachment/CommonAttachmentTests.java b/fabric-data-attachment-api-v1/src/test/java/net/fabricmc/fabric/test/attachment/CommonAttachmentTests.java index eb3080a56e..3c72ee3a25 100644 --- a/fabric-data-attachment-api-v1/src/test/java/net/fabricmc/fabric/test/attachment/CommonAttachmentTests.java +++ b/fabric-data-attachment-api-v1/src/test/java/net/fabricmc/fabric/test/attachment/CommonAttachmentTests.java @@ -132,11 +132,11 @@ void testStaticReadWrite() { map.put(dummy, 0.5d); var fakeSave = new NbtCompound(); - AttachmentSerializingImpl.serializeAttachmentData(fakeSave, map); + AttachmentSerializingImpl.serializeAttachmentData(fakeSave, null, map); assertTrue(fakeSave.contains(AttachmentTarget.NBT_ATTACHMENT_KEY, NbtElement.COMPOUND_TYPE)); assertTrue(fakeSave.getCompound(AttachmentTarget.NBT_ATTACHMENT_KEY).contains(dummy.identifier().toString())); - map = AttachmentSerializingImpl.deserializeAttachmentData(fakeSave); + map = AttachmentSerializingImpl.deserializeAttachmentData(fakeSave, null); assertEquals(1, map.size()); Map.Entry, Object> entry = map.entrySet().stream().findFirst().orElseThrow(); // in this case the key should be the exact same object @@ -194,9 +194,9 @@ void testBlockEntityPersistence() { int expected = 1; blockEntity.setAttached(PERSISTENT, expected); - NbtCompound fakeSave = blockEntity.createNbtWithId(); + NbtCompound fakeSave = blockEntity.createNbtWithId(null); - blockEntity = BlockEntity.createFromNbt(BlockPos.ORIGIN, mock(), fakeSave); + blockEntity = BlockEntity.createFromNbt(BlockPos.ORIGIN, mock(), fakeSave, null); assertNotNull(blockEntity); assertTrue(blockEntity.hasAttached(PERSISTENT)); assertEquals(expected, blockEntity.getAttached(PERSISTENT)); @@ -211,10 +211,10 @@ void testWorldPersistentState() { int expected = 1; world.setAttached(PERSISTENT, expected); - NbtCompound fakeSave = state.writeNbt(new NbtCompound()); + NbtCompound fakeSave = state.writeNbt(new NbtCompound(), null); world = mock(ServerWorld.class, CALLS_REAL_METHODS); - AttachmentPersistentState.read(world, fakeSave); + AttachmentPersistentState.read(world, fakeSave, null); assertTrue(world.hasAttached(PERSISTENT)); assertEquals(expected, world.getAttached(PERSISTENT)); } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricCodecDataProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricCodecDataProvider.java index 36d8b5a97d..aae3351751 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricCodecDataProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricCodecDataProvider.java @@ -49,16 +49,6 @@ public abstract class FabricCodecDataProvider implements DataProvider { private final CompletableFuture registriesFuture; private final Codec codec; - /** - * @deprecated Please use {@link FabricCodecDataProvider#FabricCodecDataProvider(FabricDataOutput, CompletableFuture, DataOutput.OutputType, String, Codec)}. - */ - @Deprecated() - protected FabricCodecDataProvider(FabricDataOutput dataOutput, DataOutput.OutputType outputType, String directoryName, Codec codec) { - this.pathResolver = dataOutput.getResolver(outputType, directoryName); - this.registriesFuture = null; - this.codec = codec; - } - protected FabricCodecDataProvider(FabricDataOutput dataOutput, CompletableFuture registriesFuture, DataOutput.OutputType outputType, String directoryName, Codec codec) { this.pathResolver = dataOutput.getResolver(outputType, directoryName); this.registriesFuture = Objects.requireNonNull(registriesFuture); @@ -67,49 +57,22 @@ protected FabricCodecDataProvider(FabricDataOutput dataOutput, CompletableFuture @Override public CompletableFuture run(DataWriter writer) { - // TODO: Remove the null check once the deprecated method and constructor are removed. - if (this.registriesFuture != null) { - return this.registriesFuture.thenCompose(lookup -> { - Map entries = new HashMap<>(); - RegistryOps ops = RegistryOps.of(JsonOps.INSTANCE, lookup); - - BiConsumer provider = (id, value) -> { - JsonElement json = this.convert(id, value, ops); - JsonElement existingJson = entries.put(id, json); - - if (existingJson != null) { - throw new IllegalArgumentException("Duplicate entry " + id); - } - }; - - this.configure(provider, lookup); - return this.write(writer, entries); - }); - } - - Map entries = new HashMap<>(); - BiConsumer provider = (id, value) -> { - JsonElement json = this.convert(id, value); - JsonElement existingJson = entries.put(id, json); - - if (existingJson != null) { - throw new IllegalArgumentException("Duplicate entry " + id); - } - }; - - this.configure(provider); - return this.write(writer, entries); - } - - /** - * Implement this method to register entries to generate. - * - * @param provider A consumer that accepts an {@link Identifier} and a value to register. - * @deprecated Please use {@link FabricCodecDataProvider#configure(BiConsumer, RegistryWrapper.WrapperLookup)}. - */ - @Deprecated() - protected void configure(BiConsumer provider) { - throw new UnsupportedOperationException("Override this method."); + return this.registriesFuture.thenCompose(lookup -> { + Map entries = new HashMap<>(); + RegistryOps ops = RegistryOps.of(JsonOps.INSTANCE, lookup); + + BiConsumer provider = (id, value) -> { + JsonElement json = this.convert(id, value, ops); + JsonElement existingJson = entries.put(id, json); + + if (existingJson != null) { + throw new IllegalArgumentException("Duplicate entry " + id); + } + }; + + this.configure(provider, lookup); + return this.write(writer, entries); + }); } /** @@ -117,10 +80,7 @@ protected void configure(BiConsumer provider) { * @param provider A consumer that accepts an {@link Identifier} and a value to register. * @param lookup A lookup for registries. */ - protected void configure(BiConsumer provider, RegistryWrapper.WrapperLookup lookup) { - // TODO: Make abstract once the deprecated method is removed. - throw new UnsupportedOperationException("Override this method."); - } + protected abstract void configure(BiConsumer provider, RegistryWrapper.WrapperLookup lookup); private JsonElement convert(Identifier id, T value) { return this.convert(id, value, JsonOps.INSTANCE); diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java index 94b5c6ccf0..66fbd6908b 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java @@ -23,6 +23,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Sets; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.serialization.JsonOps; import org.jetbrains.annotations.Nullable; @@ -37,6 +38,8 @@ import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder; import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder; import net.minecraft.recipe.Recipe; +import net.minecraft.registry.RegistryOps; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -53,8 +56,8 @@ public abstract class FabricRecipeProvider extends RecipeProvider { protected final FabricDataOutput output; - public FabricRecipeProvider(FabricDataOutput output) { - super(output); + public FabricRecipeProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); this.output = output; } @@ -84,7 +87,7 @@ public Advancement.Builder getAdvancementBuilder() { } @Override - public CompletableFuture run(DataWriter writer) { + public CompletableFuture method_56888(DataWriter writer, RegistryWrapper.WrapperLookup wrapperLookup) { Set generatedRecipes = Sets.newHashSet(); List> list = new ArrayList<>(); generate(new RecipeExporter() { @@ -96,14 +99,15 @@ public void accept(Identifier recipeId, Recipe recipe, @Nullable AdvancementE throw new IllegalStateException("Duplicate recipe " + identifier); } - JsonObject recipeJson = Util.getResult(Recipe.CODEC.encodeStart(JsonOps.INSTANCE, recipe), IllegalStateException::new).getAsJsonObject(); + RegistryOps registryOps = RegistryOps.of(JsonOps.INSTANCE, wrapperLookup); + JsonObject recipeJson = Util.getResult(Recipe.CODEC.encodeStart(registryOps, recipe), IllegalStateException::new).getAsJsonObject(); ConditionJsonProvider[] conditions = FabricDataGenHelper.consumeConditions(recipe); ConditionJsonProvider.write(recipeJson, conditions); list.add(DataProvider.writeToPath(writer, recipeJson, recipesPathResolver.resolveJson(identifier))); if (advancement != null) { - JsonObject advancementJson = Util.getResult(Advancement.CODEC.encodeStart(JsonOps.INSTANCE, advancement.value()), IllegalStateException::new).getAsJsonObject(); + JsonObject advancementJson = Util.getResult(Advancement.CODEC.encodeStart(registryOps, advancement.value()), IllegalStateException::new).getAsJsonObject(); ConditionJsonProvider.write(advancementJson, conditions); list.add(DataProvider.writeToPath(writer, advancementJson, advancementsPathResolver.resolveJson(getRecipeIdentifier(advancement.id())))); } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/TagProviderMixin.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/TagProviderMixin.java index aa3c433624..3ae2955117 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/TagProviderMixin.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/TagProviderMixin.java @@ -16,33 +16,24 @@ package net.fabricmc.fabric.mixin.datagen; -import java.nio.file.Path; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; - -import com.google.gson.JsonElement; +import com.llamalad7.mixinextras.sugar.Local; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.spongepowered.asm.mixin.injection.ModifyArg; -import net.minecraft.data.DataWriter; import net.minecraft.data.server.tag.TagProvider; import net.minecraft.registry.tag.TagBuilder; -import net.minecraft.registry.tag.TagEntry; -import net.minecraft.util.Identifier; import net.fabricmc.fabric.impl.datagen.FabricTagBuilder; @Mixin(TagProvider.class) public class TagProviderMixin { - @Inject(method = "method_27046", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/DataProvider;writeToPath(Lnet/minecraft/data/DataWriter;Lcom/google/gson/JsonElement;Ljava/nio/file/Path;)Ljava/util/concurrent/CompletableFuture;"), locals = LocalCapture.CAPTURE_FAILHARD) - public void addReplaced(Predicate predicate, Predicate predicate2, DataWriter dataWriter, Map.Entry entry, CallbackInfoReturnable> cir, Identifier identifier, TagBuilder builder, List list, List list2, JsonElement jsonElement, Path path) { - if (builder instanceof FabricTagBuilder fabricTagBuilder) { - jsonElement.getAsJsonObject().addProperty("replace", fabricTagBuilder.fabric_isReplaced()); + @ModifyArg(method = "method_27046", at = @At(value = "INVOKE", target = "Lnet/minecraft/registry/tag/TagFile;(Ljava/util/List;Z)V"), index = 1) + private boolean addReplaced(boolean replaced, @Local TagBuilder tagBuilder) { + if (tagBuilder instanceof FabricTagBuilder fabricTagBuilder) { + return fabricTagBuilder.fabric_isReplaced(); } + + return replaced; } } diff --git a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener index 9a710a95b1..bd95c495a7 100644 --- a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener +++ b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener @@ -64,7 +64,8 @@ transitive-accessible field net/minecraft/data/server/loottable/BlockLootTableGe ### Generated access wideners below -transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataWriter;Lnet/minecraft/advancement/AdvancementEntry;)Ljava/util/concurrent/CompletableFuture; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider method_56888 (Lnet/minecraft/data/DataWriter;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Ljava/util/concurrent/CompletableFuture; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataWriter;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;Lnet/minecraft/advancement/AdvancementEntry;)Ljava/util/concurrent/CompletableFuture; transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generate (Lnet/minecraft/data/server/recipe/RecipeExporter;)V transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateFamilies (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/resource/featuretoggle/FeatureSet;)V transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSingleOutputShapelessRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;)V @@ -312,7 +313,7 @@ transitive-accessible method net/minecraft/data/client/ItemModelGenerator regist transitive-accessible method net/minecraft/data/client/ItemModelGenerator uploadArmor (Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V transitive-accessible method net/minecraft/data/client/ItemModelGenerator uploadArmor (Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V transitive-accessible method net/minecraft/data/client/ItemModelGenerator suffixTrim (Lnet/minecraft/util/Identifier;Ljava/lang/String;)Lnet/minecraft/util/Identifier; -transitive-accessible method net/minecraft/data/client/ItemModelGenerator createArmorJson (Lnet/minecraft/util/Identifier;Ljava/util/Map;Lnet/minecraft/item/ArmorMaterial;)Lcom/google/gson/JsonObject; +transitive-accessible method net/minecraft/data/client/ItemModelGenerator createArmorJson (Lnet/minecraft/util/Identifier;Ljava/util/Map;Lnet/minecraft/registry/entry/RegistryEntry;)Lcom/google/gson/JsonObject; transitive-accessible method net/minecraft/data/client/ItemModelGenerator registerArmor (Lnet/minecraft/item/ArmorItem;)V transitive-extendable method net/minecraft/data/MetadataProvider getName ()Ljava/lang/String; transitive-extendable method net/minecraft/data/SnbtProvider getName ()Ljava/lang/String; diff --git a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java index 4bb212b55a..d84f67552c 100644 --- a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java +++ b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java @@ -154,8 +154,8 @@ private void bootstrapTestDatagenRegistry(Registerable registriesFuture) { + super(output, registriesFuture); } @Override diff --git a/fabric-data-generation-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/datagen/client/DataGeneratorClientTestEntrypoint.java b/fabric-data-generation-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/datagen/client/DataGeneratorClientTestEntrypoint.java index 2d6ce1ce75..3d66619395 100644 --- a/fabric-data-generation-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/datagen/client/DataGeneratorClientTestEntrypoint.java +++ b/fabric-data-generation-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/datagen/client/DataGeneratorClientTestEntrypoint.java @@ -19,12 +19,14 @@ import static net.fabricmc.fabric.test.datagen.DataGeneratorTestContent.MOD_ID; import java.util.List; +import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import net.minecraft.client.texture.atlas.AtlasSource; import net.minecraft.client.texture.atlas.AtlasSourceManager; import net.minecraft.client.texture.atlas.DirectoryAtlasSource; import net.minecraft.data.DataOutput; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; @@ -47,12 +49,12 @@ public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) { } private static class TestAtlasSourceProvider extends FabricCodecDataProvider> { - private TestAtlasSourceProvider(FabricDataOutput dataOutput) { - super(dataOutput, DataOutput.OutputType.RESOURCE_PACK, "atlases", AtlasSourceManager.LIST_CODEC); + private TestAtlasSourceProvider(FabricDataOutput dataOutput, CompletableFuture registriesFuture) { + super(dataOutput, registriesFuture, DataOutput.OutputType.RESOURCE_PACK, "atlases", AtlasSourceManager.LIST_CODEC); } @Override - protected void configure(BiConsumer> provider) { + protected void configure(BiConsumer> provider, RegistryWrapper.WrapperLookup lookup) { provider.accept(new Identifier(MOD_ID, "atlas_source_test"), List.of(new DirectoryAtlasSource("example", "example/"))); } diff --git a/fabric-events-interaction-v0/src/client/java/net/fabricmc/fabric/mixin/event/interaction/client/MinecraftClientMixin.java b/fabric-events-interaction-v0/src/client/java/net/fabricmc/fabric/mixin/event/interaction/client/MinecraftClientMixin.java index 5d2d72f205..1693f5c673 100644 --- a/fabric-events-interaction-v0/src/client/java/net/fabricmc/fabric/mixin/event/interaction/client/MinecraftClientMixin.java +++ b/fabric-events-interaction-v0/src/client/java/net/fabricmc/fabric/mixin/event/interaction/client/MinecraftClientMixin.java @@ -34,10 +34,12 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.client.option.GameOptions; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; +import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -88,7 +90,7 @@ private void fabric_doItemPickWrapper(CallbackInfo info) { BlockEntity be = client.world.getBlockEntity(((BlockHitResult) client.crosshairTarget).getBlockPos()); if (be != null) { - addBlockEntityNbt(stack, be); + addBlockEntityNbt(stack, be, world.getRegistryManager()); } } @@ -115,9 +117,6 @@ private void fabric_doItemPickWrapper(CallbackInfo info) { } } - @Shadow - protected abstract void addBlockEntityNbt(ItemStack itemStack_1, BlockEntity blockEntity_1); - @ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSlotWithStack(Lnet/minecraft/item/ItemStack;)I", shift = At.Shift.BEFORE), method = "doItemPick", ordinal = 0) public ItemStack modifyItemPick(ItemStack stack) { MinecraftClient client = (MinecraftClient) (Object) this; @@ -147,6 +146,13 @@ public void cancelItemPick(CallbackInfo info) { @Nullable public ClientPlayerInteractionManager interactionManager; + @Shadow + protected abstract void addBlockEntityNbt(ItemStack stack, BlockEntity blockEntity, DynamicRegistryManager dynamicRegistryManager); + + @Shadow + @Nullable + public ClientWorld world; + @Inject( at = @At( value = "INVOKE", diff --git a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ArmorKnockbackResistanceTest.java b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ArmorKnockbackResistanceTest.java index eb32566459..346ca08dc5 100644 --- a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ArmorKnockbackResistanceTest.java +++ b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/ArmorKnockbackResistanceTest.java @@ -16,65 +16,46 @@ package net.fabricmc.fabric.test.item; +import java.util.EnumMap; +import java.util.List; + import net.minecraft.item.ArmorItem; import net.minecraft.item.ArmorMaterial; import net.minecraft.item.Item; +import net.minecraft.item.Items; import net.minecraft.recipe.Ingredient; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; -import net.minecraft.registry.tag.ItemTags; -import net.minecraft.sound.SoundEvent; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; +import net.minecraft.util.Util; import net.fabricmc.api.ModInitializer; public class ArmorKnockbackResistanceTest implements ModInitializer { - private static final ArmorMaterial WOOD_ARMOR = new ArmorMaterial() { - @Override - public int getDurability(ArmorItem.Type arg) { - return 50; - } - - @Override - public int getProtection(ArmorItem.Type arg) { - return 5; - } - - @Override - public int getEnchantability() { - return 1; - } - - @Override - public SoundEvent getEquipSound() { - return SoundEvents.ITEM_ARMOR_EQUIP_GENERIC; - } - - @Override - public Ingredient getRepairIngredient() { - return Ingredient.fromTag(ItemTags.LOGS); - } - - @Override - public String getName() { - return "wood"; - } - - @Override - public float getToughness() { - return 0.0F; - } - - @Override - public float getKnockbackResistance() { - return 0.5F; - } - }; + private static final RegistryEntry WOOD_ARMOR = Registry.registerReference(Registries.field_48976, new Identifier("fabric-item-api-v1-testmod", "wood"), createTestArmorMaterial()); @Override public void onInitialize() { Registry.register(Registries.ITEM, new Identifier("fabric-item-api-v1-testmod", "wooden_boots"), new ArmorItem(WOOD_ARMOR, ArmorItem.Type.BOOTS, new Item.Settings())); } + + private static ArmorMaterial createTestArmorMaterial() { + return new ArmorMaterial(Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> { + map.put(ArmorItem.Type.BOOTS, 1); + map.put(ArmorItem.Type.LEGGINGS, 2); + map.put(ArmorItem.Type.CHESTPLATE, 3); + map.put(ArmorItem.Type.HELMET, 1); + map.put(ArmorItem.Type.BODY, 3); + }), + 0, + SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, + () -> Ingredient.ofItems(Items.LEATHER), + List.of(new ArmorMaterial.class_9196(new Identifier("fabric-item-api-v1-testmod", "wood"))), + 0, + 0.5F + ); + } } diff --git a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java index 16938db7d5..afb3948f66 100644 --- a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java +++ b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java @@ -30,6 +30,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Hand; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.GameMode; import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; import net.fabricmc.fabric.test.item.FoodGameInitializer; @@ -37,7 +38,7 @@ public final class FoodGameTest implements FabricGameTest { @GameTest(templateName = EMPTY_STRUCTURE) public void damageFoodTest(TestContext context) { - PlayerEntity player = context.createMockSurvivalPlayer(); + PlayerEntity player = context.createMockCreativePlayer(GameMode.SURVIVAL); HungerManager hungerManager = player.getHungerManager(); for (int damage : new int[]{0, 1, 10, 19}) { @@ -60,7 +61,7 @@ public void damageFoodTest(TestContext context) { @GameTest(templateName = EMPTY_STRUCTURE) public void nameFoodTest(TestContext context) { - PlayerEntity player = context.createMockSurvivalPlayer(); + PlayerEntity player = context.createMockCreativePlayer(GameMode.SURVIVAL); HungerManager hungerManager = player.getHungerManager(); hungerManager.setFoodLevel(0); hungerManager.setSaturationLevel(0); @@ -79,7 +80,7 @@ public void nameFoodTest(TestContext context) { @GameTest(templateName = EMPTY_STRUCTURE) public void nameMeatTest(TestContext context) { - PlayerEntity player = context.createMockSurvivalPlayer(); + PlayerEntity player = context.createMockCreativePlayer(GameMode.SURVIVAL); WolfEntity wolf = context.spawnEntity(EntityType.WOLF, context.getRelative(Vec3d.ZERO)); wolf.setTamed(true); wolf.setOwner(player); diff --git a/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/play/NetworkingPlayPacketTest.java b/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/play/NetworkingPlayPacketTest.java index 678a719bf6..c784656814 100644 --- a/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/play/NetworkingPlayPacketTest.java +++ b/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/play/NetworkingPlayPacketTest.java @@ -36,6 +36,7 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; +import net.minecraft.text.TextCodecs; import net.fabricmc.api.EnvType; import net.fabricmc.api.ModInitializer; @@ -123,12 +124,12 @@ public record OverlayPacket(Text message) implements CustomPayload { public static final CustomPayload.Id ID = new Id<>(NetworkingTestmods.id("test_channel")); public static final PacketCodec CODEC = CustomPayload.codecOf(OverlayPacket::write, OverlayPacket::new); - public OverlayPacket(PacketByteBuf buf) { - this(buf.readText()); + public OverlayPacket(RegistryByteBuf buf) { + this(TextCodecs.PACKET_CODEC.decode(buf)); } - public void write(PacketByteBuf buf) { - buf.writeText(this.message); + public void write(RegistryByteBuf buf) { + TextCodecs.PACKET_CODEC.encode(buf, this.message); } @Override diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java index b941db5b46..5805935dae 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java @@ -20,9 +20,6 @@ import java.util.function.Supplier; import com.google.common.collect.ImmutableSet; - -import net.minecraft.entity.SpawnLocation; - import org.jetbrains.annotations.Nullable; import net.minecraft.block.Block; @@ -31,6 +28,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SpawnGroup; +import net.minecraft.entity.SpawnLocation; import net.minecraft.entity.SpawnRestriction; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.mob.MobEntity; diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/PersistentStateManagerTest.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/PersistentStateManagerTest.java index 402ba43ad3..00bd6b729c 100644 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/PersistentStateManagerTest.java +++ b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/PersistentStateManagerTest.java @@ -19,6 +19,7 @@ import java.util.Objects; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.PersistentState; @@ -68,12 +69,12 @@ public void setValue(String value) { } @Override - public NbtCompound writeNbt(NbtCompound nbt) { + public NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { nbt.putString("value", value); return nbt; } - private static TestState fromTag(NbtCompound tag) { + private static TestState fromTag(NbtCompound tag, RegistryWrapper.WrapperLookup wrapperLookup) { return new TestState(tag.getString("value")); } } diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/SimpleTradeFactory.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/SimpleTradeFactory.java index 77f76c6c6d..426a814ab6 100644 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/SimpleTradeFactory.java +++ b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/SimpleTradeFactory.java @@ -31,6 +31,6 @@ class SimpleTradeFactory implements TradeOffers.Factory { @Override public TradeOffer create(Entity entity, Random random) { // ALWAYS supply a copy of the offer. - return new TradeOffer(this.offer.toNbt()); + return this.offer.copy(); } } diff --git a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/FrameBlockEntity.java b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/FrameBlockEntity.java index 82587d29e4..61a07846a2 100644 --- a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/FrameBlockEntity.java +++ b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/FrameBlockEntity.java @@ -25,6 +25,7 @@ import net.minecraft.nbt.NbtElement; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -40,8 +41,8 @@ public FrameBlockEntity(BlockPos blockPos, BlockState blockState) { } @Override - public void readNbt(NbtCompound tag) { - super.readNbt(tag); + public void readNbt(NbtCompound tag, RegistryWrapper.WrapperLookup wrapperLookup) { + super.readNbt(tag, wrapperLookup); if (tag.contains("block", NbtElement.STRING_TYPE)) { this.block = Registries.BLOCK.get(new Identifier(tag.getString("block"))); @@ -56,7 +57,9 @@ public void readNbt(NbtCompound tag) { } @Override - public void writeNbt(NbtCompound tag) { + public void writeNbt(NbtCompound tag, RegistryWrapper.WrapperLookup wrapperLookup) { + super.writeNbt(tag, wrapperLookup); + if (this.block != null) { tag.putString("block", Registries.BLOCK.getId(this.block).toString()); } else { @@ -96,7 +99,7 @@ public BlockEntityUpdateS2CPacket toUpdatePacket() { } @Override - public NbtCompound toInitialChunkDataNbt() { - return this.createNbt(); + public NbtCompound toInitialChunkDataNbt(RegistryWrapper.WrapperLookup wrapperLookup) { + return this.createNbt(wrapperLookup); } } diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderContext.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderContext.java index 97ef3ccccc..7dca30f3fe 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderContext.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderContext.java @@ -45,8 +45,6 @@ public interface WorldRenderContext { */ WorldRenderer worldRenderer(); - MatrixStack matrixStack(); - float tickDelta(); long limitTime(); @@ -61,6 +59,8 @@ public interface WorldRenderContext { Matrix4f projectionMatrix(); + Matrix4f positionMatrix(); + /** * Convenient access to {WorldRenderer.world}. * diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/impl/client/rendering/WorldRenderContextImpl.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/impl/client/rendering/WorldRenderContextImpl.java index 5d5cca0cce..dd33e3190d 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/impl/client/rendering/WorldRenderContextImpl.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/impl/client/rendering/WorldRenderContextImpl.java @@ -27,7 +27,6 @@ import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.WorldRenderer; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; @@ -37,7 +36,6 @@ public final class WorldRenderContextImpl implements WorldRenderContext.BlockOutlineContext, WorldRenderContext { private WorldRenderer worldRenderer; - private MatrixStack matrixStack; private float tickDelta; private long limitTime; private boolean blockOutlines; @@ -46,6 +44,7 @@ public final class WorldRenderContextImpl implements WorldRenderContext.BlockOut private GameRenderer gameRenderer; private LightmapTextureManager lightmapTextureManager; private Matrix4f projectionMatrix; + private Matrix4f positionMatrix; private VertexConsumerProvider consumers; private Profiler profiler; private boolean advancedTranslucency; @@ -62,7 +61,6 @@ public final class WorldRenderContextImpl implements WorldRenderContext.BlockOut public void prepare( WorldRenderer worldRenderer, - MatrixStack matrixStack, float tickDelta, long limitTime, boolean blockOutlines, @@ -70,13 +68,13 @@ public void prepare( GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f projectionMatrix, + Matrix4f positionMatrix, VertexConsumerProvider consumers, Profiler profiler, boolean advancedTranslucency, ClientWorld world ) { this.worldRenderer = worldRenderer; - this.matrixStack = matrixStack; this.tickDelta = tickDelta; this.limitTime = limitTime; this.blockOutlines = blockOutlines; @@ -84,6 +82,7 @@ public void prepare( this.gameRenderer = gameRenderer; this.lightmapTextureManager = lightmapTextureManager; this.projectionMatrix = projectionMatrix; + this.positionMatrix = positionMatrix; this.consumers = consumers; this.profiler = profiler; this.advancedTranslucency = advancedTranslucency; @@ -115,11 +114,6 @@ public WorldRenderer worldRenderer() { return worldRenderer; } - @Override - public MatrixStack matrixStack() { - return matrixStack; - } - @Override public float tickDelta() { return tickDelta; @@ -145,6 +139,11 @@ public Matrix4f projectionMatrix() { return projectionMatrix; } + @Override + public Matrix4f positionMatrix() { + return positionMatrix; + } + @Override public ClientWorld world() { return world; diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java index 12f8b996db..9af9cb99c2 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java @@ -16,7 +16,6 @@ package net.fabricmc.fabric.mixin.client.rendering; -import java.util.Locale; import java.util.Map; import org.spongepowered.asm.mixin.Final; @@ -25,7 +24,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; @@ -35,7 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ArmorItem; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; @@ -62,20 +59,4 @@ private void renderArmor(MatrixStack matrices, VertexConsumerProvider vertexCons ci.cancel(); } } - - // TODO 1.20.5 - // TODO Check ArmorMaterial.class, seems to be no longer required -// @Inject(method = "getArmorTexture", at = @At(value = "HEAD"), cancellable = true) -// private void getArmorTexture(ArmorItem item, boolean secondLayer, String overlay, CallbackInfoReturnable cir) { -// final String name = item.getMaterial().getName(); -// final int separator = name.indexOf(Identifier.NAMESPACE_SEPARATOR); -// -// if (separator != -1) { -// final String namespace = name.substring(0, separator); -// final String path = name.substring(separator + 1); -// final String texture = String.format(Locale.ROOT, "%s:textures/models/armor/%s_layer_%d%s.png", namespace, path, secondLayer ? 2 : 1, overlay == null ? "" : "_" + overlay); -// -// cir.setReturnValue(ARMOR_TEXTURE_CACHE.computeIfAbsent(texture, Identifier::new)); -// } -// } } diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/WorldRendererMixin.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/WorldRendererMixin.java index 7b84620802..65333c2ff7 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/WorldRendererMixin.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/WorldRendererMixin.java @@ -14,8 +14,6 @@ * limitations under the License. */ -// TODO 1.20.5 I am not gonna touch rendering code... -/* package net.fabricmc.fabric.mixin.client.rendering; import org.joml.Matrix4f; @@ -63,9 +61,8 @@ public abstract class WorldRendererMixin { @Unique private boolean didRenderParticles; @Inject(method = "render", at = @At("HEAD")) - private void beforeRender(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { - // MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci - context.prepare((WorldRenderer) (Object) this, matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f, bufferBuilders.getEntityVertexConsumers(), world.getProfiler(), transparencyPostProcessor != null, world); + private void beforeRender(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, Matrix4f projectionMatrix, CallbackInfo ci) { + context.prepare((WorldRenderer) (Object) this, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, projectionMatrix, positionMatrix, bufferBuilders.getEntityVertexConsumers(), world.getProfiler(), transparencyPostProcessor != null, world); WorldRenderEvents.START.invoker().onStart(context); didRenderParticles = false; } @@ -80,7 +77,7 @@ private void afterTerrainSetup(Camera camera, Frustum frustum, boolean hasForced method = "render", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/render/WorldRenderer;renderLayer(Lnet/minecraft/client/render/RenderLayer;Lnet/minecraft/client/util/math/MatrixStack;DDDLorg/joml/Matrix4f;)V", + target = "Lnet/minecraft/client/render/WorldRenderer;renderLayer(Lnet/minecraft/client/render/RenderLayer;DDDLorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V", ordinal = 2, shift = Shift.AFTER ) @@ -143,7 +140,7 @@ private void beforeDebugRender(CallbackInfo ci) { method = "render", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/particle/ParticleManager;renderParticles(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/render/LightmapTextureManager;Lnet/minecraft/client/render/Camera;F)V" + target = "Lnet/minecraft/client/particle/ParticleManager;renderParticles(Lnet/minecraft/client/render/LightmapTextureManager;Lnet/minecraft/client/render/Camera;F)V" ) ) private void onRenderParticles(CallbackInfo ci) { @@ -192,8 +189,8 @@ private void renderWeather(LightmapTextureManager manager, float tickDelta, doub } } - @Inject(at = @At("HEAD"), method = "renderClouds(Lnet/minecraft/client/util/math/MatrixStack;Lorg/joml/Matrix4f;FDDD)V", cancellable = true) - private void renderCloud(MatrixStack matrices, Matrix4f matrix4f, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo info) { + @Inject(at = @At("HEAD"), method = "renderClouds(Lnet/minecraft/client/util/math/MatrixStack;Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FDDD)V", cancellable = true) + private void renderCloud(MatrixStack matrices, Matrix4f matrix4f, Matrix4f matrix4f2, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo info) { if (this.client.world != null) { DimensionRenderingRegistry.CloudRenderer renderer = DimensionRenderingRegistry.getCloudRenderer(world.getRegistryKey()); @@ -204,8 +201,8 @@ private void renderCloud(MatrixStack matrices, Matrix4f matrix4f, float tickDelt } } - @Inject(at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V", shift = At.Shift.AFTER, ordinal = 0), method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", cancellable = true) - private void renderSky(MatrixStack matrices, Matrix4f matrix4f, float tickDelta, Camera camera, boolean bl, Runnable runnable, CallbackInfo info) { + @Inject(at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V", shift = At.Shift.AFTER, ordinal = 0), method = "renderSky(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", cancellable = true) + private void renderSky(Matrix4f matrix4f, Matrix4f matrix4f2, float tickDelta, Camera camera, boolean bl, Runnable runnable, CallbackInfo info) { if (this.client.world != null) { DimensionRenderingRegistry.SkyRenderer renderer = DimensionRenderingRegistry.getSkyRenderer(world.getRegistryKey()); @@ -216,4 +213,3 @@ private void renderSky(MatrixStack matrices, Matrix4f matrix4f, float tickDelta, } } } -*/ diff --git a/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java index 52185f3142..55401ffaab 100644 --- a/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java +++ b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.test.rendering; +import java.util.EnumMap; +import java.util.List; import java.util.Optional; import net.minecraft.client.item.TooltipData; @@ -27,15 +29,17 @@ import net.minecraft.recipe.Ingredient; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; -import net.minecraft.sound.SoundEvent; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; +import net.minecraft.util.Util; import net.fabricmc.api.ModInitializer; public class TooltipComponentTestInit implements ModInitializer { public static Item CUSTOM_TOOLTIP_ITEM = new CustomTooltipItem(); - public static Item CUSTOM_ARMOR_ITEM = new ArmorItem(TestArmorMaterial.INSTANCE, ArmorItem.Type.CHESTPLATE, new Item.Settings()); + public static RegistryEntry TEST_ARMOR_MATERIAL = Registry.registerReference(Registries.field_48976, new Identifier("fabric-rendering-v1-testmod", "test_material"), createTestArmorMaterial()); + public static Item CUSTOM_ARMOR_ITEM = new ArmorItem(TEST_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE, new Item.Settings()); @Override public void onInitialize() { @@ -57,50 +61,20 @@ public Optional getTooltipData(ItemStack stack) { public record Data(String string) implements TooltipData { } - public static final class TestArmorMaterial implements ArmorMaterial { - public static final TestArmorMaterial INSTANCE = new TestArmorMaterial(); - - private TestArmorMaterial() { - } - - @Override - public int getDurability(ArmorItem.Type type) { - return 0; - } - - @Override - public int getProtection(ArmorItem.Type type) { - return 0; - } - - @Override - public int getEnchantability() { - return 0; - } - - @Override - public SoundEvent getEquipSound() { - return SoundEvents.ITEM_ARMOR_EQUIP_LEATHER; - } - - @Override - public Ingredient getRepairIngredient() { - return Ingredient.ofItems(Items.LEATHER); - } - - @Override - public String getName() { - return "fabric-rendering-v1-testmod:test"; - } - - @Override - public float getToughness() { - return 0; - } - - @Override - public float getKnockbackResistance() { - return 0; - } + private static ArmorMaterial createTestArmorMaterial() { + return new ArmorMaterial(Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> { + map.put(ArmorItem.Type.BOOTS, 1); + map.put(ArmorItem.Type.LEGGINGS, 2); + map.put(ArmorItem.Type.CHESTPLATE, 3); + map.put(ArmorItem.Type.HELMET, 1); + map.put(ArmorItem.Type.BODY, 3); + }), + 0, + SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, + () -> Ingredient.ofItems(Items.LEATHER), + List.of(new ArmorMaterial.class_9196(new Identifier("fabric-rendering-v1-testmod", "test_material"))), + 0, + 0 + ); } } diff --git a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java index 3cb7e1ab51..171a46bd05 100644 --- a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java +++ b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java @@ -45,7 +45,7 @@ private static void render(WorldRenderContext context) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); - Matrix4f matrix4f = context.matrixStack().peek().getPositionMatrix(); + Matrix4f matrix4f = context.positionMatrix(); bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); bufferBuilder.vertex(matrix4f, -100.0f, -100.0f, -100.0f).texture(0.0F, 0.0F).color(255, 255, 255, 255).next(); bufferBuilder.vertex(matrix4f, -100.0f, -100.0f, 100.0f).texture(0.0F, 1.0F).color(255, 255, 255, 255).next(); diff --git a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java index 029649c870..48d752f21b 100644 --- a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java +++ b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java @@ -19,6 +19,7 @@ import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -29,20 +30,21 @@ public class WorldRenderEventsTests implements ClientModInitializer { private static boolean onBlockOutline(WorldRenderContext wrc, WorldRenderContext.BlockOutlineContext blockOutlineContext) { if (blockOutlineContext.blockState().isOf(Blocks.DIAMOND_BLOCK)) { - wrc.matrixStack().push(); + MatrixStack matrixStack = new MatrixStack(); + matrixStack.push(); Vec3d cameraPos = MinecraftClient.getInstance().gameRenderer.getCamera().getPos(); BlockPos pos = blockOutlineContext.blockPos(); double x = pos.getX() - cameraPos.x; double y = pos.getY() - cameraPos.y; double z = pos.getZ() - cameraPos.z; - wrc.matrixStack().translate(x+0.25, y+0.25+1, z+0.25); - wrc.matrixStack().scale(0.5f, 0.5f, 0.5f); + matrixStack.translate(x+0.25, y+0.25+1, z+0.25); + matrixStack.scale(0.5f, 0.5f, 0.5f); MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity( Blocks.DIAMOND_BLOCK.getDefaultState(), - wrc.matrixStack(), wrc.consumers(), 15728880, OverlayTexture.DEFAULT_UV); + matrixStack, wrc.consumers(), 15728880, OverlayTexture.DEFAULT_UV); - wrc.matrixStack().pop(); + matrixStack.pop(); } return true; diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java index d265f659ad..695db8086f 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/LootManagerMixin.java @@ -31,11 +31,12 @@ import org.spongepowered.asm.mixin.injection.Inject; 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.loot.LootDataType; import net.minecraft.loot.LootManager; import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.RegistryOps; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; @@ -51,21 +52,21 @@ public class LootManagerMixin { @Unique private static final Map dynamicRegistryManagerMap = Collections.synchronizedMap(new IdentityHashMap<>()); - @Inject(method = "load", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;runAsync(Ljava/lang/Runnable;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void load(LootDataType type, ResourceManager resourceManager, Executor executor, Map, Map> results, CallbackInfoReturnable> cir, Map map) { - dynamicRegistryManagerMap.put(map, ResourceConditionsImpl.CURRENT_REGISTRIES.get()); + @Inject(method = "load", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;runAsync(Ljava/lang/Runnable;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) + private static void load(LootDataType type, RegistryWrapper.WrapperLookup wrapperLookup, ResourceManager resourceManager, Executor executor, Map, Map> results, CallbackInfoReturnable> cir) { + dynamicRegistryManagerMap.put(results.get(type), ResourceConditionsImpl.CURRENT_REGISTRIES.get()); } // runAsync Runnable in load method @Inject(method = "method_51189", at = @At("HEAD")) - private static void runAsync(ResourceManager resourceManager, LootDataType lootDataType, Map map, CallbackInfo ci) { + private static void runAsync(ResourceManager resourceManager, LootDataType lootDataType, RegistryOps registryOps, Map map, CallbackInfo ci) { assert ResourceConditionsImpl.CURRENT_REGISTRIES.get() == null; ResourceConditionsImpl.CURRENT_REGISTRIES.set(Objects.requireNonNull(dynamicRegistryManagerMap.remove(map))); } // forEach in load method @Inject(method = "method_51195", at = @At("HEAD"), cancellable = true) - private static void applyResourceConditions(LootDataType lootDataType, Map map, Identifier id, JsonElement json, CallbackInfo ci) { + private static void applyResourceConditions(LootDataType lootDataType, RegistryOps registryOps, Map map, Identifier id, JsonElement json, CallbackInfo ci) { if (json.isJsonObject()) { JsonObject obj = json.getAsJsonObject(); @@ -86,7 +87,7 @@ private static void applyResourceConditions(LootDataType lootDataType, Map map, // runAsync Runnable in load method @Inject(method = "method_51189", at = @At("RETURN")) - private static void runAsyncEnd(ResourceManager resourceManager, LootDataType lootDataType, Map map, CallbackInfo ci) { + private static void runAsyncEnd(ResourceManager resourceManager, LootDataType lootDataType, RegistryOps registryOps, Map map, CallbackInfo ci) { ResourceConditionsImpl.CURRENT_REGISTRIES.remove(); } } diff --git a/fabric-screen-handler-api-v1/src/main/java/net/fabricmc/fabric/impl/screenhandler/Networking.java b/fabric-screen-handler-api-v1/src/main/java/net/fabricmc/fabric/impl/screenhandler/Networking.java index 8c55acb6e6..bfec5e041f 100644 --- a/fabric-screen-handler-api-v1/src/main/java/net/fabricmc/fabric/impl/screenhandler/Networking.java +++ b/fabric-screen-handler-api-v1/src/main/java/net/fabricmc/fabric/impl/screenhandler/Networking.java @@ -20,8 +20,6 @@ import java.util.Map; import java.util.Objects; -import net.minecraft.text.TextCodecs; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,6 +30,7 @@ import net.minecraft.screen.ScreenHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; +import net.minecraft.text.TextCodecs; import net.minecraft.util.Identifier; import net.fabricmc.api.ModInitializer; diff --git a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlockEntity.java b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlockEntity.java index d88825fddc..04794778e1 100644 --- a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlockEntity.java +++ b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlockEntity.java @@ -19,6 +19,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -57,14 +58,14 @@ public void tick() { } @Override - protected void writeNbt(NbtCompound nbt) { - super.writeNbt(nbt); + protected void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { + super.writeNbt(nbt, wrapperLookup); storage.writeNbt(nbt); } @Override - public void readNbt(NbtCompound nbt) { - super.readNbt(nbt); + public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) { + super.readNbt(nbt, wrapperLookup); storage.readNbt(nbt); } } diff --git a/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener b/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener index d89e673155..dcbcd06dff 100644 --- a/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener +++ b/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener @@ -40,7 +40,7 @@ transitive-accessible class net/minecraft/village/TradeOffers$SellMapFactory transitive-accessible class net/minecraft/village/TradeOffers$SellDyedArmorFactory # Registering custom entity spawn restrictions -transitive-accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/class_9168;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V +transitive-accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/entity/SpawnLocation;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V # Item usage context constructors transitive-accessible method net/minecraft/item/ItemUsageContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V @@ -306,6 +306,7 @@ transitive-accessible field net/minecraft/client/render/RenderPhase LIGHTNING_PR transitive-accessible field net/minecraft/client/render/RenderPhase TRIPWIRE_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram; transitive-accessible field net/minecraft/client/render/RenderPhase END_PORTAL_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram; transitive-accessible field net/minecraft/client/render/RenderPhase END_GATEWAY_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram; +transitive-accessible field net/minecraft/client/render/RenderPhase field_48949 Lnet/minecraft/client/render/RenderPhase$ShaderProgram; transitive-accessible field net/minecraft/client/render/RenderPhase LINES_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram; transitive-accessible field net/minecraft/client/render/RenderPhase GUI_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram; transitive-accessible field net/minecraft/client/render/RenderPhase GUI_OVERLAY_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram; diff --git a/fabric-transitive-access-wideners-v1/template.accesswidener b/fabric-transitive-access-wideners-v1/template.accesswidener index 80b4622337..a5809648bd 100644 --- a/fabric-transitive-access-wideners-v1/template.accesswidener +++ b/fabric-transitive-access-wideners-v1/template.accesswidener @@ -35,7 +35,7 @@ transitive-accessible class net/minecraft/village/TradeOffers$SellMapFactory transitive-accessible class net/minecraft/village/TradeOffers$SellDyedArmorFactory # Registering custom entity spawn restrictions -transitive-accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/class_9168;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V +transitive-accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/entity/SpawnLocation;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V # Item usage context constructors transitive-accessible method net/minecraft/item/ItemUsageContext (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V