类net.minecraft.util.shape.VoxelShape源码实例Demo

下面列出了怎么用net.minecraft.util.shape.VoxelShape的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Wurst7   文件: JesusHack.java
public boolean isOverLiquid()
{
	boolean foundLiquid = false;
	boolean foundSolid = false;
	
	// check collision boxes below player
	ArrayList<Box> blockCollisions = MC.world
		.getBlockCollisions(MC.player,
			MC.player.getBoundingBox().offset(0, -0.5, 0))
		.map(VoxelShape::getBoundingBox)
		.collect(Collectors.toCollection(() -> new ArrayList<>()));
	
	for(Box bb : blockCollisions)
	{
		BlockPos pos = new BlockPos(bb.getCenter());
		Material material = BlockUtils.getState(pos).getMaterial();
		
		if(material == Material.WATER || material == Material.LAVA)
			foundLiquid = true;
		else if(material != Material.AIR)
			foundSolid = true;
	}
	
	return foundLiquid && !foundSolid;
}
 
源代码2 项目: Wurst7   文件: ParkourHack.java
@Override
public void onUpdate()
{
	if(!MC.player.isOnGround() || MC.options.keyJump.isPressed())
		return;
	
	if(MC.player.isSneaking() || MC.options.keySneak.isPressed())
		return;
	
	Box box = MC.player.getBoundingBox();
	Box adjustedBox = box.offset(0, -0.5, 0).expand(-0.001, 0, -0.001);
	
	Stream<VoxelShape> blockCollisions =
		MC.world.getBlockCollisions(MC.player, adjustedBox);
	
	if(blockCollisions.findAny().isPresent())
		return;
	
	MC.player.jump();
}
 
源代码3 项目: Wurst7   文件: AbstractBlockStateMixin.java
@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());
}
 
源代码4 项目: Wurst7   文件: CactusBlockMixin.java
@Inject(at = {@At("HEAD")},
	method = {
		"getOutlineShape(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;"},
	cancellable = true)
private void onGetCollisionShape(BlockState blockState_1,
	BlockView blockView_1, BlockPos blockPos_1,
	ShapeContext entityContext_1, CallbackInfoReturnable<VoxelShape> cir)
{
	EventManager events = WurstClient.INSTANCE.getEventManager();
	if(events == null)
		return;
	
	CactusCollisionShapeEvent event = new CactusCollisionShapeEvent();
	events.fire(event);
	
	VoxelShape collisionShape = event.getCollisionShape();
	if(collisionShape != null)
		cir.setReturnValue(collisionShape);
}
 
@Redirect(method = "canPlace", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/world/World;canPlace(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityContext;)Z"
))
private boolean canSpectatingPlace(World world, BlockState state, BlockPos pos, EntityContext context,
                                   ItemPlacementContext contextOuter, BlockState stateOuter)
{
    PlayerEntity player = contextOuter.getPlayer();
    if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.abilities.flying)
    {
        // copy from canPlace
        VoxelShape voxelShape = state.getCollisionShape(world, pos, context);
        return voxelShape.isEmpty() || world.intersectsEntities(player, voxelShape.offset(pos.getX(), pos.getY(), pos.getZ()));

    }
    return world.canPlace(state, pos, context);
}
 
源代码6 项目: Galacticraft-Rewoven   文件: MoonBerryBushBlock.java
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) {
    if (blockState.get(AGE) == 0) {
        return SMALL_SHAPE;
    } else {
        return blockState.get(AGE) < 3 ? LARGE_SHAPE : super.getOutlineShape(blockState, blockView, blockPos, context);
    }
}
 
源代码7 项目: Galacticraft-Rewoven   文件: FluidPipeBlock.java
@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]));
    }
}
 
源代码8 项目: Galacticraft-Rewoven   文件: AluminumWireBlock.java
@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]));
    }
}
 
源代码9 项目: Galacticraft-Rewoven   文件: Walkway.java
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);
}
 
源代码10 项目: Galacticraft-Rewoven   文件: Walkway.java
private VoxelShape getShape(BlockState state) {
    int index = getShapeIndex(state);
    if (shape[index] != null) {
        return shape[index];
    }
    return shape[index] = createShape(state.get(NORTH), state.get(SOUTH), state.get(EAST), state.get(WEST));
}
 
