use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class TileMulti method updateConnections.
public void updateConnections() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Pos pos = new Pos(this).add(dir);
Block b = pos.getBlock(getWorldObj());
if (connectedBlocks.containsKey(dir)) {
// TODO notify that a block has changed
if (connectedBlocks.get(dir) != b) {
connectedBlocks.remove(dir);
}
}
if (b != null && !b.isAir(getWorldObj(), xCoord, yCoord, zCoord)) {
connectedBlocks.put(dir, b);
}
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class SelectionHandler method updatePlayerRenderData.
public static void updatePlayerRenderData(EntityPlayerMP player) {
List<Cube> cubes = new ArrayList();
List<Cube> regions = new ArrayList();
Cube selection = getSelection(player);
for (Cube cube : selections.values()) {
if (cube != selection && cube.distance(new Pos(player)) <= 160) {
cubes.add(cube);
}
}
for (Region region : RegionManager.getControllerForWorld(player.worldObj).getRegionsNear(player, 160)) {
for (Cube cube : region.segments) {
if (cube.isCloseToAnyCorner(new Pos(player), 160)) {
regions.add(cube);
}
}
}
Engine.instance.packetHandler.sendToPlayer(new PacketSelectionData(selection, cubes, regions), player);
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class BlockRenderHandler method renderWorldBlock.
@Override
public boolean renderWorldBlock(IBlockAccess access, int x, int y, int z, Block block, int modelId, RenderBlocks renderBlocks) {
/**
* Try TileEntity rendering
*/
TileEntity tile = access.getTileEntity(x, y, z);
if (tile instanceof Tile) {
return ((Tile) tile).renderStatic(renderBlocks, new Pos(x, y, z), 0);
}
/**
* Try Block rendering
*/
if (block instanceof BlockTile) {
BlockTile dummy = (BlockTile) block;
tile = dummy.inject(access, x, y, z);
boolean b = ((Tile) tile).renderStatic(renderBlocks, new Pos(x, y, z), 0);
dummy.eject();
return b;
}
return false;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class FluidUtility method drainBlock.
/**
* Drains a block of fluid
*
* @param doDrain - do the action
* @param update - block update flag to use
* @return FluidStack drained from the block
*/
public static FluidStack drainBlock(World world, Pos position, boolean doDrain, int update) {
if (world == null || position == null) {
return null;
}
Block block = position.getBlock(world);
int meta = position.getBlockMetadata(world);
if (block != null) {
if (block instanceof IFluidBlock && ((IFluidBlock) block).canDrain(world, position.xi(), position.yi(), position.zi())) {
return ((IFluidBlock) block).drain(world, position.xi(), position.yi(), position.zi(), doDrain);
} else if ((block == Blocks.water || block == Blocks.flowing_water) && position.getBlockMetadata(world) == 0) {
if (doDrain) {
Pos vec = position.clone().add(ForgeDirection.UP);
if (vec.getBlock(world) == Blocks.water) {
vec.setBlock(world, Blocks.air, 0, update);
position.setBlock(world, block, meta);
} else {
position.setBlock(world, Blocks.air, 0, update);
}
}
return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME);
} else if ((block == Blocks.lava || block == Blocks.flowing_lava) && position.getBlockMetadata(world) == 0) {
if (doDrain) {
position.setBlock(world, Blocks.air, 0, update);
}
return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME);
}
}
return null;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class FluidUtility method fillBlock.
/**
* Helper method to fill a location with a fluid
* <p/>
* Note: This does not update the block to prevent the liquid from flowing
*
* @return
*/
public static int fillBlock(World world, Pos node, FluidStack stack, boolean doFill) {
if ((isFillableBlock(world, node) || isFillableFluid(world, node)) && stack != null && stack.amount >= FluidContainerRegistry.BUCKET_VOLUME) {
if (doFill) {
Block block = node.getBlock(world);
int meta = node.getBlockMetadata(world);
Pos vec = node.clone().add(ForgeDirection.UP);
if (block != null) {
if (block == Blocks.water && vec.getBlock(world).isAir(world, node.xi(), node.yi(), node.zi())) {
vec.setBlock(world, block, meta);
} else if (replacableBlocks.contains(block) && !nonBlockDropList.contains(block)) {
block.dropBlockAsItem(world, node.xi(), node.yi(), node.zi(), meta, 1);
block.breakBlock(world, node.xi(), node.yi(), node.zi(), block, meta);
}
}
node.setBlock(world, stack.getFluid().getBlock());
}
return FluidContainerRegistry.BUCKET_VOLUME;
}
return 0;
}
Aggregations