use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class BlockPneumaticDoor method rotateBlock.
@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection face) {
int meta = world.getBlockMetadata(x, y, z);
if (meta < 6) {
super.rotateBlock(world, player, x, y, z, face);
world.setBlockMetadataWithNotify(x, y + 1, z, world.getBlockMetadata(x, y, z) + 6, 3);
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPneumaticDoor) {
((TileEntityPneumaticDoor) te).rightGoing = true;
((TileEntityPneumaticDoor) te).setRotation(0);
TileEntity topDoor = world.getTileEntity(x, y + 1, z);
if (topDoor instanceof TileEntityPneumaticDoor) {
((TileEntityPneumaticDoor) topDoor).sendDescriptionPacket();
}
}
} else {
return rotateBlock(world, player, x, y - 1, z, face);
}
return true;
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class BlockPneumaticDoor method setBlockBoundsBasedOnState.
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
if (isTrackingPlayerEye) {
setBlockBounds(0, 0, 0, 1, 1, 1);
} else {
float xMin = 0;
float zMin = 0;
float xMax = 1;
float zMax = 1;
TileEntity te = blockAccess.getTileEntity(x, y, z);
int meta = blockAccess.getBlockMetadata(x, y, z);
if (te instanceof TileEntityPneumaticDoor) {
TileEntityPneumaticDoor door = (TileEntityPneumaticDoor) te;
float cosinus = 13 / 16F - (float) Math.sin(Math.toRadians(door.rotation)) * 13 / 16F;
float sinus = 13 / 16F - (float) Math.cos(Math.toRadians(door.rotation)) * 13 / 16F;
if (door.rightGoing) {
switch(ForgeDirection.getOrientation(meta % 6)) {
case NORTH:
zMin = cosinus;
xMax = 1 - sinus;
break;
case WEST:
xMin = cosinus;
zMin = sinus;
break;
case SOUTH:
zMax = 1 - cosinus;
xMin = sinus;
break;
case EAST:
xMax = 1 - cosinus;
zMax = 1 - sinus;
break;
}
} else {
switch(ForgeDirection.getOrientation(meta % 6)) {
case NORTH:
zMin = cosinus;
xMin = sinus;
break;
case WEST:
xMin = cosinus;
zMax = 1 - sinus;
break;
case SOUTH:
zMax = 1 - cosinus;
xMax = 1 - sinus;
break;
case EAST:
xMax = 1 - cosinus;
zMin = sinus;
break;
}
}
}
setBlockBounds(xMin, meta < 6 ? 0 : -1, zMin, xMax, meta < 6 ? 2 : 1, zMax);
}
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class DroneAIExternalProgram method isValidPosition.
@Override
protected boolean isValidPosition(ChunkPosition pos) {
if (traversedPositions.add(pos)) {
curSlot = 0;
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
return te instanceof IInventory;
}
return false;
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class DroneAILiquidImport method emptyTank.
private boolean emptyTank(ChunkPosition pos, boolean simulate) {
if (drone.getTank().getFluidAmount() == drone.getTank().getCapacity()) {
drone.addDebugEntry("gui.progWidget.liquidImport.debug.fullDroneTank");
abort();
return false;
} else {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (te instanceof IFluidHandler) {
IFluidHandler tank = (IFluidHandler) te;
for (int i = 0; i < 6; i++) {
if (((ISidedWidget) widget).getSides()[i]) {
FluidStack importedFluid = tank.drain(ForgeDirection.getOrientation(i), Integer.MAX_VALUE, false);
if (importedFluid != null && ((ILiquidFiltered) widget).isFluidValid(importedFluid.getFluid())) {
int filledAmount = drone.getTank().fill(importedFluid, false);
if (filledAmount > 0) {
if (((ICountWidget) widget).useCount())
filledAmount = Math.min(filledAmount, getRemainingCount());
if (!simulate) {
decreaseCount(drone.getTank().fill(tank.drain(ForgeDirection.getOrientation(i), filledAmount, true), true));
}
return true;
}
}
}
}
drone.addDebugEntry("gui.progWidget.liquidImport.debug.emptiedToMax", pos);
} else if (!((ICountWidget) widget).useCount() || getRemainingCount() >= 1000) {
Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.getWorld().getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ));
if (fluid != null && ((ILiquidFiltered) widget).isFluidValid(fluid) && drone.getTank().fill(new FluidStack(fluid, 1000), false) == 1000 && FluidUtils.isSourceBlock(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
if (!simulate) {
decreaseCount(1000);
drone.getTank().fill(new FluidStack(fluid, 1000), true);
drone.getWorld().setBlockToAir(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
}
return true;
}
}
return false;
}
}
use of net.minecraft.tileentity.TileEntity in project PneumaticCraft by MineMaarten.
the class HackableMobSpawner method onHackFinished.
@Override
public void onHackFinished(World world, int x, int y, int z, EntityPlayer player) {
if (!world.isRemote) {
NBTTagCompound tag = new NBTTagCompound();
TileEntity te = world.getTileEntity(x, y, z);
te.writeToNBT(tag);
tag.setShort("RequiredPlayerRange", (short) 0);
te.readFromNBT(tag);
world.markBlockForUpdate(x, y, z);
}
}
Aggregations