diff --git a/README.md b/README.md index bc2643b2..647db8c5 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ All changes are toggleable via config files. * **Packet Size:** Increases the packet size limit to account for large packets in modded environments * **Particle Spawning:** Fixes various particle types not showing up on the client * **Piston Progress:** Properly saves the last state of pistons to tags +* **Piston Retraction:** Improves retraction behavior on double piston extenders * **Portal Traveling Dupe:** Fixes duplication issues that can occur when entities travel through portals * **Potion Amplifier Visibility:** Fixes potion effects not displaying their level above 'IV' * **Shear Mooshroom Dupe:** Fixes a duplication exploit connected to shearing mooshrooms diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/pistonretraction/mixin/UTPistonBaseBlockMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/pistonretraction/mixin/UTPistonBaseBlockMixin.java new file mode 100644 index 00000000..289f5f1e --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/pistonretraction/mixin/UTPistonBaseBlockMixin.java @@ -0,0 +1,32 @@ +package mod.acgaming.universaltweaks.bugfixes.blocks.piston.pistonretraction.mixin; + +import static net.minecraft.block.BlockPistonBase.EXTENDED; + +import net.minecraft.block.BlockPistonBase; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import mod.acgaming.universaltweaks.UniversalTweaks; +import mod.acgaming.universaltweaks.config.UTConfigBugfixes; +import org.objectweb.asm.Opcodes; +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; + +// MC-88959 +// https://bugs.mojang.com/browse/MC-88959 +// Courtesy of mrgrim +@Mixin(BlockPistonBase.class) +public abstract class UTPistonBaseBlockMixin +{ + @Inject(method = "checkForMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V", ordinal = 1)) + private void onPistonDepower(World worldIn, BlockPos pos, IBlockState state, CallbackInfo ci) + { + if (UTConfigBugfixes.BLOCKS.utPistonRetractionToggle) + { + worldIn.setBlockState(pos, state.withProperty(EXTENDED, false), 2); + } + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java index 811a6e91..1e341383 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java @@ -89,6 +89,11 @@ public static class BlocksCategory @Config.Name("Piston Progress") @Config.Comment("Properly saves the last state of pistons to tags") public boolean utPistonTileToggle = true; + + @Config.RequiresMcRestart + @Config.Name("Piston Retraction") + @Config.Comment("Improves retraction behavior on double piston extenders") + public boolean utPistonRetractionToggle = true; @Config.RequiresMcRestart @Config.Name("Sleep Resets Weather") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 7fead7c9..4b4a8bbf 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -157,6 +157,7 @@ public List getMixinConfigs() configs.add("mixins.bugfixes.blocks.ladderflying.json"); configs.add("mixins.bugfixes.blocks.miningglitch.server.json"); configs.add("mixins.bugfixes.blocks.pistontile.json"); + configs.add("mixins.bugfixes.blocks.pistontile.pistonretraction.json"); configs.add("mixins.bugfixes.entities.ai.json"); configs.add("mixins.bugfixes.entities.attackradius.json"); configs.add("mixins.bugfixes.entities.blockfire.json"); @@ -336,6 +337,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigBugfixes.BLOCKS.utMiningGlitchToggle; case "mixins.bugfixes.blocks.pistontile.json": return UTConfigBugfixes.BLOCKS.utPistonTileToggle; + case "mixins.bugfixes.blocks.pistontile.pistonretraction.json": + return UTConfigBugfixes.BLOCKS.utPistonRetractionToggle; case "mixins.bugfixes.blocks.bed.json": return UTConfigBugfixes.BLOCKS.utSleepResetsWeatherToggle; case "mixins.bugfixes.misc.enchantment.json": diff --git a/src/main/resources/mixins.bugfixes.blocks.pistontile.pistonretraction.json b/src/main/resources/mixins.bugfixes.blocks.pistontile.pistonretraction.json new file mode 100644 index 00000000..c4408cdf --- /dev/null +++ b/src/main/resources/mixins.bugfixes.blocks.pistontile.pistonretraction.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.bugfixes.blocks.piston.pistonretraction.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTPistonBaseBlockMixin"] +} \ No newline at end of file