mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
as straightforward as the nordring
This commit is contained in:
parent
9b0bd4d180
commit
01830fd877
10
changelog
10
changelog
@ -1,6 +1,14 @@
|
||||
## Changed
|
||||
* Changed bedrock ore processing time in the electrolyzer to 60 ticks
|
||||
* RF converters have been reworked
|
||||
* The conversion ratio from HE to RF is now 5:1 (instead of 1:4), HE is no longer way more powerful (in order to compensate for the much higher HE output starting with the first generators and becoming increasingly absurd with nuclear power)
|
||||
* Converters have an internal buffer again, effectively limiting throughput. The internal buffer is 1MRF and 5MHE.
|
||||
* The input energy buffer has a loss of 5% of its (unused) current level per tick, which means chaining up converters can not be abused to create earlygame super capacitors
|
||||
* The loss only takes effect once the input buffer can no longer empty into the output buffer, i.e. when energy demand is too low for the input
|
||||
* The buffer also fixes a bug where the HE to RF converter often behaves weirdly with certain mods, either outright destroying energy ot creating infinite energy
|
||||
* HE to RF converters now by default have the connection priority of LOW, only feeding into RF networks when all other energy consumers are sufficiently supplied. This can still be changed by using diodes
|
||||
|
||||
## Fixed
|
||||
* Fixed issue where the NEI universal handler can not correctly display more than 4 outputs (now supports up to 8, which should cover all possible electrolyzer cases too)
|
||||
* Fixed the metal electrolysis duration variable not being part of the config
|
||||
* Fixed the metal electrolysis duration variable not being part of the config
|
||||
* Removed the global energy transfer cap (only per-machine caps apply now), fixing issues where FENSUs in buffer mode would not charge past 10THE, and constantly void energy if above that threshold
|
||||
@ -123,7 +123,6 @@ public class PowerNetMK2 {
|
||||
if(receiverEntries.isEmpty()) return;
|
||||
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long transferCap = 100_000_000_000_000_00L;
|
||||
|
||||
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
|
||||
long powerAvailable = 0;
|
||||
@ -134,11 +133,9 @@ public class PowerNetMK2 {
|
||||
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
|
||||
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
|
||||
providers.add(new Pair(entry.getKey(), src));
|
||||
if(powerAvailable < transferCap) powerAvailable += src;
|
||||
powerAvailable += src;
|
||||
}
|
||||
|
||||
powerAvailable = Math.min(powerAvailable, transferCap);
|
||||
|
||||
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
|
||||
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
|
||||
long[] demand = new long[ConnectionPriority.values().length];
|
||||
|
||||
@ -307,6 +307,8 @@ public class ModBlocks {
|
||||
public static Block spotlight_halogen;
|
||||
public static Block spotlight_halogen_off;
|
||||
public static Block spotlight_beam;
|
||||
public static Block floodlight;
|
||||
public static Block floodlight_beam;
|
||||
|
||||
public static Block reinforced_stone;
|
||||
public static Block concrete_smooth;
|
||||
@ -590,7 +592,6 @@ public class ModBlocks {
|
||||
public static Block spikes;
|
||||
|
||||
public static Block charger;
|
||||
public static Block floodlight;
|
||||
|
||||
public static Block tesla;
|
||||
|
||||
@ -1492,6 +1493,7 @@ public class ModBlocks {
|
||||
spotlight_halogen_off = new Spotlight(Material.iron, 32, LightType.HALOGEN, false).setBlockName("spotlight_halogen_off").setBlockTextureName(RefStrings.MODID + ":flood_lamp_off");
|
||||
spotlight_beam = new SpotlightBeam().setBlockName("spotlight_beam");
|
||||
floodlight = new Floodlight(Material.iron).setBlockName("floodlight").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
floodlight_beam = new FloodlightBeam().setBlockName("floodlight_beam");
|
||||
|
||||
reinforced_stone = new BlockGeneric(Material.rock).setBlockName("reinforced_stone").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(100.0F).setBlockTextureName(RefStrings.MODID + ":reinforced_stone");
|
||||
concrete_smooth = new BlockRadResistant(Material.rock).setBlockName("concrete_smooth").setCreativeTab(MainRegistry.blockTab).setHardness(15.0F).setResistance(140.0F).setBlockTextureName(RefStrings.MODID + ":concrete");
|
||||
|
||||
38
src/main/java/com/hbm/blocks/machine/BlockBeamBase.java
Normal file
38
src/main/java/com/hbm/blocks/machine/BlockBeamBase.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockBeamBase extends BlockContainer {
|
||||
|
||||
public BlockBeamBase() {
|
||||
super(Material.air);
|
||||
setLightLevel(1.0F);
|
||||
setLightOpacity(0);
|
||||
setHardness(-1);
|
||||
setResistance(1_000_000);
|
||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override public boolean isOpaqueCube() { return false; }
|
||||
@Override public boolean renderAsNormalBlock() { return false; }
|
||||
@Override public int getRenderType() { return -1; }
|
||||
|
||||
@Override public Item getItemDropped(int i, Random rand, int j) { return null; }
|
||||
@Override public int quantityDropped(Random rand) { return 0; }
|
||||
|
||||
@Override public boolean isAir(IBlockAccess world, int x, int y, int z) { return true; }
|
||||
@Override public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { return true; }
|
||||
@Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int x, int y, int z) { return null; }
|
||||
|
||||
// This was taken from GregsLighting (cargo cult behaviour)
|
||||
// This is a bit screwy, but it's needed so that trees are not prevented from growing
|
||||
// near a floodlight beam.
|
||||
@Override public boolean isLeaves(IBlockAccess world, int x, int y, int z) { return true; }
|
||||
}
|
||||
@ -1,8 +1,13 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@ -12,7 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Floodlight extends BlockContainer {
|
||||
public class Floodlight extends BlockContainer implements IToolable {
|
||||
|
||||
public Floodlight(Material mat) {
|
||||
super(mat);
|
||||
@ -36,28 +41,49 @@ public class Floodlight extends BlockContainer {
|
||||
//only method with player param, called second for variable rotation
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
setAngle(world, x, y, z, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
if(tool != ToolType.SCREWDRIVER) return false;
|
||||
setAngle(world, x, y, z, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAngle(World world, int x, int y, int z, EntityLivingBase player) {
|
||||
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
float rotation = player.rotationPitch;
|
||||
|
||||
if(meta == 0 || meta == 1) {
|
||||
if(i == 0 || i == 2) world.setBlockMetadataWithNotify(x, y, z, meta + 6, 3);
|
||||
if(meta == 1) if(i == 0 || i == 1) rotation = 180F - rotation;
|
||||
if(meta == 0) if(i == 0 || i == 3) rotation = 180F - rotation;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof TileEntityFloodlight) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
TileEntityFloodlight floodlight = (TileEntityFloodlight) tile;
|
||||
|
||||
if(meta == 0 || meta == 1) {
|
||||
if(i == 0 || i == 2) world.setBlockMetadataWithNotify(x, y, z, meta + 6, 3);
|
||||
if(meta == 1) if(i == 0 || i == 1) rotation = 180F - rotation;
|
||||
if(meta == 0) if(i == 0 || i == 3) rotation = 180F - rotation;
|
||||
}
|
||||
|
||||
floodlight.rotation = -Math.round(rotation / 5F) * 5F;
|
||||
tile.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public static class TileEntityFloodlight extends TileEntity {
|
||||
public static class TileEntityFloodlight extends TileEntity implements IEnergyReceiverMK2 {
|
||||
|
||||
public float rotation;
|
||||
protected BlockPos[] lightPos = new BlockPos[9];
|
||||
public static final long maxPower = 10_000;
|
||||
public long power;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
@ -75,12 +101,22 @@ public class Floodlight extends BlockContainer {
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.rotation = nbt.getFloat("rotation");
|
||||
this.power = nbt.getLong("power");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setFloat("rotation", rotation);
|
||||
nbt.setLong("power", power);
|
||||
}
|
||||
|
||||
@Override public long getPower() { return power; }
|
||||
@Override public void setPower(long power) { this.power = power; }
|
||||
@Override public long getMaxPower() { return maxPower; }
|
||||
|
||||
private boolean isLoaded = true;
|
||||
@Override public boolean isLoaded() { return isLoaded; }
|
||||
@Override public void onChunkUnload() { this.isLoaded = false; }
|
||||
}
|
||||
}
|
||||
|
||||
16
src/main/java/com/hbm/blocks/machine/FloodlightBeam.java
Normal file
16
src/main/java/com/hbm/blocks/machine/FloodlightBeam.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FloodlightBeam extends BlockBeamBase {
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityFloodlightBeam();
|
||||
}
|
||||
|
||||
public static class TileEntityFloodlightBeam extends TileEntity {
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,29 +2,15 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.tileentity.TileEntityData;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class SpotlightBeam extends BlockContainer {
|
||||
|
||||
public SpotlightBeam() {
|
||||
super(Material.air);
|
||||
setLightLevel(1.0F);
|
||||
setLightOpacity(0);
|
||||
setHardness(-1);
|
||||
setResistance(1_000_000);
|
||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
public class SpotlightBeam extends BlockBeamBase {
|
||||
|
||||
// If a block is placed onto the beam, handle the new cutoff
|
||||
@Override
|
||||
@ -35,8 +21,7 @@ public class SpotlightBeam extends BlockContainer {
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If a block in the beam path is removed, repropagate beam
|
||||
@Override
|
||||
@ -78,7 +63,7 @@ public class SpotlightBeam extends BlockContainer {
|
||||
|
||||
// Sets the metadata bit for a given direction
|
||||
public static int applyDirection(int metadata, ForgeDirection direction, boolean state) {
|
||||
if (state) {
|
||||
if(state) {
|
||||
return metadata | direction.flag;
|
||||
} else {
|
||||
return metadata & ~direction.flag;
|
||||
@ -89,47 +74,4 @@ public class SpotlightBeam extends BlockContainer {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves(IBlockAccess world, int x, int y, int z) {
|
||||
// This was taken from GregsLighting (cargo cult behaviour)
|
||||
// This is a bit screwy, but it's needed so that trees are not prevented from growing
|
||||
// near a floodlight beam.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,83 +4,75 @@ import com.hbm.calc.Location;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityConverterHeRf extends TileEntityLoadedBase implements IEnergyReceiverMK2, IEnergyHandler {
|
||||
|
||||
//Thanks to the great people of Fusion Warfare for helping me with the original implementation of the RF energy API
|
||||
|
||||
public long power;
|
||||
public final long maxPower = 5_000_000;
|
||||
public EnergyStorage storage = new EnergyStorage(1_000_000, 1_000_000, 1_000_000);
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
|
||||
long rfCreated = Math.min(storage.getMaxEnergyStored() - storage.getEnergyStored(), power / 5);
|
||||
this.power -= rfCreated * 5;
|
||||
this.storage.setEnergyStored((int) (storage.getEnergyStored() + rfCreated));
|
||||
if(power > 0) this.power *= 0.95;
|
||||
if(rfCreated > 0) this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean canConnectEnergy(ForgeDirection from) { return true; }
|
||||
@Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { return 0; }
|
||||
@Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return 0; }
|
||||
@Override public int getEnergyStored(ForgeDirection from) { return 0; }
|
||||
@Override public int getMaxEnergyStored(ForgeDirection from) { return 0; }
|
||||
@Override public long getPower() { return 0; }
|
||||
@Override public void setPower(long power) { }
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return Integer.MAX_VALUE / 4;
|
||||
}
|
||||
|
||||
private long lastTransfer = 0;
|
||||
|
||||
@Override
|
||||
public long getReceiverSpeed() {
|
||||
|
||||
if(lastTransfer > 0) {
|
||||
return lastTransfer * 2;
|
||||
} else {
|
||||
return getMaxPower();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recursionBrake = false;
|
||||
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
|
||||
if(recursionBrake)
|
||||
return power;
|
||||
|
||||
recursionBrake = true;
|
||||
|
||||
// we have to limit the transfer amount because otherwise FEnSUs would overflow the RF output, twice
|
||||
long out = Math.min(power, Long.MAX_VALUE / 4);
|
||||
int toRF = (int) Math.min(Integer.MAX_VALUE, out * 4);
|
||||
int rfTransferred = 0;
|
||||
int totalTransferred = 0;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
Location loc = new Location(worldObj, xCoord, yCoord, zCoord).add(dir);
|
||||
TileEntity entity = loc.getTileEntity();
|
||||
|
||||
if(entity != null && entity instanceof IEnergyReceiver) {
|
||||
|
||||
IEnergyReceiver receiver = (IEnergyReceiver) entity;
|
||||
rfTransferred = receiver.receiveEnergy(dir.getOpposite(), toRF, false);
|
||||
totalTransferred += rfTransferred;
|
||||
|
||||
toRF -= rfTransferred; //to prevent energy duping
|
||||
Location loc = new Location(worldObj, xCoord, yCoord, zCoord).add(dir);
|
||||
TileEntity entity = loc.getTileEntity();
|
||||
|
||||
if (entity != null && entity instanceof IEnergyReceiver) {
|
||||
IEnergyReceiver receiver = (IEnergyReceiver) entity;
|
||||
|
||||
int maxExtract = storage.getMaxExtract();
|
||||
int maxAvailable = storage.extractEnergy(maxExtract, true);
|
||||
int energyTransferred = receiver.receiveEnergy(dir.getOpposite(), maxAvailable, false);
|
||||
|
||||
storage.extractEnergy(energyTransferred, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recursionBrake = false;
|
||||
lastTransfer = totalTransferred / 4;
|
||||
@Override public boolean canConnectEnergy(ForgeDirection from) { return true; }
|
||||
@Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { return 0; }
|
||||
@Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return storage.extractEnergy(maxExtract, simulate); }
|
||||
@Override public int getEnergyStored(ForgeDirection from) { return storage.getEnergyStored(); }
|
||||
@Override public int getMaxEnergyStored(ForgeDirection from) { return storage.getMaxEnergyStored(); }
|
||||
|
||||
@Override public void setPower(long i) { power = i; }
|
||||
@Override public long getPower() { return power; }
|
||||
@Override public long getMaxPower() { return maxPower; }
|
||||
@Override public ConnectionPriority getPriority() { return ConnectionPriority.LOW; }
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
return power - (totalTransferred / 4);
|
||||
this.power = nbt.getLong("power");
|
||||
storage.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setLong("power", power);
|
||||
storage.writeToNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,73 +1,59 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.interfaces.Untested;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energymk2.IEnergyProviderMK2;
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityConverterRfHe extends TileEntityLoadedBase implements IEnergyProviderMK2, IEnergyHandler {
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
subBuffer = power;
|
||||
}
|
||||
public long power;
|
||||
public final long maxPower = 5_000_000;
|
||||
public EnergyStorage storage = new EnergyStorage(1_000_000, 1_000_000, 1_000_000);
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return subBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return subBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private long subBuffer;
|
||||
private boolean recursionBrake = false;
|
||||
|
||||
@Untested
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
|
||||
if(this.tileEntityInvalid) return 0;
|
||||
if(recursionBrake) return 0;
|
||||
public void updateEntity() {
|
||||
|
||||
if(simulate)
|
||||
return maxReceive;
|
||||
|
||||
recursionBrake = true;
|
||||
|
||||
long capacity = maxReceive / 4L;
|
||||
subBuffer = capacity;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.tryProvide(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
if (!worldObj.isRemote) {
|
||||
|
||||
long rfCreated = Math.min(storage.getEnergyStored(), (maxPower - power) / 5);
|
||||
storage.setEnergyStored((int) (storage.getEnergyStored() - rfCreated));
|
||||
power += rfCreated * 5;
|
||||
if(storage.getEnergyStored() > 0) storage.extractEnergy((int) Math.ceil(storage.getEnergyStored() * 0.05), false);
|
||||
if(rfCreated > 0) this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.tryProvide(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean canConnectEnergy(ForgeDirection from) { return true; }
|
||||
@Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { return storage.receiveEnergy(maxReceive, simulate); }
|
||||
@Override public int getEnergyStored(ForgeDirection from) { return storage.getEnergyStored(); }
|
||||
@Override public int getMaxEnergyStored(ForgeDirection from) { return storage.getMaxEnergyStored(); }
|
||||
@Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return 0; }
|
||||
|
||||
@Override public long getPower() { return power; }
|
||||
@Override public void setPower(long power) { this.power = power; }
|
||||
@Override public long getMaxPower() { return maxPower; }
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
recursionBrake = false;
|
||||
this.power = nbt.getLong("power");
|
||||
storage.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
return (int) ((capacity - subBuffer) * 4L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return 1000000;
|
||||
nbt.setLong("power", power);
|
||||
storage.writeToNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package com.hbm.tileentity.network;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.network.CraneInserter;
|
||||
import com.hbm.entity.item.EntityMovingItem;
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerCraneGrabber;
|
||||
import com.hbm.inventory.gui.GUICraneGrabber;
|
||||
import com.hbm.items.ModItems;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerCraneRouter;
|
||||
import com.hbm.inventory.gui.GUICraneRouter;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
|
||||
@ -3,7 +3,6 @@ package com.hbm.tileentity.network;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.tileentity.IFilterable;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user