@Override
public VoxelShape getOutlineShape(BlockState blockState_1, BlockView blockView_1, BlockPos pos, ShapeContext context) {
    Block down = blockView_1.getBlockState(pos.down()).getBlock();
    if (down == GalacticraftBlocks.BASIC_SOLAR_PANEL) {
        return POLE_SHAPE;
    } else if (blockView_1.getBlockState(pos.down().down()).getBlock() == GalacticraftBlocks.BASIC_SOLAR_PANEL) {
        return TOP_MID_SHAPE;
    }
    return TOP_SHAPE;
}
 
源代码12 项目: Wurst7   文件: FluidBlockMixin.java
@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);
}
 
源代码13 项目: bleachhack-1.14   文件: MixinBlock.java
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) {
    if (ModuleManager.getModule(Xray.class).isToggled()) {
        callback.setReturnValue(false);
        callback.cancel();
    }
}
 
源代码14 项目: bleachhack-1.14   文件: MixinBlock.java
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) {
    if (ModuleManager.getModule(Xray.class).isToggled()) {
        callback.setReturnValue(false);
        callback.cancel();
    }
}
 
源代码15 项目: bleachhack-1.14   文件: MixinBlock.java
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) {
    if (ModuleManager.getModule(Xray.class).isToggled()) {
        callback.setReturnValue(false);
        callback.cancel();
    }
}
 
源代码16 项目: Galacticraft-Rewoven   文件: GratingBlock.java
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) {
    return blockState.get(GRATING_STATE) == GratingState.UPPER ?
            Block.createCuboidShape(0.0D, 14.0D, 0.0D, 16.0D, 16.0D, 16.0D) :
            Block.createCuboidShape(0.0D, 6.0D, 0.0D, 16.0D, 8.0D, 16.0D);
}
 
源代码17 项目: Galacticraft-Rewoven   文件: Walkway.java
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
    return getShape(state);
}
 
源代码18 项目: Galacticraft-Rewoven   文件: Walkway.java
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
    return getShape(state);
}
 
@Inject(at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V"), method = "generatePiece", remap = false)
private void extraDebugInfoGC(PoolStructurePiece piece, MutableObject<VoxelShape> mutableObject, int minY, int currentSize, boolean bl, CallbackInfo ci) {
    if (Galacticraft.configManager.get().isDebugLogEnabled()) {
        Galacticraft.logger.warn("Pool referencer: {}", piece.toString());
    }
}
 
源代码20 项目: the-hallow   文件: TinyPumpkinBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPosition, EntityContext entityContext) {
	return Y_SHAPE;
}
 
源代码21 项目: the-hallow   文件: RestlessCactusBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
	return COLLISION_SHAPE;
}
 
源代码22 项目: the-hallow   文件: RestlessCactusBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
	return OUTLINE_SHAPE;
}
 
源代码23 项目: the-hallow   文件: PumpkinPieBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView blockView, BlockPos pos, EntityContext entityContext) {
	return SHAPE[state.get(BITES) - 1];
}
 
源代码24 项目: the-hallow   文件: InfusionPillarBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPosition, EntityContext entityContext) {
	return SHAPE;
}
 
源代码25 项目: the-hallow   文件: HallowedTreasureChestBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
	return SHAPE;
}
 
源代码26 项目: the-hallow   文件: HallowedTreasureChestBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getCollisionShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
	return SHAPE;
}
 
源代码27 项目: the-hallow   文件: WitchWaterBubbleColumnBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
	return VoxelShapes.empty();
}
 
源代码28 项目: the-hallow   文件: BreadCrumbsBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView blockView, BlockPos pos, EntityContext context) {
	return SHAPE;
}
 
源代码29 项目: the-hallow   文件: InfusionAltarBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPosition, EntityContext entityContext) {
	return SHAPE;
}
 
源代码30 项目: the-hallow   文件: TombstoneBlock.java
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView blockView, BlockPos pos, EntityContext context) {
	return SHAPES.get(state.get(FACING));
}
 
 类所在包
 同包方法