use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericSubMultiBlock method getSelectedBoundingBoxFromPool.
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
return LogisticsPipes.LogisticsPipeBlock.getSelectedBoundingBoxFromPool(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord);
}
}
}
}
return super.getSelectedBoundingBoxFromPool(world, x, y, z).expand(-0.85F, -0.85F, -0.85F);
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericSubMultiBlock method getPickBlock.
@Override
@SuppressWarnings("deprecation")
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
return LogisticsPipes.LogisticsPipeBlock.getPickBlock(target, world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord);
}
}
}
if (!mainPipeList.isEmpty() && mainPipeList.get(0).pipe != null && mainPipeList.get(0).pipe.isMultiBlock()) {
return LogisticsPipes.LogisticsPipeBlock.getPickBlock(target, world, mainPipeList.get(0).xCoord, mainPipeList.get(0).yCoord, mainPipeList.get(0).zCoord);
}
}
return super.getPickBlock(target, world, x, y, z);
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericSubMultiBlock method getIcon.
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "all" })
public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) {
DoubleCoordinates pos = new DoubleCoordinates(i, j, k);
TileEntity tile = pos.getTileEntity(iblockaccess);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> mainPipe = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
if (!mainPipe.isEmpty() && mainPipe.get(0).pipe != null && mainPipe.get(0).pipe.isMultiBlock()) {
return LogisticsPipes.LogisticsPipeBlock.getIcon(iblockaccess, mainPipe.get(0).xCoord, mainPipe.get(0).yCoord, mainPipe.get(0).zCoord, l);
}
}
return null;
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericSubMultiBlock method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
boolean handled = false;
List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
DoubleCoordinates mainPipePos = mainPipe.pipe.getLPPosition();
mainPipePos.setBlockToAir(world);
handled = true;
}
}
}
if (!handled) {
mainPipeList.stream().filter(mainPipe -> mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()).forEach(mainPipe -> {
DoubleCoordinates mainPipePos = mainPipe.pipe.getLPPosition();
mainPipePos.setBlockToAir(world);
});
}
}
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericSubMultiBlock method addHitEffects.
@Override
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
TileEntity tile = pos.getTileEntity(worldObj);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(worldObj, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
CoreUnroutedPipe pipe = mainPipe.pipe;
if (pipe == null) {
return false;
}
IIcon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
int sideHit = target.sideHit;
Block block = LogisticsPipes.LogisticsPipeBlock;
float b = 0.1F;
double px = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (b * 2.0F)) + b + block.getBlockBoundsMinX();
double py = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F)) + b + block.getBlockBoundsMinY();
double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ();
if (sideHit == 0) {
py = y + block.getBlockBoundsMinY() - b;
}
if (sideHit == 1) {
py = y + block.getBlockBoundsMaxY() + b;
}
if (sideHit == 2) {
pz = z + block.getBlockBoundsMinZ() - b;
}
if (sideHit == 3) {
pz = z + block.getBlockBoundsMaxZ() + b;
}
if (sideHit == 4) {
px = x + block.getBlockBoundsMinX() - b;
}
if (sideHit == 5) {
px = x + block.getBlockBoundsMaxX() + b;
}
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z));
fx.setParticleIcon(icon);
effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
return true;
}
}
}
}
return super.addHitEffects(worldObj, target, effectRenderer);
}
Aggregations