From 87186be4827a6b7165f21c2a08949f1a094032aa Mon Sep 17 00:00:00 2001 From: FX Date: Tue, 6 Jul 2021 11:35:49 -0400 Subject: [PATCH] Added Rule: `movingBlocksDestroyPathFix` --- README.md | 10 +++++++- .../java/carpetfixes/CarpetFixesSettings.java | 10 +++++++- .../DirtPathBlock_movingBlockMixin.java | 25 +++++++++++++++++++ src/main/resources/carpetfixes.mixins.json | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/main/java/carpetfixes/mixins/blockFixes/DirtPathBlock_movingBlockMixin.java diff --git a/README.md b/README.md index 6cb8d394..1106cf8c 100644 --- a/README.md +++ b/README.md @@ -273,11 +273,19 @@ Fixes Explosions being able to destroy item frames in water * Type: `boolean` * Default value: `false` * Required options: `false`,`true` -* Categories: `CARPETFIXES`,`BUGFIX`,`EXPERIMENTAL` +* Categories: `CARPETFIXES`,`BUGFIX` * Fixes: [MC-3697](https://bugs.mojang.com/browse/MC-3697) * Additional notes: * Only doing so for Item Frames +## movingBlocksDestroyPathFix +Fixes Moving Blocks from destroying path blocks +* Type: `boolean` +* Default value: `false` +* Required options: `false`,`true` +* Categories: `CARPETFIXES`,`BUGFIX` +* Fixes: [MC-161026](https://bugs.mojang.com/browse/MC-161026) + ## drownedEnchantedTridentsFix Makes enchantments work on tridents thrown by drowned * Type: `boolean` diff --git a/src/main/java/carpetfixes/CarpetFixesSettings.java b/src/main/java/carpetfixes/CarpetFixesSettings.java index 42a640c1..037f42bf 100644 --- a/src/main/java/carpetfixes/CarpetFixesSettings.java +++ b/src/main/java/carpetfixes/CarpetFixesSettings.java @@ -331,10 +331,18 @@ public enum PresetSettings { @Rule( desc = "Fixes Explosions being able to destroy item frames in water", extra = "Fixes [MC-3697](https://bugs.mojang.com/browse/MC-3697)", - category = {CARPETFIXES,BUGFIX,EXPERIMENTAL} + category = {CARPETFIXES,BUGFIX} ) public static boolean explosionBreaksItemFrameInWaterFix = false; + //by FX - PR0CESS + @Rule( + desc = "Fixes Moving Blocks from destroying path blocks", + extra = "Fixes [MC-161026](https://bugs.mojang.com/browse/MC-161026)", + category = {CARPETFIXES,BUGFIX} + ) + public static boolean movingBlocksDestroyPathFix = false; + /* BACKPORTS diff --git a/src/main/java/carpetfixes/mixins/blockFixes/DirtPathBlock_movingBlockMixin.java b/src/main/java/carpetfixes/mixins/blockFixes/DirtPathBlock_movingBlockMixin.java new file mode 100644 index 00000000..6b028758 --- /dev/null +++ b/src/main/java/carpetfixes/mixins/blockFixes/DirtPathBlock_movingBlockMixin.java @@ -0,0 +1,25 @@ +package carpetfixes.mixins.blockFixes; + +import carpetfixes.CarpetFixesSettings; +import net.minecraft.block.BlockState; +import net.minecraft.block.DirtPathBlock; +import net.minecraft.block.FenceGateBlock; +import net.minecraft.block.PistonExtensionBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldView; +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; + +@Mixin(DirtPathBlock.class) +public class DirtPathBlock_movingBlockMixin { + + @Inject(method= "canPlaceAt(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)Z",at=@At("HEAD"),cancellable = true) + public void canPlaceAt(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable cir) { + if (CarpetFixesSettings.movingBlocksDestroyPathFix) { + BlockState blockState = world.getBlockState(pos.up()); + cir.setReturnValue(!blockState.getMaterial().isSolid() || blockState.getBlock() instanceof FenceGateBlock || blockState.getBlock() instanceof PistonExtensionBlock); + } + } +} diff --git a/src/main/resources/carpetfixes.mixins.json b/src/main/resources/carpetfixes.mixins.json index da3c2ee9..05dbc6c5 100644 --- a/src/main/resources/carpetfixes.mixins.json +++ b/src/main/resources/carpetfixes.mixins.json @@ -5,6 +5,7 @@ "mixins": [ "backports.AbstractFireBlock_flintAndSteelMixin", "backports.PlayerManager_LlamaRidingDupeMixin", + "blockFixes.DirtPathBlock_movingBlockMixin", "blockFixes.LightningRodBlock_PermanentlyPoweredMixin", "blockFixes.PowderSnowBlock_centerCollisionMixin", "blockFixes.SlimeBlock_incorrectLogicMixin",