本文整理汇总了Java中net.minecraft.block.state.IBlockState.collisionRayTrace方法的典型用法代码示例。如果您正苦于以下问题:Java IBlockState.collisionRayTrace方法的具体用法?Java IBlockState.collisionRayTrace怎么用?Java IBlockState.collisionRayTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.state.IBlockState
的用法示例。
在下文中一共展示了IBlockState.collisionRayTrace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLookedModule
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public static TubeModule getLookedModule(World world, BlockPos pos, EntityPlayer player) {
Pair<Vec3d, Vec3d> vecs = PneumaticCraftUtils.getStartAndEndLookVec(player);
IBlockState state = world.getBlockState(pos);
RayTraceResult rayTraceResult = state.collisionRayTrace(world, pos, vecs.getLeft(), vecs.getRight());
TubeHitInfo tubeHitInfo = getHitInfo(rayTraceResult);
if (tubeHitInfo.type == TubeHitInfo.PartType.MODULE) {
TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(getTE(world, pos));
return tube.modules[tubeHitInfo.dir.ordinal()];
}
return null;
}
示例2: getLookedTube
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
* Get the part of the tube being looked at.
*
* @param world the world
* @param pos the blockpos
* @param player the player
* @return (true, side) if it's the side of the tube core, or (false, side) if it's a tube arm
*/
private static Pair<Boolean,EnumFacing> getLookedTube(World world, BlockPos pos, EntityPlayer player) {
Pair<Vec3d, Vec3d> vecs = PneumaticCraftUtils.getStartAndEndLookVec(player);
IBlockState state = world.getBlockState(pos);
RayTraceResult rayTraceResult = state.collisionRayTrace(world, pos, vecs.getLeft(), vecs.getRight());
TubeHitInfo tubeHitInfo = getHitInfo(rayTraceResult);
if (tubeHitInfo.type == TubeHitInfo.PartType.TUBE) {
// return either the tube arm (if connected), or the side of the centre face (if not)
return tubeHitInfo.dir == null ? Pair.of(true, rayTraceResult.sideHit) : Pair.of(false, tubeHitInfo.dir);
}
return null;
}