diff options
| author | ash lea <example@thisismyactual.email> | 2026-06-01 14:25:40 -0400 |
|---|---|---|
| committer | ash lea <example@thisismyactual.email> | 2026-06-01 14:25:40 -0400 |
| commit | 52b847653296f6e80fd68678b2a88ee9f560eaff (patch) | |
| tree | b52750d0b649f64a670552d1776e39f6a0a676d3 /src/main/java/wtf/kity/uncrackable/mixin/BlockBehaviourMixin.java | |
initial commit
Diffstat (limited to 'src/main/java/wtf/kity/uncrackable/mixin/BlockBehaviourMixin.java')
| -rw-r--r-- | src/main/java/wtf/kity/uncrackable/mixin/BlockBehaviourMixin.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/wtf/kity/uncrackable/mixin/BlockBehaviourMixin.java b/src/main/java/wtf/kity/uncrackable/mixin/BlockBehaviourMixin.java new file mode 100644 index 0000000..506b0c9 --- /dev/null +++ b/src/main/java/wtf/kity/uncrackable/mixin/BlockBehaviourMixin.java @@ -0,0 +1,35 @@ +package wtf.kity.uncrackable.mixin; + +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.item.FallingBlockEntity; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.EntityCollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(BlockBehaviour.class) +public class BlockBehaviourMixin { + /// If checking collision for a dragon egg, non-piston-destructible blocks should act + /// as full blocks so the egg lands on top of them. + @WrapMethod(method = "getCollisionShape") + VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context, Operation<VoxelShape> original) { + VoxelShape shape = original.call(state, level, pos, context); + if (!shape.isEmpty() + && context instanceof EntityCollisionContext entityContext + && entityContext.getEntity() instanceof FallingBlockEntity fallingBlock + && fallingBlock.getBlockState().is(Blocks.DRAGON_EGG) + && state.getPistonPushReaction() != PushReaction.DESTROY + ) { + return Shapes.block(); + } + return shape; + } +} |