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
@ -1,6 +1,14 @@
|
|||||||
## Changed
|
## Changed
|
||||||
* Changed bedrock ore processing time in the electrolyzer to 60 ticks
|
* 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
|
||||||
* 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 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;
|
if(receiverEntries.isEmpty()) return;
|
||||||
|
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
long transferCap = 100_000_000_000_000_00L;
|
|
||||||
|
|
||||||
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
|
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
|
||||||
long powerAvailable = 0;
|
long powerAvailable = 0;
|
||||||
@ -134,11 +133,9 @@ public class PowerNetMK2 {
|
|||||||
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
|
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
|
||||||
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
|
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
|
||||||
providers.add(new Pair(entry.getKey(), src));
|
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];
|
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
|
||||||
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
|
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
|
||||||
long[] demand = new long[ConnectionPriority.values().length];
|
long[] demand = new long[ConnectionPriority.values().length];
|
||||||
|
|||||||
@ -307,6 +307,8 @@ public class ModBlocks {
|
|||||||
public static Block spotlight_halogen;
|
public static Block spotlight_halogen;
|
||||||
public static Block spotlight_halogen_off;
|
public static Block spotlight_halogen_off;
|
||||||
public static Block spotlight_beam;
|
public static Block spotlight_beam;
|
||||||
|
public static Block floodlight;
|
||||||
|
public static Block floodlight_beam;
|
||||||
|
|
||||||
public static Block reinforced_stone;
|
public static Block reinforced_stone;
|
||||||
public static Block concrete_smooth;
|
public static Block concrete_smooth;
|
||||||
@ -590,7 +592,6 @@ public class ModBlocks {
|
|||||||
public static Block spikes;
|
public static Block spikes;
|
||||||
|
|
||||||
public static Block charger;
|
public static Block charger;
|
||||||
public static Block floodlight;
|
|
||||||
|
|
||||||
public static Block tesla;
|
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_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");
|
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 = 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");
|
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");
|
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;
|
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.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
@ -12,7 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class Floodlight extends BlockContainer {
|
public class Floodlight extends BlockContainer implements IToolable {
|
||||||
|
|
||||||
public Floodlight(Material mat) {
|
public Floodlight(Material mat) {
|
||||||
super(mat);
|
super(mat);
|
||||||
@ -36,28 +41,49 @@ public class Floodlight extends BlockContainer {
|
|||||||
//only method with player param, called second for variable rotation
|
//only method with player param, called second for variable rotation
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
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;
|
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||||
float rotation = player.rotationPitch;
|
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);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if(tile instanceof TileEntityFloodlight) {
|
if(tile instanceof TileEntityFloodlight) {
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
TileEntityFloodlight floodlight = (TileEntityFloodlight) tile;
|
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;
|
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;
|
public float rotation;
|
||||||
|
protected BlockPos[] lightPos = new BlockPos[9];
|
||||||
|
public static final long maxPower = 10_000;
|
||||||
|
public long power;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket() {
|
public Packet getDescriptionPacket() {
|
||||||
@ -75,12 +101,22 @@ public class Floodlight extends BlockContainer {
|
|||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
this.rotation = nbt.getFloat("rotation");
|
this.rotation = nbt.getFloat("rotation");
|
||||||
|
this.power = nbt.getLong("power");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setFloat("rotation", rotation);
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.hbm.tileentity.TileEntityData;
|
import com.hbm.tileentity.TileEntityData;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class SpotlightBeam extends BlockContainer {
|
public class SpotlightBeam extends BlockBeamBase {
|
||||||
|
|
||||||
public SpotlightBeam() {
|
|
||||||
super(Material.air);
|
|
||||||
setLightLevel(1.0F);
|
|
||||||
setLightOpacity(0);
|
|
||||||
setHardness(-1);
|
|
||||||
setResistance(1_000_000);
|
|
||||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a block is placed onto the beam, handle the new cutoff
|
// If a block is placed onto the beam, handle the new cutoff
|
||||||
@Override
|
@Override
|
||||||
@ -35,8 +21,7 @@ public class SpotlightBeam extends BlockContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.breakBlock(world, x, y, z, block, metadata);
|
super.breakBlock(world, x, y, z, block, metadata);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If a block in the beam path is removed, repropagate beam
|
// If a block in the beam path is removed, repropagate beam
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +63,7 @@ public class SpotlightBeam extends BlockContainer {
|
|||||||
|
|
||||||
// Sets the metadata bit for a given direction
|
// Sets the metadata bit for a given direction
|
||||||
public static int applyDirection(int metadata, ForgeDirection direction, boolean state) {
|
public static int applyDirection(int metadata, ForgeDirection direction, boolean state) {
|
||||||
if (state) {
|
if(state) {
|
||||||
return metadata | direction.flag;
|
return metadata | direction.flag;
|
||||||
} else {
|
} else {
|
||||||
return metadata & ~direction.flag;
|
return metadata & ~direction.flag;
|
||||||
@ -89,47 +74,4 @@ public class SpotlightBeam extends BlockContainer {
|
|||||||
public TileEntity createNewTileEntity(World world, int meta) {
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
return new TileEntityData();
|
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,8 +4,10 @@ import com.hbm.calc.Location;
|
|||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
|
|
||||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||||
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
import cofh.api.energy.IEnergyHandler;
|
||||||
import cofh.api.energy.IEnergyReceiver;
|
import cofh.api.energy.IEnergyReceiver;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
@ -13,74 +15,64 @@ public class TileEntityConverterHeRf extends TileEntityLoadedBase implements IEn
|
|||||||
|
|
||||||
//Thanks to the great people of Fusion Warfare for helping me with the original implementation of the RF energy API
|
//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
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if (!worldObj.isRemote) {
|
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);
|
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean canConnectEnergy(ForgeDirection from) { return true; }
|
@Override public boolean canConnectEnergy(ForgeDirection from) { return true; }
|
||||||
@Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { return 0; }
|
@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 extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return storage.extractEnergy(maxExtract, simulate); }
|
||||||
@Override public int getEnergyStored(ForgeDirection from) { return 0; }
|
@Override public int getEnergyStored(ForgeDirection from) { return storage.getEnergyStored(); }
|
||||||
@Override public int getMaxEnergyStored(ForgeDirection from) { return 0; }
|
@Override public int getMaxEnergyStored(ForgeDirection from) { return storage.getMaxEnergyStored(); }
|
||||||
@Override public long getPower() { return 0; }
|
|
||||||
@Override public void setPower(long power) { }
|
@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
|
@Override
|
||||||
public long getMaxPower() {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
return Integer.MAX_VALUE / 4;
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
this.power = nbt.getLong("power");
|
||||||
|
storage.readFromNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long lastTransfer = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getReceiverSpeed() {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
if(lastTransfer > 0) {
|
nbt.setLong("power", power);
|
||||||
return lastTransfer * 2;
|
storage.writeToNBT(nbt);
|
||||||
} 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
recursionBrake = false;
|
|
||||||
lastTransfer = totalTransferred / 4;
|
|
||||||
|
|
||||||
return power - (totalTransferred / 4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,73 +1,59 @@
|
|||||||
package com.hbm.tileentity.network;
|
package com.hbm.tileentity.network;
|
||||||
|
|
||||||
import com.hbm.interfaces.Untested;
|
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
|
|
||||||
import api.hbm.energymk2.IEnergyProviderMK2;
|
import api.hbm.energymk2.IEnergyProviderMK2;
|
||||||
|
import cofh.api.energy.EnergyStorage;
|
||||||
import cofh.api.energy.IEnergyHandler;
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityConverterRfHe extends TileEntityLoadedBase implements IEnergyProviderMK2, IEnergyHandler {
|
public class TileEntityConverterRfHe extends TileEntityLoadedBase implements IEnergyProviderMK2, IEnergyHandler {
|
||||||
|
|
||||||
@Override
|
public long power;
|
||||||
public void setPower(long power) {
|
public final long maxPower = 5_000_000;
|
||||||
subBuffer = power;
|
public EnergyStorage storage = new EnergyStorage(1_000_000, 1_000_000, 1_000_000);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPower() {
|
public void updateEntity() {
|
||||||
return subBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (!worldObj.isRemote) {
|
||||||
public long getMaxPower() {
|
|
||||||
return subBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
long rfCreated = Math.min(storage.getEnergyStored(), (maxPower - power) / 5);
|
||||||
public boolean canConnectEnergy(ForgeDirection from) {
|
storage.setEnergyStored((int) (storage.getEnergyStored() - rfCreated));
|
||||||
return true;
|
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);
|
||||||
|
|
||||||
private long subBuffer;
|
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
private boolean recursionBrake = false;
|
this.tryProvide(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||||
|
}
|
||||||
@Untested
|
|
||||||
@Override
|
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
|
||||||
|
|
||||||
if(this.tileEntityInvalid) return 0;
|
|
||||||
if(recursionBrake) return 0;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
recursionBrake = false;
|
@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; }
|
||||||
|
|
||||||
return (int) ((capacity - subBuffer) * 4L);
|
@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);
|
||||||
|
|
||||||
|
this.power = nbt.getLong("power");
|
||||||
|
storage.readFromNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
return 0;
|
super.writeToNBT(nbt);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
nbt.setLong("power", power);
|
||||||
public int getEnergyStored(ForgeDirection from) {
|
storage.writeToNBT(nbt);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxEnergyStored(ForgeDirection from) {
|
|
||||||
return 1000000;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package com.hbm.tileentity.network;
|
|||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.blocks.network.CraneInserter;
|
import com.hbm.blocks.network.CraneInserter;
|
||||||
import com.hbm.entity.item.EntityMovingItem;
|
import com.hbm.entity.item.EntityMovingItem;
|
||||||
import com.hbm.interfaces.IControlReceiver;
|
|
||||||
import com.hbm.inventory.container.ContainerCraneGrabber;
|
import com.hbm.inventory.container.ContainerCraneGrabber;
|
||||||
import com.hbm.inventory.gui.GUICraneGrabber;
|
import com.hbm.inventory.gui.GUICraneGrabber;
|
||||||
import com.hbm.items.ModItems;
|
import com.hbm.items.ModItems;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.hbm.tileentity.network;
|
package com.hbm.tileentity.network;
|
||||||
|
|
||||||
import com.hbm.interfaces.IControlReceiver;
|
|
||||||
import com.hbm.inventory.container.ContainerCraneRouter;
|
import com.hbm.inventory.container.ContainerCraneRouter;
|
||||||
import com.hbm.inventory.gui.GUICraneRouter;
|
import com.hbm.inventory.gui.GUICraneRouter;
|
||||||
import com.hbm.module.ModulePatternMatcher;
|
import com.hbm.module.ModulePatternMatcher;
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package com.hbm.tileentity.network;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.hbm.interfaces.IControlReceiver;
|
|
||||||
import com.hbm.inventory.RecipesCommon.AStack;
|
import com.hbm.inventory.RecipesCommon.AStack;
|
||||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.hbm.tileentity.network;
|
package com.hbm.tileentity.network;
|
||||||
|
|
||||||
import com.hbm.interfaces.IControlReceiver;
|
|
||||||
import com.hbm.module.ModulePatternMatcher;
|
import com.hbm.module.ModulePatternMatcher;
|
||||||
import com.hbm.tileentity.IFilterable;
|
import com.hbm.tileentity.IFilterable;
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user