本文整理汇总了Java中codechicken.lib.raytracer.RayTracer类的典型用法代码示例。如果您正苦于以下问题:Java RayTracer类的具体用法?Java RayTracer怎么用?Java RayTracer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RayTracer类属于codechicken.lib.raytracer包,在下文中一共展示了RayTracer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return true;
}
RayTraceResult hit = RayTracer.retraceBlock(world, player, pos);
TileCraftingGrid tcraft = (TileCraftingGrid) world.getTileEntity(pos);
if (hit != null) {
if (hit.subHit > 0) {
tcraft.activate(hit.subHit - 1, player);
}
return true;
}
return false;
}
示例2: onBlockActivated
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return true;
}
RayTraceResult hit = RayTracer.retraceBlock(world, player, pos);
TileTranslocator ttrans = (TileTranslocator) world.getTileEntity(pos);
if (hit != null && ttrans != null) {
if (hit.subHit < 6) {
Vector3 vhit = new Vector3(hit.hitVec);
vhit.add(-pos.getX() - 0.5, -pos.getY() - 0.5, -pos.getZ() - 0.5);
vhit.apply(Rotation.sideRotations[hit.subHit % 6].inverse());
if (MathHelper.between(-2 / 16D, vhit.x, 2 / 16D) && MathHelper.between(-2 / 16D, vhit.z, 2 / 16D)) {
hit.subHit += 6;
}
}
return ttrans.attachments[hit.subHit % 6].activate(player, hit.subHit / 6);
}
return false;
}
示例3: collisionRayTrace
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos pos, Vec3d start, Vec3d end) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null && tile instanceof TileFrequencyOwner) {
return RayTracer.rayTraceCuboidsClosest(start, end, pos, ((TileFrequencyOwner) tile).getIndexedCuboids());
}
return super.collisionRayTrace(state, world, pos, start, end);
}
示例4: removedByPlayer
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
RayTraceResult hit = RayTracer.retraceBlock(world, player, pos);
if (hit == null) {
return false;
}
TileTranslocator ttrans = (TileTranslocator) world.getTileEntity(pos);
return ttrans.harvestPart(hit.subHit % 6, !player.capabilities.isCreativeMode);
}
示例5: collisionRayTrace
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World world, BlockPos pos, Vec3d start, Vec3d end) {
ICuboidProvider provider = (ICuboidProvider) world.getTileEntity(pos);
if (provider != null) {
return RayTracer.rayTraceCuboidsClosest(start, end, pos, provider.getIndexedCuboids());
}
return super.collisionRayTrace(blockState, world, pos, start, end);
}
示例6: onSneakRightClick
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
if(!world().isRemote)
{
ExtendedMOP hit = (ExtendedMOP)RayTracer.retraceBlock(world(), player, x(), y(), z());
if(hit == null)
{
return false;
}
else if(hit.subHit < 6)
{
connectionTypes[hit.subHit] = connectionTypes[hit.subHit].next();
sendDesc = true;
onModeChange(ForgeDirection.getOrientation(hit.subHit));
player.addChatMessage(new ChatComponentText("Connection type changed to " + connectionTypes[hit.subHit].toString()));
return true;
}
else {
return onConfigure(player, hit.subHit, side);
}
}
return true;
}
示例7: traceBlock
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public static BlockPos traceBlock(EntityPlayerMP player, float reach) {
return RayTracer.retrace(player, reach).getBlockPos();
}
示例8: traceEntity
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public static Entity traceEntity(EntityPlayerMP player, float reach) {
return RayTracer.retrace(player, reach).entityHit;
}
示例9: collisionRayTrace
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
ICuboidProvider provider = (ICuboidProvider) worldIn.getTileEntity(pos);
List<IndexedCuboid6> cuboids = provider.getIndexedCuboids();
return RayTracer.rayTraceCuboidsClosest(start, end, pos, cuboids);
}
示例10: handleCommand
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
@Override
public void handleCommand(EntityPlayer player, String[] args)
{
if (args.length < 2 || args.length > 4)
{
player.addChatMessage(new TextComponentString("/tt-schematic block <function> [Used to interact with the structure builder block you are looking at]"));
return;
}else
{
RayTraceResult mop = RayTracer.retrace(player, 50);
if (mop == null || mop.typeOfHit != RayTraceResult.Type.BLOCK || player.worldObj.getBlockState(mop.getBlockPos()).getBlock() != TBFeatures.structureBuilder)
{
player.addChatMessage(new TextComponentString("Did not find Structure Builder! [you must be looking at a structure builder block to use this command]"));
return;
}
TileStructureBuilder tile = player.worldObj.getTileEntity(mop.getBlockPos()) instanceof TileStructureBuilder ? (TileStructureBuilder) player.worldObj.getTileEntity(mop.getBlockPos()) : null;
if (tile == null)
{
player.addChatMessage(new TextComponentString("[ERROR 404] Block tile entity not found"));
return;
}
if (args[1].equals("set"))
{
if (args.length != 3)
{
player.addChatMessage(new TextComponentString("/tt-schematic block set <schematic name>"));
return;
}
if ( SchematicHandler.getFile(args[2]) == null)
{
player.addChatMessage(new TextComponentString(args[2] + " Dose not exist"));
return;
}
NBTTagCompound compound = null;
try
{
compound = SchematicHandler.loadCompoundFromFile(args[2]);
}
catch (SchematicHandler.SchematicException e)
{
e.printStackTrace();
}
tile.schematic.value = args[2];
tile.xSize.value = compound.getShort("Width");
tile.ySize.value = compound.getShort("Height");
tile.zSize.value = compound.getShort("Length");
player.addChatMessage(new TextComponentString(args[2] + " Bound to block"));
// player.worldObj.markBlockForUpdate(mop.blockX, mop.blockY, mop.blockZ);
}
else if (args[1].equals("toggleview"))
{
tile.showPosition.value = !tile.showPosition.value;
// player.worldObj.markBlockForUpdate(mop.blockX, mop.blockY, mop.blockZ);
}
tile.updateBlock();
}
}
示例11: place
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public static boolean place(EntityPlayer player, World world) {
MovingObjectPosition hit = RayTracer.reTrace(world, player);
if (hit == null)
return false;
BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ).offset(hit.sideHit);
ItemStack held = player.getHeldItem();
McBlockPart part = null;
if (held == null)
return false;
if (held.func_150998_b() == Chisel.blockCarpetFloor.blockID)
part = MultiPartCarpetTest.placement(world, pos, hit.sideHit, held.getItemDamage());
if (part == null)
return false;
if (world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff
{
Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ);
Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
if (block != null && !ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float) f.x, (float) f.y, (float) f.z)) {
player.swingItem();
PacketCustom.sendToServer(new Packet15Place(
hit.blockX, hit.blockY, hit.blockZ, hit.sideHit,
player.inventory.getCurrentItem(),
(float) f.x, (float) f.y, (float) f.z));
return false;
}
}
TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
if (tile == null || !tile.canAddPart(part))
return false;
if (!world.isRemote) {
TileMultipart.addPart(world, pos, part);
world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5,
part.getBlock().stepSound.getBreakSound(),
(part.getBlock().stepSound.getVolume() + 1.0F) / 2.0F,
part.getBlock().stepSound.getPitch() * 0.8F);
if (!player.capabilities.isCreativeMode) {
held.stackSize--;
if (held.stackSize == 0) {
player.inventory.mainInventory[player.inventory.currentItem] = null;
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
}
}
} else {
player.swingItem();
TinyChiselPacketHandler.signalServer();
}
return true;
}
示例12: place
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public static boolean place(EntityPlayer player, World world){
MovingObjectPosition hit = RayTracer.reTrace(world, player);
if(hit == null) return false;
BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ);
ItemStack held = player.getHeldItem();
PartPressureTube part = null;
if(held == null) return false;
Block heldBlock = Block.getBlockFromItem(held.getItem());
if(heldBlock == Blockss.pressureTube) {
part = new PartPressureTube();
} else if(heldBlock == Blockss.advancedPressureTube) {
part = new PartAdvancedPressureTube();
}
if(part == null) return false;
if(world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff
{
Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ);
Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
if(!ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float)f.x, (float)f.y, (float)f.z)) {
player.swingItem();
PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement(hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float)f.x, (float)f.y, (float)f.z));
return true;
}
}
TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
if(tile == null || !tile.canAddPart(part)) {
pos = pos.offset(hit.sideHit);
tile = TileMultipart.getOrConvertTile(world, pos);
if(tile == null || !tile.canAddPart(part)) return false;
}
if(!world.isRemote) {
TileMultipart.addPart(world, pos, part);
world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, Blockss.pressureTube.stepSound.func_150496_b(), (Blockss.pressureTube.stepSound.getVolume() + 1.0F) / 2.0F, Blockss.pressureTube.stepSound.getPitch() * 0.8F);
if(!player.capabilities.isCreativeMode) {
held.stackSize--;
if(held.stackSize == 0) {
player.inventory.mainInventory[player.inventory.currentItem] = null;
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
}
}
} else {
player.swingItem();
NetworkHandler.sendToServer(new PacketFMPPlacePart());
}
return true;
}
示例13: rayTrace
import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public MovingObjectPosition rayTrace(EntityPlayer player) {
return rayTrace(RayTracer.getStartVec(player), RayTracer.getEndVec(player));
}