From cd4f41ab55ed9375113ffa4e73a58798fa7926e8 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 9 May 2024 00:04:40 -0400 Subject: [PATCH] UDOC-0 - Disable old slab placement when modern slab placement is active --- gradle.properties | 2 +- .../annoyancefix/AnnoyanceFixMixinPlugin.java | 2 +- .../mixin/StoneSlabBlockMixin.java | 31 +++++++++++++++++++ ...SlabMixin.java => StoneSlabItemMixin.java} | 4 +-- src/main/resources/annoyancefix.mixins.json | 3 +- 5 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabBlockMixin.java rename src/main/java/com/github/telvarost/annoyancefix/mixin/{StoneSlabMixin.java => StoneSlabItemMixin.java} (96%) diff --git a/gradle.properties b/gradle.properties index caf4834..bd62b6f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3-build.2 loader_version=0.14.24-babric.1 # Mod Properties -mod_version=2.5.0 +mod_version=2.5.1 maven_group=com.github.telvarost archives_base_name=AnnoyanceFix diff --git a/src/main/java/com/github/telvarost/annoyancefix/AnnoyanceFixMixinPlugin.java b/src/main/java/com/github/telvarost/annoyancefix/AnnoyanceFixMixinPlugin.java index 771ee8a..98ddb61 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/AnnoyanceFixMixinPlugin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/AnnoyanceFixMixinPlugin.java @@ -34,7 +34,7 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { } } - if (mixinClassName.equals("com.github.telvarost.annoyancefix.mixin.StoneSlabMixin")) { + if (mixinClassName.equals("com.github.telvarost.annoyancefix.mixin.StoneSlabItemMixin")) { return Config.config.slabPlacementFixesEnabled; } else { return true; diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabBlockMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabBlockMixin.java new file mode 100644 index 0000000..001bf98 --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabBlockMixin.java @@ -0,0 +1,31 @@ +package com.github.telvarost.annoyancefix.mixin; + +import com.github.telvarost.annoyancefix.Config; +import net.minecraft.block.BlockBase; +import net.minecraft.block.StoneSlab; +import net.minecraft.block.material.Material; +import net.minecraft.level.Level; +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(StoneSlab.class) +public class StoneSlabBlockMixin extends BlockBase { + + public StoneSlabBlockMixin(int i, boolean bl) { + super(i, 6, Material.STONE); + } + + @Inject( + method = "onBlockPlaced", + at = @At("HEAD"), + cancellable = true + ) + public void onBlockPlaced(Level arg, int i, int j, int k, CallbackInfo ci) { + if (Config.config.slabPlacementFixesEnabled) { + super.onBlockPlaced(arg, i, j, k); + ci.cancel(); + } + } +} diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabItemMixin.java similarity index 96% rename from src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabMixin.java rename to src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabItemMixin.java index cfa8ceb..b50d333 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/StoneSlabItemMixin.java @@ -9,8 +9,8 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(StoneSlab.class) -public class StoneSlabMixin extends Block { - public StoneSlabMixin(int i) { +public class StoneSlabItemMixin extends Block { + public StoneSlabItemMixin(int i) { super(i); } diff --git a/src/main/resources/annoyancefix.mixins.json b/src/main/resources/annoyancefix.mixins.json index c63ec5c..fb5a2ae 100644 --- a/src/main/resources/annoyancefix.mixins.json +++ b/src/main/resources/annoyancefix.mixins.json @@ -20,7 +20,8 @@ "PigMixin", "PlayerBaseMixin", "StairsMixin", - "StoneSlabMixin", + "StoneSlabBlockMixin", + "StoneSlabItemMixin", "ToolBaseMixin" ], "server": [