From fb3ca6bdfeea670372d5cce9d266408965fc130d Mon Sep 17 00:00:00 2001 From: Wynd Date: Wed, 11 Sep 2024 16:12:57 +0300 Subject: [PATCH] Pressure plates can be placed on top of fences --- .../mixin/PressurePlateTileMixin.java | 32 +++++++++++++++++++ src/main/resources/finalbeta.mixins.json | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/java/xyz/pixelatedw/finalbeta/mixin/PressurePlateTileMixin.java diff --git a/src/main/java/xyz/pixelatedw/finalbeta/mixin/PressurePlateTileMixin.java b/src/main/java/xyz/pixelatedw/finalbeta/mixin/PressurePlateTileMixin.java new file mode 100644 index 0000000..2a71eb5 --- /dev/null +++ b/src/main/java/xyz/pixelatedw/finalbeta/mixin/PressurePlateTileMixin.java @@ -0,0 +1,32 @@ +package xyz.pixelatedw.finalbeta.mixin; + +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.level.Level; +import net.minecraft.tile.PressurePlateTile; +import net.minecraft.tile.Tile; + +@Mixin(PressurePlateTile.class) +public class PressurePlateTileMixin { + @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) + public void canPlaceAt(Level level, int x, int y, int z, CallbackInfoReturnable cir) { + int tileId = level.getTileId(x, y - 1, z); + if (tileId == Tile.FENCE.id) { + cir.setReturnValue(true); + return; + } + } + + @Inject(method = "method_1609", at = @At("HEAD"), cancellable = true) + public void canSurviveAt(Level level, int x, int y, int z, int i1, CallbackInfo ci) { + int tileId = level.getTileId(x, y - 1, z); + if (tileId == Tile.FENCE.id) { + ci.cancel(); + return; + } + } +} diff --git a/src/main/resources/finalbeta.mixins.json b/src/main/resources/finalbeta.mixins.json index b60621e..d2e6b7e 100644 --- a/src/main/resources/finalbeta.mixins.json +++ b/src/main/resources/finalbeta.mixins.json @@ -46,7 +46,8 @@ "TranslationStorageMixin", "RecipeRegistryAccessor", "FoodItemMixin", - "ItemTypeAccessor" + "ItemTypeAccessor", + "PressurePlateTileMixin" ], "injectors": { "defaultRequire": -1