From 294a1918cad7c7d83588c8665b63acc8300443e6 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Fri, 21 May 2021 18:31:40 +0800 Subject: [PATCH] rule `shulkerTeleportFix` --- .../java/carpetfixes/CarpetFixesSettings.java | 8 ++++++ .../ShulkerEntity_CustomDataMixin.java | 26 +++++++++++++++++++ src/main/resources/carpetfixes.mixins.json | 1 + 3 files changed, 35 insertions(+) create mode 100644 src/main/java/carpetfixes/mixins/entityFixes/ShulkerEntity_CustomDataMixin.java diff --git a/src/main/java/carpetfixes/CarpetFixesSettings.java b/src/main/java/carpetfixes/CarpetFixesSettings.java index 6a4610ee..2ba91559 100644 --- a/src/main/java/carpetfixes/CarpetFixesSettings.java +++ b/src/main/java/carpetfixes/CarpetFixesSettings.java @@ -106,6 +106,14 @@ public class CarpetFixesSettings { ) public static boolean targetBlockPermanentlyPoweredFix = true; + //By Hendrix-Shen + @Rule( + desc = "Shulkers do not teleport correctly when going through a portal.", + extra = "Fixed [MC-139265](https://bugs.mojang.com/browse/MC-139265) in 21w03a", + category = {CARPETFIXES,BACKPORT} + ) + public static boolean shulkerTeleportFix = false; + /* diff --git a/src/main/java/carpetfixes/mixins/entityFixes/ShulkerEntity_CustomDataMixin.java b/src/main/java/carpetfixes/mixins/entityFixes/ShulkerEntity_CustomDataMixin.java new file mode 100644 index 00000000..74a03e83 --- /dev/null +++ b/src/main/java/carpetfixes/mixins/entityFixes/ShulkerEntity_CustomDataMixin.java @@ -0,0 +1,26 @@ +package carpetfixes.mixins.entityFixes; + +import carpetfixes.CarpetFixesSettings; +import net.minecraft.entity.mob.ShulkerEntity; +import net.minecraft.nbt.CompoundTag; +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; + +@Mixin(ShulkerEntity.class) +public class ShulkerEntity_CustomDataMixin { + @Inject( + method = "writeCustomDataToTag", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/mob/ShulkerEntity;getAttachedBlock()Lnet/minecraft/util/math/BlockPos;" + ), + cancellable = true + ) + private void onWriteCustomDataToTag(CompoundTag tag, CallbackInfo ci) { + if (CarpetFixesSettings.shulkerTeleportFix) { + ci.cancel(); + } + } +} diff --git a/src/main/resources/carpetfixes.mixins.json b/src/main/resources/carpetfixes.mixins.json index 8f6086b2..6441ba15 100644 --- a/src/main/resources/carpetfixes.mixins.json +++ b/src/main/resources/carpetfixes.mixins.json @@ -13,6 +13,7 @@ "dupeFixes.PistonBlock_tntDupingFixMixin", "entityFixes.EndCrystalEntity_ExplosionChainingMixin", "entityFixes.Entity_blockCollisionMixin", + "entityFixes.ShulkerEntity_CustomDataMixin", "redstoneFixes.AbstractRedstoneGateBlock_repeaterPriorityMixin", "redstoneFixes.PistonBlock_doubleRetractionMixin", "redstoneFixes.World_ComparatorNotUpdatingMixin"