本文整理匯總了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;
}