blob: 428d195e31d2dc7eeb20d2d5dabc56155abf55a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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.DragonEggBlock;
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().getBlock() instanceof DragonEggBlock
&& state.getPistonPushReaction() != PushReaction.DESTROY
) {
return Shapes.block();
}
return shape;
}
}
|