Skip to content

Commit

Permalink
UDOC-0 - Disable old slab placement when modern slab placement is active
Browse files Browse the repository at this point in the history
  • Loading branch information
telvarost committed May 9, 2024
1 parent b531e7d commit cd4f41a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/annoyancefix.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"PigMixin",
"PlayerBaseMixin",
"StairsMixin",
"StoneSlabMixin",
"StoneSlabBlockMixin",
"StoneSlabItemMixin",
"ToolBaseMixin"
],
"server": [
Expand Down

0 comments on commit cd4f41a

Please sign in to comment.