use of pneumaticCraft.common.tileentity.TileEntityChargingStation in project PneumaticCraft by MineMaarten.
the class BlockChargingStation method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (!world.isRemote && player.isSneaking()) {
TileEntityChargingStation station = (TileEntityChargingStation) world.getTileEntity(x, y, z);
station.setCamoStack(player.getCurrentEquippedItem());
return player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemBlock;
} else
return super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}
use of pneumaticCraft.common.tileentity.TileEntityChargingStation in project PneumaticCraft by MineMaarten.
the class RenderChargingStationPad method renderWorldBlock.
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityChargingStation) {
TileEntityChargingStation station = (TileEntityChargingStation) te;
if (station.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) {
ItemStack camo = station.getCamoStack();
Block camoBlock = ((ItemBlock) camo.getItem()).field_150939_a;
renderer.renderAllFaces = true;
renderer.setOverrideBlockTexture(camoBlock.getIcon(0, camo.getItemDamage()));
renderer.setRenderBounds(0, 15 / 16D, 0, 1, 1, 1);
renderer.renderStandardBlock(block, x, y, z);
renderer.setOverrideBlockTexture(null);
renderer.renderAllFaces = false;
return true;
}
}
return false;
}
use of pneumaticCraft.common.tileentity.TileEntityChargingStation in project PneumaticCraft by MineMaarten.
the class ModelChargingStation method renderStatic.
@Override
public void renderStatic(float size, TileEntity te) {
renderModel(size);
if (te instanceof TileEntityChargingStation) {
TileEntityChargingStation tile = (TileEntityChargingStation) te;
if (tile.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) {
RenderManager.instance.renderEngine.bindTexture(Textures.MODEL_CHARGING_STATION_PAD);
chargePad.renderModel(size);
}
if (tile.getStackInSlot(TileEntityChargingStation.CHARGE_INVENTORY_INDEX) != null) {
float scaleFactor = 0.7F;
EntityItem ghostEntityItem = new EntityItem(tile.getWorldObj());
ghostEntityItem.hoverStart = 0.0F;
ghostEntityItem.setEntityItemStack(tile.getStackInSlot(TileEntityChargingStation.CHARGE_INVENTORY_INDEX));
GL11.glTranslated(0, 1, 0);
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
GL11.glScalef(1.0F, -1F, -1F);
boolean fancySetting = RenderManager.instance.options.fancyGraphics;
RenderManager.instance.options.fancyGraphics = true;
customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
RenderManager.instance.options.fancyGraphics = fancySetting;
}
}
}
use of pneumaticCraft.common.tileentity.TileEntityChargingStation in project PneumaticCraft by MineMaarten.
the class DroneGoToChargingStation method shouldExecute.
/**
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute() {
List<TileEntityChargingStation> validChargingStations = new ArrayList<TileEntityChargingStation>();
if (drone.getPressure(null) < PneumaticValues.DRONE_LOW_PRESSURE) {
for (TileEntity te : (List<TileEntity>) drone.worldObj.loadedTileEntityList) {
if (te instanceof TileEntityChargingStation) {
TileEntityChargingStation station = (TileEntityChargingStation) te;
ChunkPosition pos = new ChunkPosition(station.xCoord, station.yCoord, station.zCoord);
if (DroneClaimManager.getInstance(drone.worldObj).isClaimed(pos)) {
drone.addDebugEntry("gui.progWidget.chargingStation.debug.claimed", pos);
} else if (station.getPressure(ForgeDirection.UNKNOWN) <= PneumaticValues.DRONE_LOW_PRESSURE) {
drone.addDebugEntry("gui.progWidget.chargingStation.debug.notEnoughPressure", pos);
} else if (station.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) == 0) {
drone.addDebugEntry("gui.progWidget.chargingStation.debug.noDispenserUpgrades", pos);
} else {
validChargingStations.add(station);
}
}
}
}
Collections.sort(validChargingStations, new Comparator() {
@Override
public int compare(Object arg1, Object arg2) {
TileEntity te1 = (TileEntity) arg1;
TileEntity te2 = (TileEntity) arg2;
return Double.compare(PneumaticCraftUtils.distBetween(te1.xCoord, te1.yCoord, te1.zCoord, drone.posX, drone.posY, drone.posZ), PneumaticCraftUtils.distBetween(te2.xCoord, te2.yCoord, te2.zCoord, drone.posX, drone.posY, drone.posZ));
}
});
for (TileEntityChargingStation station : validChargingStations) {
boolean protect = PneumaticCraftUtils.getProtectingSecurityStations(drone.worldObj, station.xCoord, station.yCoord, station.zCoord, drone.getFakePlayer(), false, false) > 0;
ChunkPosition pos = new ChunkPosition(station.xCoord, station.yCoord, station.zCoord);
if (protect) {
drone.addDebugEntry("gui.progWidget.chargingStation.debug.protected", pos);
} else if (drone.getPathNavigator().moveToXYZ(station.xCoord, station.yCoord + 1.5, station.zCoord) || drone.getPathNavigator().isGoingToTeleport()) {
isExecuting = true;
curCharger = station;
DroneClaimManager.getInstance(drone.worldObj).claim(pos);
return true;
} else {
drone.addDebugEntry("gui.progWidget.chargingStation.debug.cantNavigate", pos);
}
}
isExecuting = false;
return false;
}
Aggregations