Skip to content

Commit

Permalink
Fix porting of Data Attachment block entity support
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j committed Mar 29, 2024
1 parent 4c67997 commit efd38d2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.block.entity.BlockEntity;
Expand All @@ -30,11 +31,11 @@
@Mixin(BlockEntity.class)
abstract class BlockEntityMixin implements AttachmentTargetImpl {
@Inject(
method = "method_17897", // lambda body in BlockEntity#createFromNbt
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/BlockEntity;read(Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)V")
method = "read",
at = @At("RETURN")
)
private static void readBlockEntityAttachments(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup, String string, BlockEntity blockEntity, CallbackInfoReturnable<BlockEntity> cir) {
((AttachmentTargetImpl) blockEntity).fabric_readAttachmentsFromNbt(nbt, wrapperLookup);
private void readBlockEntityAttachments(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup, CallbackInfo ci) {
this.fabric_readAttachmentsFromNbt(nbt, registryLookup);
}

@Inject(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"mixins": [
"AttachmentTargetsMixin",
"BlockEntityMixin",
"BlockEntityUpdateS2CPacketMixin",
"ChunkSerializerMixin",
"EntityMixin",
"ServerWorldMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void testBlockEntitySync(TestContext context) {
NbtCompound nbt = ((BlockEntityUpdateS2CPacket) packet).getNbt();

if (nbt != null && nbt.contains(AttachmentTarget.NBT_ATTACHMENT_KEY)) {
// Note: this is a vanilla bug (it called createNbt, instead of the correct createComponentlessNbt)
throw new GameTestException("Packet NBT for " + entry + " had persistent data: " + nbt.asString());
}
}
Expand Down

0 comments on commit efd38d2

Please sign in to comment.