下面列出了net.minecraft.util.shape.VoxelShape#net.minecraft.util.shape.VoxelShapes 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Inject(at = {@At("HEAD")},
method = {
"getOutlineShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;"},
cancellable = true)
private void onGetOutlineShape(BlockView view, BlockPos pos,
ShapeContext context, CallbackInfoReturnable<VoxelShape> cir)
{
if(context == ShapeContext.absent())
return;
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null)
return;
HandNoClipHack handNoClipHack = hax.handNoClipHack;
if(!handNoClipHack.isEnabled() || handNoClipHack.isBlockInList(pos))
return;
cir.setReturnValue(VoxelShapes.empty());
}
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) {
ArrayList<VoxelShape> shapes = new ArrayList<>();
if (blockState.get(ATTACHED_NORTH)) {
shapes.add(NORTH);
}
if (blockState.get(ATTACHED_SOUTH)) {
shapes.add(SOUTH);
}
if (blockState.get(ATTACHED_EAST)) {
shapes.add(EAST);
}
if (blockState.get(ATTACHED_WEST)) {
shapes.add(WEST);
}
if (blockState.get(ATTACHED_UP)) {
shapes.add(UP);
}
if (blockState.get(ATTACHED_DOWN)) {
shapes.add(DOWN);
}
if (shapes.isEmpty()) {
return NONE;
} else {
return VoxelShapes.union(NONE, shapes.toArray(new VoxelShape[0]));
}
}
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) {
ArrayList<VoxelShape> shapes = new ArrayList<>();
if (blockState.get(ATTACHED_NORTH)) {
shapes.add(NORTH);
}
if (blockState.get(ATTACHED_SOUTH)) {
shapes.add(SOUTH);
}
if (blockState.get(ATTACHED_EAST)) {
shapes.add(EAST);
}
if (blockState.get(ATTACHED_WEST)) {
shapes.add(WEST);
}
if (blockState.get(ATTACHED_UP)) {
shapes.add(UP);
}
if (blockState.get(ATTACHED_DOWN)) {
shapes.add(DOWN);
}
if (shapes.isEmpty()) {
return NONE;
} else {
return VoxelShapes.union(NONE, shapes.toArray(new VoxelShape[0]));
}
}
private static VoxelShape createShape(boolean north, boolean south, boolean east, boolean west) {
VoxelShape top1 = Block.createCuboidShape(0.0D, 13.0D, 0.0D, 2.0D, 16.0D, 16.0D);
VoxelShape top2 = Block.createCuboidShape(0.0D, 13.0D, 16.0D, 16.0D, 16.0D, 14.0D);
VoxelShape top3 = Block.createCuboidShape(16.0D, 13.0D, 16.0D, 14.0D, 16.0D, 0.0D);
VoxelShape top4 = Block.createCuboidShape(16.0D, 13.0D, 0.0D, 0.0D, 16.0D, 2.0D);
VoxelShape mTop1 = Block.createCuboidShape(6.0D, 15.0D, 2.0D, 16.0D - 6.0D, 14.0D, 16.0D - 2.0D);
VoxelShape mTop2 = Block.createCuboidShape(2.0D, 15.0D, 6.0D, 16.0D - 2.0D, 14.0D, 16.0D - 6.0D);
VoxelShape center = Block.createCuboidShape(6.0D, 15.0D, 6.0D, 10.0D, 6.0D, 10.0);
VoxelShape base = VoxelShapes.union(top1, top2, top3, top4, mTop1, mTop2, center);
if (north) {
base = VoxelShapes.union(base, Block.createCuboidShape(7.0D, 9.0D, 7.0D, 9.0D, 7.0D, 0.0D));
}
if (south) {
base = VoxelShapes.union(base, Block.createCuboidShape(7.0D, 9.0D, 9.0D, 9.0D, 7.0D, 16.0D));
}
if (east) {
base = VoxelShapes.union(base, Block.createCuboidShape(9.0D, 9.0D, 7.0D, 16.0D, 7.0D, 9.0D));
}
if (west) {
base = VoxelShapes.union(base, Block.createCuboidShape(7.0D, 9.0D, 7.0D, 0.0D, 7.0D, 9.0D));
}
return VoxelShapes.union(base);
}
@Override
public VoxelShape getCollisionShape(BlockState blockState_1,
BlockView blockView_1, BlockPos blockPos_1,
ShapeContext entityContext_1)
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax != null && hax.jesusHack.shouldBeSolid())
return VoxelShapes.fullCube();
return super.getCollisionShape(blockState_1, blockView_1, blockPos_1,
entityContext_1);
}
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
return VoxelShapes.empty();
}
@Override
public void onCactusCollisionShape(CactusCollisionShapeEvent event)
{
event.setCollisionShape(VoxelShapes.fullCube());
}