Tweaks on top of #1775
Make new interface not have default methods, make `Shadow` body throw and tiny style changes
This commit is contained in:
3 files changed
+8
-10
No files matched your search
@@ -15,14 +15,10 @@ public interface BlockPistonBehaviourInterface {
|
||||
/**
|
||||
* @return whether this block is sticky in any way when moved by pistons
|
||||
*/
|
||||
default boolean isSticky(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
boolean isSticky(BlockState state);
|
||||
|
||||
/**
|
||||
* @return whether the neighboring block is pulled along if this block is moved by pistons
|
||||
*/
|
||||
default boolean isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir) {
|
||||
return false;
|
||||
}
|
||||
boolean isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BlockPistonBehaviourInterface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.BlockPistonBehaviourInterface;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
@@ -19,12 +19,14 @@ import net.minecraft.world.level.block.piston.PistonStructureResolver;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@Mixin(PistonStructureResolver.class)
|
||||
public abstract class PistonStructureResolver_customStickyMixin {
|
||||
public class PistonStructureResolver_customStickyMixin {
|
||||
|
||||
@Shadow @Final private Level level;
|
||||
@Shadow @Final private Direction pushDirection;
|
||||
|
||||
@Shadow private static boolean canStickToEachOther(BlockState blockState, BlockState blockState2) { return false; }
|
||||
@Shadow private static boolean canStickToEachOther(BlockState blockState, BlockState blockState2) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "isSticky",
|
||||
@@ -34,7 +36,7 @@ public abstract class PistonStructureResolver_customStickyMixin {
|
||||
)
|
||||
)
|
||||
private static void isSticky(BlockState state, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(state.getBlock() instanceof BlockPistonBehaviourInterface behaviourInterface){
|
||||
if (state.getBlock() instanceof BlockPistonBehaviourInterface behaviourInterface){
|
||||
cir.setReturnValue(behaviourInterface.isSticky(state));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user