|
|
@@ -0,0 +1,42 @@ |
|
|
|
package click.vpzom.coloredslime.mixin; |
|
|
|
|
|
|
|
import net.minecraft.block.Block; |
|
|
|
import net.minecraft.block.BlockState; |
|
|
|
import net.minecraft.block.Blocks; |
|
|
|
import net.minecraft.block.SlimeBlock; |
|
|
|
import net.minecraft.block.piston.PistonHandler; |
|
|
|
import net.minecraft.util.math.BlockPos; |
|
|
|
import net.minecraft.world.World; |
|
|
|
import org.spongepowered.asm.mixin.Mixin; |
|
|
|
import org.spongepowered.asm.mixin.Shadow; |
|
|
|
import org.spongepowered.asm.mixin.gen.Invoker; |
|
|
|
import org.spongepowered.asm.mixin.injection.At; |
|
|
|
import org.spongepowered.asm.mixin.injection.Inject; |
|
|
|
import org.spongepowered.asm.mixin.injection.Redirect; |
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
|
|
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
|
|
|
|
|
|
|
@Mixin(PistonHandler.class) |
|
|
|
public abstract class PistonHandlerMixin { |
|
|
|
@Shadow |
|
|
|
private World world; |
|
|
|
|
|
|
|
@Invoker |
|
|
|
protected abstract boolean callMethod_11538(BlockPos pos); |
|
|
|
|
|
|
|
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), method = "calculatePush()Z", allow = 1, locals = LocalCapture.CAPTURE_FAILEXCEPTION) |
|
|
|
private void calculatePushSlime(CallbackInfoReturnable<Boolean> info, int _i, BlockPos pos) { |
|
|
|
if(world.getBlockState(pos).getBlock() instanceof SlimeBlock && !callMethod_11538(pos)) { |
|
|
|
info.setReturnValue(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), method = "tryMove(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;)Z") |
|
|
|
private Block hackSlimeBlock(BlockState state) { |
|
|
|
Block block = state.getBlock(); |
|
|
|
if(block instanceof SlimeBlock) { |
|
|
|
return Blocks.SLIME_BLOCK; |
|
|
|
} |
|
|
|
return block; |
|
|
|
} |
|
|
|
} |