@Override public void updateEntity() { super.updateEntity(); if (!this.worldObj.isRemote) { if (this.storedOxygen > 0 && this.getEnergyStoredGC() > 0) { if (!this.worldObj.isRemote) { if (this.containingItems[0] != null) { ItemStack tank0 = this.containingItems[0]; if (tank0.getItem() instanceof ItemOxygenTank && tank0.getItemDamage() > 0) { tank0.setItemDamage( tank0.getItemDamage() - TileEntityOxygenCompressor.TANK_TRANSFER_SPEED); this.storedOxygen -= TileEntityOxygenCompressor.TANK_TRANSFER_SPEED; } } } } } }
@Override public void updateEntity() { super.updateEntity(); if (!this.worldObj.isRemote) { this.produceOxygen(); // if (this.getEnergyStored() > 0) // { // int gasToSend = Math.min(this.storedOxygen, // GCCoreTileEntityOxygenCollector.OUTPUT_PER_TICK); // GasStack toSend = new GasStack(GalacticraftCore.gasOxygen, // gasToSend); // this.storedOxygen -= GasTransmission.emitGasToNetwork(toSend, // this, this.getOxygenOutputDirection()); // // Vector3 thisVec = new Vector3(this); // TileEntity tileEntity = // thisVec.modifyPositionFromSide(this.getOxygenOutputDirection()).getTileEntity(this.worldObj); // // if (tileEntity instanceof IGasAcceptor) // { // if (((IGasAcceptor) // tileEntity).canReceiveGas(this.getOxygenOutputDirection().getOpposite(), // GalacticraftCore.gasOxygen)) // { // double sendingGas = 0; // // if (this.storedOxygen >= // GCCoreTileEntityOxygenCollector.OUTPUT_PER_TICK) // { // sendingGas = GCCoreTileEntityOxygenCollector.OUTPUT_PER_TICK; // } // else // { // sendingGas = this.storedOxygen; // } // // this.storedOxygen -= sendingGas - ((IGasAcceptor) // tileEntity).receiveGas(new GasStack(GalacticraftCore.gasOxygen, // (int) Math.floor(sendingGas))); // } // } // } // The later calculations are more efficient if power is a float, so // there are fewer casts float power = 0; if (this.getEnergyStoredGC() > 0) { if (this.worldObj.provider instanceof IGalacticraftWorldProvider) { // Pre-test to see if close to the map edges, so code // doesn't have to continually test for map edges inside the // loop if (this.xCoord > -29999995 && this.xCoord < 2999995 && this.zCoord > -29999995 && this.zCoord < 29999995) { // Test the y coordinates, so code doesn't have to keep // testing that either int miny = this.yCoord - 5; int maxy = this.yCoord + 5; if (miny < 0) { miny = 0; } if (maxy >= this.worldObj.getHeight()) { maxy = this.worldObj.getHeight() - 1; } // Loop the x and the z first, so the y loop will be at // fixed (x,z) coordinates meaning fixed chunk // coordinates for (int x = this.xCoord - 5; x <= this.xCoord + 5; x++) { int chunkx = x >> 4; int intrachunkx = x & 15; // Preload the first chunk for the z loop - there // can be a maximum of 2 chunks in the z loop int chunkz = (this.zCoord - 5) >> 4; Chunk chunk = this.worldObj.getChunkFromChunkCoords(chunkx, chunkz); for (int z = this.zCoord - 5; z <= this.zCoord + 5; z++) { if ((z >> 4) != chunkz) { // moved across z chunk boundary into a new // chunk, so load the new chunk chunkz = z >> 4; chunk = this.worldObj.getChunkFromChunkCoords(chunkx, chunkz); } for (int y = miny; y <= maxy; y++) { // chunk.getBlockID is like world.getBlock // but faster - needs to be given // intra-chunk coordinates though final Block block = chunk.getBlock(intrachunkx, y, z & 15); // Test for the two most common blocks (air // and breatheable air) without looking up // in the blocksList if (block != Blocks.air && block != GCBlocks.breatheableAir) { if (block.isLeaves(this.worldObj, x, y, z) || block instanceof IPlantable && ((IPlantable) block).getPlantType(this.worldObj, x, y, z) == EnumPlantType.Crop) { power += 0.075F; } } } } } } } else { power = 9.3F; } power = (float) Math.floor(power); this.lastOxygenCollected = power; this.storedOxygen = (int) Math.max(Math.min(this.storedOxygen + power, this.maxOxygen), 0); } else { this.lastOxygenCollected = 0; } } }