/** Returns a list of all Tile Entities matching the class given within the bounding box */ public static <T extends TileEntity> List<T> getTileEntitiesWithinAABB( World world, Class<T> clazz, AxisAlignedBB aabb) { List<T> list = new ArrayList<T>(); int minX = MathHelper.floor_double(aabb.minX - World.MAX_ENTITY_RADIUS); int maxX = MathHelper.floor_double(aabb.maxX + World.MAX_ENTITY_RADIUS); int minY = MathHelper.floor_double(aabb.minY - World.MAX_ENTITY_RADIUS); int maxY = MathHelper.floor_double(aabb.maxY + World.MAX_ENTITY_RADIUS); int minZ = MathHelper.floor_double(aabb.minZ - World.MAX_ENTITY_RADIUS); int maxZ = MathHelper.floor_double(aabb.maxZ + World.MAX_ENTITY_RADIUS); if (!world.checkChunksExist(minX, minY, minZ, maxX, maxY, maxZ)) { return list; } for (int i = minX; i <= maxX; ++i) { for (int j = minY; j <= maxY; ++j) { for (int k = minZ; k <= maxZ; ++k) { TileEntity te = world.getTileEntity(i, j, k); if (te != null && clazz.isAssignableFrom(te.getClass())) { list.add((T) te); } } } } return list; }
public static BasicEggBlock addEggBlock( String name, TileEntity entity, BasicBlockRenderer renderer) { BasicEggBlock b = new BasicEggBlock(name, entity); GameRegistry.registerTileEntity(entity.getClass(), "tileentity_" + name); tileEntityList.add(entity); specialRenderList.add(renderer); return b; }
public boolean checkTileEntity(TileEntity te) { for (Iterator<SegmentTileEntity> it = segmentsTiles.iterator(); it.hasNext(); ) { SegmentTileEntity segment = it.next(); if (segment.getCheckClass().isAssignableFrom(te.getClass())) { try { if (segment.checkCondition(te)) { Volume teBox = new Volume( segment.getX1(te), segment.getY1(te), segment.getZ1(te), segment.getX2(te), segment.getY2(te), segment.getZ2(te)); int dim = te.getWorldObj().provider.dimensionId; Resident owner = segment.hasOwner() ? Protections.instance.getOwnerForTileEntity(te) : null; if (!hasPermission(owner, segment, dim, teBox)) { return true; } } } catch (Exception ex) { MyTown.instance.LOG.error( "Failed to check tile entity: {} ({}, {}, {}, Dim: {})", te.getClass().getSimpleName(), te.xCoord, te.yCoord, te.zCoord, te.getWorldObj().provider.dimensionId); MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex)); // Disabling protection if something errors. if (ex instanceof GetterException || ex instanceof ConditionException) { this.disableSegment(it, segment, ex.getMessage()); } else { MyTown.instance.LOG.error("Skipping..."); } } return false; } } return false; }
@Override public boolean worksWith(final World world, final int x, final int y, final int z) { final Class<?> filter = getTileEntityClass(); if (filter == null) { // This can happen if filter classes are deduced by reflection and // the class in question is not present. return false; } final TileEntity tileEntity = world.getTileEntity(x, y, z); return tileEntity != null && filter.isAssignableFrom(tileEntity.getClass()); }
/** * Attempts to register the TileEntity for this block. If the process fails, an error is printed * to the log via {@link LogHelper#printStackTrace(Exception)}. */ private void registerTileEntity() { try { TileEntity tile = this.createNewTileEntity(null, 0); if (tile != null) { Class<? extends TileEntity> tileClass = tile.getClass(); GameRegistry.registerTileEntity(tileClass, wrapName(getTileEntityName())); } } catch (Exception e) { LogHelper.printStackTrace(e); } }
@SuppressWarnings("unchecked") public <TE extends TileEntity> TE getTinkerTE(Class<TE> clazz) { for (Pair<BlockPos, IBlockState> pair : tinkerStationBlocks) { TileEntity te = this.world.getTileEntity(pair.getLeft()); if (te != null && clazz.isAssignableFrom(te.getClass())) { return (TE) te; } } return null; }
public TileEntityConnectable getConnected() { TileEntity te = worldObj.getTileEntity( xCoord + linkedDir.offsetX, yCoord + linkedDir.offsetY, zCoord + linkedDir.offsetZ); if (linkedDir != ForgeDirection.UNKNOWN && te instanceof TileEntityConnectable && te.getClass() == this.getClass()) { return (TileEntityConnectable) te; } return null; }
private void legacyConversion(int kind, NBTTagCompound nbttagcompound) { if (definitionMap == null) createDefinitionMap(); Block block = worldObj.getBlock(xCoord, yCoord, zCoord); if (!definitionMap.containsKey(block) || !definitionMap.get(block).containsKey(kind)) { commitSeppuku(block, kind); return; } MachineDefinition definition = definitionMap.get(block).get(kind); Proxies.log.info( "Converting obsolete gadget %s-%s to new '%s' %s-%s", block.getUnlocalizedName(), kind, definition.teIdent, definition.block.getUnlocalizedName(), definition.meta); Proxies.log.info("Removing old tile entity..."); worldObj.removeTileEntity(xCoord, yCoord, zCoord); worldObj.setBlockToAir(xCoord, yCoord, zCoord); Proxies.log.info("Setting to new block id..."); worldObj.setBlock( xCoord, yCoord, zCoord, definition.block, definition.meta, Defaults.FLAG_BLOCK_SYNCH); TileEntity tile = worldObj.getTileEntity(xCoord, yCoord, zCoord); if (tile == null) throw new RuntimeException("Failed to set new block tile entity!"); else if (tile.getClass() != definition.teClass) throw new RuntimeException( String.format( "Converted tile entity was '%s' instead of expected '%s'", tile.getClass(), definition.teClass)); Proxies.log.info("Refreshing converted tile entity %s with nbt data...", tile.getClass()); if (nbttagcompound.hasKey("Machine")) tile.readFromNBT( complementNBT(nbttagcompound, nbttagcompound.getCompoundTag("Machine"), definition)); else tile.readFromNBT(nbttagcompound); }
public static void check(TileEntity te) { for (SegmentTileEntity segment : segmentsTile.get(te.getClass())) { if (!segment.shouldExist(te)) { ItemStack itemStack = new ItemStack(te.getBlockType(), 1, te.getBlockMetadata()); NBTTagCompound nbt = new NBTTagCompound(); te.writeToNBT(nbt); itemStack.setTagCompound(nbt); WorldUtils.dropAsEntity(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, itemStack); te.getWorldObj().setBlock(te.xCoord, te.yCoord, te.zCoord, Blocks.air); te.invalidate(); MyTown.instance.LOG.info("TileEntity {} was ATOMICALLY DISINTEGRATED!", te.toString()); return; } } }
public ItemAdvancedBase(Block b) { super(b); TileEntity te = ((BlockContainerAdvanced) b).createNewTileEntity(null, 0); Class<?>[] interfaces = te.getClass().getInterfaces(); for (Class<?> curInterface : interfaces) { String intName = curInterface.getName(); tileInterfaces.add(intName.substring(intName.lastIndexOf('.') + 1, intName.length())); } setUnlocalizedName(b.getUnlocalizedName()); if (tileInterfaces.contains("IUpgradable")) { IUpgradable up = (IUpgradable) te; String name = String.format(StatCollector.translateToLocal(b.getUnlocalizedName() + ".name")); ItemBoost.upgradeable.add(name + ": " + up.getInfo()); } }
/** Gets the nearby tile entities of the specified tile entity and of the specified type */ public static List<TileEntity> getNearbyTileEntity( TileEntity te, Class<? extends TileEntity> type) { List<TileEntity> result = new ArrayList<TileEntity>(); int[] dx = {0, 1, 0, -1, 0, 0}; int[] dy = {1, 0, -1, 0, 0, 0}; int[] dz = {0, 0, 0, 0, 1, -1}; for (int i = 0; i < 6; i++) { TileEntity found = te.getWorldObj().getTileEntity(te.xCoord + dx[i], te.yCoord + dy[i], te.zCoord + dz[i]); if (found != null && type.isAssignableFrom(found.getClass())) { MyTown.instance.LOG.info("Found tile entity {} for class {}", found, type.getName()); result.add(found); } } return result; }
/** Checks if the block whitelist is still valid */ public static boolean isBlockWhitelistValid(BlockWhitelist bw) { // Delete if the town is gone if (MyTownUtils.getTownAtPosition(bw.getDim(), bw.getX() >> 4, bw.getZ() >> 4) == null) return false; if (bw.getFlagType() == FlagType.ACTIVATE && !checkActivatedBlocks( DimensionManager.getWorld(bw.getDim()).getBlock(bw.getX(), bw.getY(), bw.getZ()), DimensionManager.getWorld(bw.getDim()) .getBlockMetadata(bw.getX(), bw.getY(), bw.getZ()))) return false; if (bw.getFlagType() == FlagType.MODIFY || bw.getFlagType() == FlagType.ACTIVATE || bw.getFlagType() == FlagType.USAGE) { TileEntity te = DimensionManager.getWorld(bw.getDim()).getTileEntity(bw.getX(), bw.getY(), bw.getZ()); if (te == null) return false; return getFlagsForTile(te.getClass()).contains(bw.getFlagType()); } return true; }
public void writeToNetwork(ByteBuf out) { PacketBuffer buffer = new PacketBuffer(out); buffer.writeByte(this.sizeX); buffer.writeByte(this.sizeY); buffer.writeByte(this.sizeZ); buffer.writeShort(tileEntities.size()); for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { for (int z = 0; z < sizeZ; z++) { buffer.writeInt(Block.getIdFromBlock(this.blocks[x][y][z])); buffer.writeShort(this.metas[x][y][z]); } } } Iterator<TileEntity> tileIterator = tileEntities.iterator(); while (tileIterator.hasNext()) { TileEntity tile = tileIterator.next(); NBTTagCompound nbt = new NBTTagCompound(); try { tile.writeToNBT(nbt); try { buffer.writeNBTTagCompoundToBuffer(nbt); } catch (Exception e) { e.printStackTrace(); } } catch (RuntimeException e) { AdvancedRocketry.logger.warning( "A tile entity has thrown an error while writing to network: " + tile.getClass().getCanonicalName()); tileIterator.remove(); } } }
@Override public void update() { if (!worldObj.isRemote) { boolean a = active; if (active) active = false; for (EnumFacing fd : EnumFacing.VALUES) { TileEntity tileEntity = worldObj.getTileEntity(getPos().offset(fd)); int consumed = 0; if (tileEntity != null) if (tileEntity instanceof IExternalHeatable) consumed = ((IExternalHeatable) tileEntity) .doHeatTick( energyStorage.getEnergyStored(), worldObj.isBlockIndirectlyGettingPowered(getPos()) > 0); else { ExternalHeaterHandler.HeatableAdapter adapter = ExternalHeaterHandler.getHeatableAdapter(tileEntity.getClass()); if (adapter != null) consumed = adapter.doHeatTick( tileEntity, energyStorage.getEnergyStored(), worldObj.isBlockIndirectlyGettingPowered(getPos()) > 0); } if (consumed > 0) { this.energyStorage.extractEnergy(consumed, false); if (!active) active = true; } } if (active != a) { this.markDirty(); this.markContainingBlockForUpdate(null); worldObj.addBlockEvent(getPos(), this.getBlockType(), 1, active ? 1 : 0); } } }
@Override public boolean preventMovement( World world, int x, int y, int z, Block block, int meta, TileEntity tile) { return !(canMoveClass(block.getClass()) && (tile == null || canMoveClass(tile.getClass()))); }
// TODO: optimize the F*** out of this public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("xSize", sizeX); nbt.setInteger("ySize", sizeY); nbt.setInteger("zSize", sizeZ); Iterator<TileEntity> tileEntityIterator = tileEntities.iterator(); NBTTagList tileList = new NBTTagList(); while (tileEntityIterator.hasNext()) { TileEntity tile = tileEntityIterator.next(); try { NBTTagCompound tileNbt = new NBTTagCompound(); tile.writeToNBT(tileNbt); tileList.appendTag(tileNbt); } catch (RuntimeException e) { AdvancedRocketry.logger.warning( "A tile entity has thrown an error: " + tile.getClass().getCanonicalName()); blocks[tile.xCoord][tile.yCoord][tile.zCoord] = Blocks.air; metas[tile.xCoord][tile.yCoord][tile.zCoord] = 0; tileEntityIterator.remove(); } } int[] blockId = new int[sizeX * sizeY * sizeZ]; int[] metasId = new int[sizeX * sizeY * sizeZ]; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { for (int z = 0; z < sizeZ; z++) { blockId[z + (sizeZ * y) + (sizeZ * sizeY * x)] = Block.getIdFromBlock(blocks[x][y][z]); metasId[z + (sizeZ * y) + (sizeZ * sizeY * x)] = (int) metas[x][y][z]; } } } NBTTagIntArray idList = new NBTTagIntArray(blockId); NBTTagIntArray metaList = new NBTTagIntArray(metasId); nbt.setTag("idList", idList); nbt.setTag("metaList", metaList); nbt.setTag("tiles", tileList); /*for(int x = 0; x < sizeX; x++) { for(int y = 0; y < sizeY; y++) { for(int z = 0; z < sizeZ; z++) { idList.appendTag(new NBTTagInt(Block.getIdFromBlock(blocks[x][y][z]))); metaList.appendTag(new NBTTagInt(metas[x][y][z])); //NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("block", Block.getIdFromBlock(blocks[x][y][z])); tag.setShort("meta", metas[x][y][z]); NBTTagCompound tileNbtData = null; for(TileEntity tile : tileEntities) { NBTTagCompound tileNbt = new NBTTagCompound(); tile.writeToNBT(tileNbt); if(tileNbt.getInteger("x") == x && tileNbt.getInteger("y") == y && tileNbt.getInteger("z") == z){ tileNbtData = tileNbt; break; } } if(tileNbtData != null) tag.setTag("tile", tileNbtData); nbt.setTag(String.format("%d.%d.%d", x,y,z), tag); } } }*/ }
public void updateEntity() { // Check for ghost TEs if (dead) return; // Make sure the relays haven't been broken verifyRelay(); // Bounce if (linked && worldObj.getTotalWorldTime() % 100 == 0 && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { // Target coordinates to check int targetX = xCoord + movementDirection.offsetX; int targetZ = zCoord + movementDirection.offsetZ; // Switch direction if at end of track if (worldObj.getBlock(targetX, yCoord, targetZ) != Block.getBlockFromName("air") || worldObj.getBlock(targetX, yCoord + 1, targetZ) != Block.getBlockFromName("air")) { movementDirection = movementDirection.getOpposite(); } } // Move if (linked && worldObj.getTotalWorldTime() % 100 == 1 && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { // Cache coordinated int targetX = xCoord + movementDirection.offsetX; int targetZ = zCoord + movementDirection.offsetZ; // Check for abandoned TEs if (worldObj.getBlock(xCoord, yCoord, zCoord) != ThaumicTinkerer.registry.getFirstBlockFromClass(BlockMobilizer.class)) { return; } // Check if the space the mobilizer will move into is empty if ((worldObj.isAirBlock(targetX, yCoord, targetZ) || worldObj.getBlock(targetX, yCoord, targetZ).isAir(worldObj, targetX, yCoord, targetZ) && (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord) || worldObj.isAirBlock(targetX, yCoord + 1, targetZ) || worldObj .getBlock(targetX, yCoord + 1, targetZ) .isAir(worldObj, targetX, yCoord + 1, targetZ)))) { // Move Entities // List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, // AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+3, zCoord+1)); // System.out.print(entities); // for(Entity e: entities){ // e.setPosition(e.posX+movementDirection.offsetX, e.posY, // e.posZ+movementDirection.offsetZ); // } // Move the block on top of the mobilizer if (!worldObj.isRemote) { TileEntity passenger = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); IAppEngApi api = AEApi.instance(); // Prevent the passenger from popping off. Not sent to clients. worldObj.setBlock(targetX, yCoord, targetZ, Block.getBlockFromName("stone"), 0, 0); // Move non-TE blocks Block passengerId = worldObj.getBlock(xCoord, yCoord + 1, zCoord); if (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord) || passengerId.canPlaceBlockAt(worldObj, targetX, yCoord + 1, targetZ)) { if (passenger == null) { if (passengerId != Block.getBlockFromName("bedrock") && passengerId != Block.getBlockFromName("")) { worldObj.setBlock( targetX, yCoord + 1, targetZ, passengerId, worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord), 3); if (passengerId != Block.getBlockFromName("air") && passengerId != Block.getBlockFromName("piston_head")) { worldObj.setBlock( xCoord, yCoord + 1, zCoord, Block.getBlockFromName("air"), 0, 2); } } // If AE is installed, use its handler } else if (api != null) { if (api.registries().moveable().askToMove(passenger)) { worldObj.setBlock( targetX, yCoord + 1, targetZ, worldObj.getBlock(xCoord, yCoord + 1, zCoord), worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord), 3); passenger.invalidate(); worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); api.registries() .moveable() .getHandler(passenger) .moveTile(passenger, worldObj, targetX, yCoord + 1, targetZ); api.registries().moveable().doneMoving(passenger); passenger.validate(); } // Handler IMovableTiles and vanilla TEs without AE } else if (passenger instanceof IMovableTile || passenger.getClass().getName().startsWith("net.minecraft.tileentity")) { boolean imovable = passenger instanceof IMovableTile; if (imovable) ((IMovableTile) passenger).prepareToMove(); worldObj.setBlock( targetX, yCoord + 1, targetZ, worldObj.getBlock(xCoord, yCoord + 1, zCoord), worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord), 3); passenger.invalidate(); worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); // IMovableHandler default code Chunk c = worldObj.getChunkFromBlockCoords(targetX, targetZ); c.func_150812_a(targetX & 0xF, yCoord + 1, targetZ & 0xF, passenger); if (c.isChunkLoaded) { worldObj.addTileEntity(passenger); worldObj.markBlockForUpdate(targetX, yCoord + 1, targetZ); } if (imovable) ((IMovableTile) passenger).doneMoving(); passenger.validate(); } } // Move self this.invalidate(); worldObj.removeTileEntity(xCoord, yCoord, zCoord); worldObj.setBlock(xCoord, yCoord, zCoord, Block.getBlockFromName("air"), 0, 2); worldObj.setBlock( targetX, yCoord, targetZ, ThaumicTinkerer.registry.getFirstBlockFromClass(BlockMobilizer.class)); int oldX = xCoord; int oldZ = zCoord; this.xCoord = targetX; this.zCoord = targetZ; this.validate(); worldObj.addTileEntity(this); worldObj.removeTileEntity(oldX, yCoord, oldZ); worldObj.notifyBlockChange(oldX, yCoord, oldZ, Block.getBlockFromName("air")); } } } }
/** * Complete the energy transfer. Called internally on server tick end. * * @return Amount of energy SENT to all acceptors */ private float doProduce() { float sent = 0.0F; if (!this.availableAcceptors.isEmpty()) { float energyNeeded = this.totalRequested; float energyAvailable = this.totalEnergy; float reducor = 1.0F; float energyStorageReducor = 1.0F; if (energyNeeded > energyAvailable) { // If not enough energy, try reducing what goes into energy storage (if any) energyNeeded -= this.totalStorageExcess; // If there's still not enough, put the minimum into energy storage (if any) and, anyhow, // reduce everything proportionately if (energyNeeded > energyAvailable) { energyStorageReducor = 0F; reducor = energyAvailable / energyNeeded; } else { // Energyavailable exceeds the total needed but only if storage does not fill all in one // go - this is a common situation energyStorageReducor = (energyAvailable - energyNeeded) / this.totalStorageExcess; } } float currentSending; float sentToAcceptor; int tierProduced = Math.min(this.producersTierGC, this.networkTierGC); TileEntity debugTE = null; try { for (TileEntity tileEntity : this.availableAcceptors) { debugTE = tileEntity; // Exit the loop if there is no energy left at all (should normally not happen, should be // some even for the last acceptor) if (sent >= energyAvailable) { break; } // The base case is to give each acceptor what it is requesting currentSending = this.energyRequests.get(tileEntity); // If it's an energy store, we may need to damp it down if energyStorageReducor is less // than 1 if (currentSending > EnergyNetwork.ENERGY_STORAGE_LEVEL) { currentSending = EnergyNetwork.ENERGY_STORAGE_LEVEL + (currentSending - EnergyNetwork.ENERGY_STORAGE_LEVEL) * energyStorageReducor; } // Reduce everything proportionately if there is not enough energy for all needs currentSending *= reducor; if (currentSending > energyAvailable - sent) { currentSending = energyAvailable - sent; } ForgeDirection sideFrom = this.availableconnectedDirections.get(tileEntity); if (tileEntity instanceof IElectrical) { sentToAcceptor = ((IElectrical) tileEntity) .receiveElectricity(sideFrom, currentSending, tierProduced, true); } else if (isRF2Loaded && tileEntity instanceof IEnergyReceiver) { final int currentSendinginRF = (currentSending >= Integer.MAX_VALUE / EnergyConfigHandler.TO_RF_RATIO) ? Integer.MAX_VALUE : (int) (currentSending * EnergyConfigHandler.TO_RF_RATIO); sentToAcceptor = ((IEnergyReceiver) tileEntity).receiveEnergy(sideFrom, currentSendinginRF, false) / EnergyConfigHandler.TO_RF_RATIO; } else if (isMekLoaded && tileEntity instanceof IStrictEnergyAcceptor) { sentToAcceptor = (float) ((IStrictEnergyAcceptor) tileEntity) .transferEnergyToAcceptor( sideFrom, currentSending * EnergyConfigHandler.TO_MEKANISM_RATIO) / EnergyConfigHandler.TO_MEKANISM_RATIO; } else if (isRF1Loaded && tileEntity instanceof IEnergyHandler) { final int currentSendinginRF = (currentSending >= Integer.MAX_VALUE / EnergyConfigHandler.TO_RF_RATIO) ? Integer.MAX_VALUE : (int) (currentSending * EnergyConfigHandler.TO_RF_RATIO); sentToAcceptor = ((IEnergyHandler) tileEntity).receiveEnergy(sideFrom, currentSendinginRF, false) / EnergyConfigHandler.TO_RF_RATIO; } else if (isIC2Loaded && tileEntity instanceof IEnergySink) { double energySendingIC2 = currentSending * EnergyConfigHandler.TO_IC2_RATIO; if (energySendingIC2 >= 1D) { double result = 0; try { if (EnergyUtil.voltageParameterIC2) { result = (Double) EnergyUtil.injectEnergyIC2.invoke( tileEntity, sideFrom, energySendingIC2, 120D); } else { result = (Double) EnergyUtil.injectEnergyIC2.invoke(tileEntity, sideFrom, energySendingIC2); } } catch (Exception ex) { if (ConfigManagerCore.enableDebug) { ex.printStackTrace(); } } sentToAcceptor = currentSending - (float) result / EnergyConfigHandler.TO_IC2_RATIO; if (sentToAcceptor < 0F) { sentToAcceptor = 0F; } } else { sentToAcceptor = 0F; } } else if (isBCLoaded && EnergyConfigHandler.getBuildcraftVersion() == 6 && MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, sideFrom) != null) // New BC API { sentToAcceptor = (float) MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, sideFrom) .addEnergy(currentSending * EnergyConfigHandler.TO_BC_RATIO) / EnergyConfigHandler.TO_BC_RATIO; } else if (isBCLoaded && tileEntity instanceof IPowerReceptor) // Legacy BC API { PowerReceiver receiver = ((IPowerReceptor) tileEntity).getPowerReceiver(sideFrom); if (receiver != null) { double toSendBC = Math.min( currentSending * EnergyConfigHandler.TO_BC_RATIO, receiver.powerRequest()); sentToAcceptor = (float) receiver.receiveEnergy( buildcraft.api.power.PowerHandler.Type.PIPE, toSendBC, sideFrom) / EnergyConfigHandler.TO_BC_RATIO; } else { sentToAcceptor = 0F; } } else { sentToAcceptor = 0F; } if (sentToAcceptor / currentSending > 1.002F && sentToAcceptor > 0.01F) { if (!this.spamstop) { FMLLog.info( "Energy network: acceptor took too much energy, offered " + currentSending + ", took " + sentToAcceptor + ". " + tileEntity.toString()); this.spamstop = true; } sentToAcceptor = currentSending; } sent += sentToAcceptor; } } catch (Exception e) { GCLog.severe("DEBUG Energy network loop issue, please report this"); if (debugTE != null) GCLog.severe( "Problem was likely caused by tile in dim " + debugTE.getWorldObj().provider.dimensionId + " at " + debugTE.xCoord + "," + debugTE.yCoord + "," + debugTE.zCoord + " Type:" + debugTE.getClass().getSimpleName()); } } if (EnergyNetwork.tickCount % 200 == 0) { this.spamstop = false; } float returnvalue = sent; if (returnvalue > this.totalEnergy) { returnvalue = this.totalEnergy; } if (returnvalue < 0F) { returnvalue = 0F; } return returnvalue; }