From 8ffc469f6308a75a33a4836caa9581bf6f3efa37 Mon Sep 17 00:00:00 2001 From: kolala Date: Fri, 5 Jul 2024 17:32:35 +0200 Subject: [PATCH 1/2] Fixed wearing a brute/zombified piglin head causes the game to crash --- .../tconstruct/mixin/SkullBlockMixins.java | 35 +++++++++++++++++++ .../tconstruct/world/TinkerWorld.java | 5 +-- src/main/resources/hephaestus.mixins.json | 3 +- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/main/java/slimeknights/tconstruct/mixin/SkullBlockMixins.java diff --git a/src/main/java/slimeknights/tconstruct/mixin/SkullBlockMixins.java b/src/main/java/slimeknights/tconstruct/mixin/SkullBlockMixins.java new file mode 100644 index 00000000000..a95b49eaab0 --- /dev/null +++ b/src/main/java/slimeknights/tconstruct/mixin/SkullBlockMixins.java @@ -0,0 +1,35 @@ +package slimeknights.tconstruct.mixin; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.AbstractSkullBlock; +import net.minecraft.world.level.block.SkullBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +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.CallbackInfoReturnable; +import slimeknights.tconstruct.world.TinkerHeadType; + +@Mixin(SkullBlock.class) +public class SkullBlockMixins extends AbstractSkullBlock { + + @Shadow + @Final + protected static VoxelShape PIGLIN_SHAPE; + + public SkullBlockMixins(SkullBlock.Type type, Properties properties) { + super(type, properties); + } + + @Inject(method = "getShape", at = @At("TAIL"), cancellable = true) + private void getCustomShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext, CallbackInfoReturnable cir) { + if (this.getType() == TinkerHeadType.PIGLIN_BRUTE || this.getType() == TinkerHeadType.ZOMBIFIED_PIGLIN) { + cir.setReturnValue(PIGLIN_SHAPE); + } + } +} diff --git a/src/main/java/slimeknights/tconstruct/world/TinkerWorld.java b/src/main/java/slimeknights/tconstruct/world/TinkerWorld.java index bbfdc273361..4d24d414042 100644 --- a/src/main/java/slimeknights/tconstruct/world/TinkerWorld.java +++ b/src/main/java/slimeknights/tconstruct/world/TinkerWorld.java @@ -254,7 +254,7 @@ private static Function createSlimewood(M public static final ResourceKey placedEarthGeodeKey = placed("earth_geode"); // sky public static final GeodeItemObject skyGeode = BLOCKS.registerGeode("sky_slime_crystal", MapColor.COLOR_BLUE, Sounds.SKY_CRYSTAL, Sounds.SKY_CRYSTAL_CHIME.getSound(), Sounds.SKY_CRYSTAL_CLUSTER, 0, WORLD_PROPS); - public static final ResourceKey> configuredSkyGeodeKey = configured("sky_geode");; + public static final ResourceKey> configuredSkyGeodeKey = configured("sky_geode"); public static final ResourceKey placedSkyGeodeKey = placed("sky_geode"); // ichor public static final GeodeItemObject ichorGeode = BLOCKS.registerGeode("ichor_slime_crystal", MapColor.COLOR_ORANGE, Sounds.ICHOR_CRYSTAL, Sounds.ICHOR_CRYSTAL_CHIME.getSound(), Sounds.ICHOR_CRYSTAL_CLUSTER, 10, WORLD_PROPS); @@ -466,9 +466,6 @@ public static void gatherData(final FabricDataGenerator.Pack pack) { /** Creates a skull block for the given head type */ private static SkullBlock makeHead(TinkerHeadType type) { BlockBehaviour.Properties props = BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).strength(1.0F); - if (type == TinkerHeadType.PIGLIN_BRUTE || type == TinkerHeadType.ZOMBIFIED_PIGLIN) { - return new SkullBlock(SkullBlock.Types.PIGLIN, props); - } return new SkullBlock(type, props); } diff --git a/src/main/resources/hephaestus.mixins.json b/src/main/resources/hephaestus.mixins.json index 3e07a9ac773..634c79d56ef 100644 --- a/src/main/resources/hephaestus.mixins.json +++ b/src/main/resources/hephaestus.mixins.json @@ -9,6 +9,7 @@ "maxShiftBy": 5 }, "mixins": [ - "DataFixersMixin" + "DataFixersMixin", + "SkullBlockMixins" ] } From 9987cc31119b20da0e8acbac846970a65388ef22 Mon Sep 17 00:00:00 2001 From: kolala Date: Fri, 5 Jul 2024 19:35:27 +0200 Subject: [PATCH 2/2] Fixed a bug where enchantments on chestplate would get removed when using a piggy backpack Fixed a bug when inventory is full, no chestplate is on but the piggy backpack doesn't work Now giving back the chestplate where the piggy backpack item was --- .../tconstruct/gadgets/item/PiggyBackPackItem.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/slimeknights/tconstruct/gadgets/item/PiggyBackPackItem.java b/src/main/java/slimeknights/tconstruct/gadgets/item/PiggyBackPackItem.java index 5a331ede6b5..c2281b51475 100644 --- a/src/main/java/slimeknights/tconstruct/gadgets/item/PiggyBackPackItem.java +++ b/src/main/java/slimeknights/tconstruct/gadgets/item/PiggyBackPackItem.java @@ -46,17 +46,20 @@ public InteractionResult interactLivingEntity(ItemStack stack, Player playerIn, // is the chest slot empty? ItemStack chestArmor = playerIn.getItemBySlot(EquipmentSlot.CHEST); - // need enough space to exchange the chest armor - if (chestArmor.getItem() != this && playerIn.getInventory().getFreeSlot() == -1) { - // not enough inventory space - return InteractionResult.PASS; + if(chestArmor != ItemStack.EMPTY) { + // need enough space to exchange the chest armor + if (chestArmor.getItem() != this && playerIn.getInventory().getFreeSlot() == -1) { + // not enough inventory space + return InteractionResult.PASS; + } } // try carrying the entity if (this.pickupEntity(playerIn, target)) { // unequip old armor if (chestArmor.getItem() != this) { - ItemHandlerHelper.giveItemToPlayer(playerIn, chestArmor); + int piggyBackpackSlot = playerIn.getInventory().findSlotMatchingItem(stack); + playerIn.getInventory().add(piggyBackpackSlot, chestArmor); chestArmor = ItemStack.EMPTY; }