当前位置: 首页>>代码示例>>Java>>正文


Java RayTracer类代码示例

本文整理汇总了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;
}
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:18,代码来源:BlockCraftingGrid.java

示例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;
}
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:26,代码来源:BlockTranslocator.java

示例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);
}
 
开发者ID:TheCBProject,项目名称:EnderStorage,代码行数:9,代码来源:BlockEnderStorage.java

示例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);
}
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:12,代码来源:BlockTranslocator.java

示例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);
}
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:10,代码来源:BlockTranslocator.java

示例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;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:29,代码来源:PartSidedPipe.java

示例7: traceBlock

import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public static BlockPos traceBlock(EntityPlayerMP player, float reach) {
    return RayTracer.retrace(player, reach).getBlockPos();
}
 
开发者ID:TheCBProject,项目名称:CodeChickenCore,代码行数:4,代码来源:PlayerCommand.java

示例8: traceEntity

import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public static Entity traceEntity(EntityPlayerMP player, float reach) {
    return RayTracer.retrace(player, reach).entityHit;
}
 
开发者ID:TheCBProject,项目名称:CodeChickenCore,代码行数:4,代码来源:PlayerCommand.java

示例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);
}
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:7,代码来源:BlockCraftingGrid.java

示例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();
		}
	}
 
开发者ID:brandon3055,项目名称:Town-Builder,代码行数:60,代码来源:CommandBlock.java

示例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;
}
 
开发者ID:delta534,项目名称:Chisel,代码行数:55,代码来源:ChiselEventHandler.java

示例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;
}
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:53,代码来源:FMPPlacementListener.java

示例13: rayTrace

import codechicken.lib.raytracer.RayTracer; //导入依赖的package包/类
public MovingObjectPosition rayTrace(EntityPlayer player) {

		return rayTrace(RayTracer.getStartVec(player), RayTracer.getEndVec(player));
	}
 
开发者ID:modmuss50,项目名称:Network,代码行数:5,代码来源:TileEntityRobot.java


注:本文中的codechicken.lib.raytracer.RayTracer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。