Revert "Fusion reactor fixes & rewrite, energy fixes."
This reverts commit 06fad2264f
.
This commit is contained in:
parent
22fd152ec9
commit
8a0d981018
13 changed files with 386 additions and 279 deletions
|
@ -44,7 +44,7 @@ public class BlockFusionControlComputer extends BlockMachineBase implements IAdv
|
|||
super.onEntityWalk(worldIn, pos, entityIn);
|
||||
if (worldIn.getTileEntity(pos) instanceof TileEntityFusionController)
|
||||
{
|
||||
if (((TileEntityFusionController) worldIn.getTileEntity(pos)).recipe != null
|
||||
if (((TileEntityFusionController) worldIn.getTileEntity(pos)).crafingTickTime != 0
|
||||
&& ((TileEntityFusionController) worldIn.getTileEntity(pos)).checkCoils())
|
||||
{
|
||||
entityIn.attackEntityFrom(new FusionDamageSource(), 200F);
|
||||
|
|
|
@ -7,22 +7,21 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.api.reactor.FusionReactorRecipe;
|
||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||
|
||||
public class ContainerFusionReactor extends RebornContainer {
|
||||
public class ContainerFusionReactor extends RebornContainer
|
||||
{
|
||||
|
||||
public int coilStatus;
|
||||
public int energy;
|
||||
public int tickTime;
|
||||
public int finalTickTime;
|
||||
|
||||
public int neededEnergy;
|
||||
public int energy;
|
||||
|
||||
public boolean hasCoils;
|
||||
public int neededEU;
|
||||
|
||||
TileEntityFusionController fusionController;
|
||||
|
||||
public ContainerFusionReactor(TileEntityFusionController tileEntityFusionController, EntityPlayer player) {
|
||||
public ContainerFusionReactor(TileEntityFusionController tileEntityFusionController, EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.fusionController = tileEntityFusionController;
|
||||
|
||||
|
@ -32,73 +31,105 @@ public class ContainerFusionReactor extends RebornContainer {
|
|||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
FusionReactorRecipe rec = fusionController.recipe;
|
||||
for (int i = 0; i < this.listeners.size(); i++) {
|
||||
IContainerListener listener = this.listeners.get(i);
|
||||
listener.sendProgressBarUpdate(this, 0, fusionController.hasCoils ? 1 : 0);
|
||||
listener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
listener.sendProgressBarUpdate(this, 2, rec == null ? 0 : (int) rec.getStartEU());
|
||||
listener.sendProgressBarUpdate(this, 3, rec == null ? -1 : fusionController.recipeTickTime);
|
||||
listener.sendProgressBarUpdate(this, 4, rec == null ? 0 : rec.getTickTime());
|
||||
for (int i = 0; i < this.listeners.size(); i++)
|
||||
{
|
||||
IContainerListener IContainerListener = this.listeners.get(i);
|
||||
if (this.coilStatus != fusionController.coilStatus)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 0, fusionController.coilStatus);
|
||||
}
|
||||
if (this.energy != (int) fusionController.getEnergy())
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
}
|
||||
if (this.tickTime != fusionController.crafingTickTime)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 2, fusionController.crafingTickTime);
|
||||
}
|
||||
if (this.finalTickTime != fusionController.finalTickTime)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 3, fusionController.finalTickTime);
|
||||
}
|
||||
if (this.neededEU != fusionController.neededPower)
|
||||
{
|
||||
IContainerListener.sendProgressBarUpdate(this, 4, fusionController.neededPower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener) {
|
||||
super.addListener(listener);
|
||||
FusionReactorRecipe rec = fusionController.recipe;
|
||||
listener.sendProgressBarUpdate(this, 0, fusionController.hasCoils ? 1 : 0);
|
||||
listener.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
listener.sendProgressBarUpdate(this, 2, rec == null ? 0 : (int) rec.getStartEU());
|
||||
listener.sendProgressBarUpdate(this, 3, rec == null ? -1 : fusionController.recipeTickTime);
|
||||
listener.sendProgressBarUpdate(this, 4, rec == null ? 0 : rec.getTickTime());
|
||||
public void addListener(IContainerListener crafting)
|
||||
{
|
||||
super.addListener(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, fusionController.coilStatus);
|
||||
crafting.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
|
||||
crafting.sendProgressBarUpdate(this, 2, fusionController.crafingTickTime);
|
||||
crafting.sendProgressBarUpdate(this, 3, fusionController.finalTickTime);
|
||||
crafting.sendProgressBarUpdate(this, 4, fusionController.neededPower);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
this.hasCoils = value == 1;
|
||||
break;
|
||||
case 1:
|
||||
this.energy = value;
|
||||
break;
|
||||
case 2:
|
||||
this.neededEnergy = value;
|
||||
break;
|
||||
case 3:
|
||||
this.tickTime = value;
|
||||
break;
|
||||
case 4:
|
||||
this.finalTickTime = value;
|
||||
break;
|
||||
public void updateProgressBar(int id, int value)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.coilStatus = value;
|
||||
} else if (id == 1)
|
||||
{
|
||||
this.energy = value;
|
||||
} else if (id == 2)
|
||||
{
|
||||
this.tickTime = value;
|
||||
} else if (id == 3)
|
||||
{
|
||||
this.finalTickTime = value;
|
||||
} else if (id == 4)
|
||||
{
|
||||
this.neededEU = value;
|
||||
}
|
||||
if (tickTime == -1)
|
||||
{
|
||||
tickTime = 0;
|
||||
}
|
||||
if (finalTickTime == -1)
|
||||
{
|
||||
finalTickTime = 0;
|
||||
}
|
||||
if (neededEU == -1)
|
||||
{
|
||||
neededEU = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getProgressScaled() {
|
||||
public int getProgressScaled()
|
||||
{
|
||||
return Math.max(0, Math.min(24,
|
||||
(this.tickTime > 0 ? 1 : 0) + this.tickTime * 24 / (this.finalTickTime < 1 ? 1 : this.finalTickTime)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.api.reactor.FusionReactorRecipe;
|
||||
import techreborn.client.container.ContainerFusionReactor;
|
||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||
|
||||
|
@ -20,28 +19,29 @@ public class GuiFusionReactor extends GuiContainer
|
|||
"textures/gui/fusion_reactor.png");
|
||||
|
||||
ContainerFusionReactor containerFusionReactor;
|
||||
public GuiFusionReactor(EntityPlayer player, TileEntityFusionController tileaesu) {
|
||||
TileEntityFusionController fusionController;
|
||||
|
||||
public GuiFusionReactor(EntityPlayer player, TileEntityFusionController tileaesu)
|
||||
{
|
||||
super(new ContainerFusionReactor(tileaesu, player));
|
||||
containerFusionReactor = (ContainerFusionReactor) this.inventorySlots;
|
||||
this.fusionController = tileaesu;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
String name = I18n.translateToLocal("tile.techreborn.fusioncontrolcomputer.name");
|
||||
this.fontRendererObj.drawString(name, 87, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocalizedPower(containerFusionReactor.energy), 11, 8, 16448255);
|
||||
this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.hasCoils ? "Yes" : "No"), 11, 16, 16448255);
|
||||
|
||||
if(containerFusionReactor.tickTime != -1) {
|
||||
if (containerFusionReactor.tickTime == 0) {
|
||||
this.fontRendererObj.drawString("Start: " + percentage(containerFusionReactor.neededEnergy,
|
||||
containerFusionReactor.energy) + "%", 11, 24, 16448255);
|
||||
} else {
|
||||
this.fontRendererObj.drawString("Fusion: " + percentage(containerFusionReactor.finalTickTime,
|
||||
containerFusionReactor.tickTime) + "%", 11, 24, 16448255);
|
||||
}
|
||||
}
|
||||
this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.coilStatus == 1 ? "Yes" : "No"), 11, 16,
|
||||
16448255);
|
||||
if (containerFusionReactor.neededEU > 1 && containerFusionReactor.tickTime < 1)
|
||||
this.fontRendererObj.drawString(
|
||||
"Start: " + percentage(containerFusionReactor.neededEU, containerFusionReactor.energy) + "%", 11,
|
||||
24, 16448255);
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class GuiFusionReactor extends GuiContainer
|
|||
|
||||
}
|
||||
|
||||
public int percentage(double MaxValue, double CurrentValue)
|
||||
public int percentage(int MaxValue, int CurrentValue)
|
||||
{
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
|
|
|
@ -4,8 +4,6 @@ import com.google.common.collect.ImmutableList;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import techreborn.Core;
|
||||
|
@ -121,12 +119,6 @@ public class OreDict {
|
|||
String oreDictName = "nugget" + OreDictUtils.toFirstUpper(type);
|
||||
OreDictionary.registerOre(oreDictName, ItemNuggets.getNuggetByName(type));
|
||||
}
|
||||
|
||||
for(Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
ItemStack cell = DynamicCell.getCellWithFluid(fluid);
|
||||
String oreDictName = "cell" + OreDictUtils.toFirstUpper(fluid.getName().toLowerCase());
|
||||
OreDictionary.registerOre(oreDictName, cell);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,7 @@ package techreborn.parts.powerCables;
|
|||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.energy.tile.*;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.darkhax.tesla.capability.TeslaCapabilities;
|
||||
|
@ -36,6 +34,7 @@ import net.minecraftforge.common.property.IExtendedBlockState;
|
|||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import reborncore.api.power.IEnergyInterfaceTile;
|
||||
import reborncore.api.power.tile.IEnergyProducerTile;
|
||||
import reborncore.api.power.tile.IEnergyReceiverTile;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
|
@ -301,36 +300,36 @@ public class CableMultipart extends Multipart
|
|||
if(tileEntity == null) continue;
|
||||
EnumFacing opposite = connection.getOpposite();
|
||||
|
||||
//TODO rewrite for new version
|
||||
if(tileEntity instanceof IEnergyProducerTile) {
|
||||
IEnergyProducerTile interfaceTile = (IEnergyProducerTile) tileEntity;
|
||||
if(interfaceTile.canProvideEnergy(opposite)) {
|
||||
double extractedEU = interfaceTile.useEnergy(getCableType().transferRate, true);
|
||||
double dispatched = EnergyUtils.dispatchWiresEnergyPacket(getWorld(), getPos(), extractedEU, blockPos);
|
||||
interfaceTile.useEnergy(dispatched);
|
||||
if(extractedEU != 0) continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(Loader.isModLoaded("IC2") && RebornCoreConfig.getRebornPower().eu()) {
|
||||
if (tileEntity instanceof IEnergySource) {
|
||||
IEnergySource source = (IEnergySource) tileEntity;
|
||||
if (source.emitsEnergyTo((emitter, from) -> true, opposite)) {
|
||||
if(source.emitsEnergyTo((emitter, from) -> true, opposite)) {
|
||||
double extractedEU = source.getOfferedEnergy();
|
||||
if (extractedEU > getCableType().transferRate)
|
||||
extractedEU = getCableType().transferRate;
|
||||
double dispatched = EnergyUtils.dispatchWiresEnergyPacket(getWorld(), getPos(), extractedEU, blockPos);
|
||||
source.drawEnergy(dispatched);
|
||||
if (extractedEU != 0) continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (tileEntity instanceof IEnergyStorage) {
|
||||
} else if(tileEntity instanceof IEnergyStorage) {
|
||||
IEnergyStorage storage = (IEnergyStorage) tileEntity;
|
||||
double extractedEU = storage.getStored();
|
||||
if (extractedEU > getCableType().transferRate)
|
||||
if(extractedEU > getCableType().transferRate)
|
||||
extractedEU = getCableType().transferRate;
|
||||
double dispatched = EnergyUtils.dispatchWiresEnergyPacket(getWorld(), getPos(), extractedEU, blockPos);
|
||||
storage.setStored((int) (extractedEU - dispatched));
|
||||
if (extractedEU != 0) continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,17 +342,18 @@ public class CableMultipart extends Multipart
|
|||
double extractedEU = extractedRF / (RebornCoreConfig.euPerRF * 1f);
|
||||
double dispatched = EnergyUtils.dispatchWiresEnergyPacket(getWorld(), getPos(), extractedEU, blockPos);
|
||||
provider.extractEnergy(opposite, (int) (dispatched * RebornCoreConfig.euPerRF), false);
|
||||
if (extractedEU != 0) continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (tileEntity instanceof cofh.api.energy.IEnergyStorage) {
|
||||
} else if(tileEntity instanceof cofh.api.energy.IEnergyStorage) {
|
||||
cofh.api.energy.IEnergyStorage energyStorage = (cofh.api.energy.IEnergyStorage) tileEntity;
|
||||
int extractedRF = energyStorage.extractEnergy(
|
||||
getCableType().transferRate * RebornCoreConfig.euPerRF, true);
|
||||
double extractedEU = extractedRF / (RebornCoreConfig.euPerRF * 1f);
|
||||
if (extractedEU > getCableType().transferRate)
|
||||
extractedEU = getCableType().transferRate;
|
||||
double dispatched = EnergyUtils.dispatchWiresEnergyPacket(getWorld(), getPos(), extractedEU, blockPos);
|
||||
energyStorage.extractEnergy((int) (dispatched * RebornCoreConfig.euPerRF), false);
|
||||
if (extractedEU != 0) continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ public class CableMultipart extends Multipart
|
|||
double extractedEU = extractedRF / (RebornCoreConfig.euPerRF * 1F);
|
||||
double dispatched = EnergyUtils.dispatchWiresEnergyPacket(getWorld(), getPos(), extractedEU, blockPos);
|
||||
producer.takePower((long) (dispatched * RebornCoreConfig.euPerRF), false);
|
||||
if (extractedEU != 0) continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.power.tile.IEnergyProducerTile;
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.tile.TilePowerAcceptorProducer;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.power.EnergyUtils;
|
||||
|
||||
public class TileAesu extends TilePowerAcceptor implements IEnergyProducerTile, IWrenchable {
|
||||
public class TileAesu extends TilePowerAcceptorProducer implements IWrenchable {
|
||||
|
||||
public static final int MAX_OUTPUT = ConfigTechReborn.AesuMaxOutput;
|
||||
public static final int MAX_STORAGE = ConfigTechReborn.AesuMaxStorage;
|
||||
|
@ -44,11 +44,19 @@ public class TileAesu extends TilePowerAcceptor implements IEnergyProducerTile,
|
|||
|
||||
if (!worldObj.isRemote && getEnergy() > 0) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
double disposed = emitEnergy(getFacingEnum(), maxOutput);
|
||||
if (maxOutput != 0 && disposed != 0) useEnergy(disposed);
|
||||
for(EnumFacing facing : EnumFacing.VALUES) {
|
||||
double disposed = emitEnergy(facing, maxOutput);
|
||||
if(disposed != 0) {
|
||||
maxOutput -= disposed;
|
||||
useEnergy(disposed);
|
||||
if (maxOutput == 0) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO move to RebornCore
|
||||
public double emitEnergy(EnumFacing enumFacing, double amount) {
|
||||
BlockPos pos = getPos().offset(enumFacing);
|
||||
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
|
||||
|
@ -59,16 +67,6 @@ public class TileAesu extends TilePowerAcceptor implements IEnergyProducerTile,
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() == direction;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
|
|
|
@ -5,12 +5,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.tile.IEnergyProducerTile;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.explosion.RebornExplosion;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.tile.TilePowerAcceptorProducer;
|
||||
import reborncore.common.util.Inventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.api.reactor.FusionReactorRecipe;
|
||||
|
@ -18,16 +16,21 @@ import techreborn.api.reactor.FusionReactorRecipeHelper;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.power.EnergyUtils;
|
||||
|
||||
public class TileEntityFusionController extends TilePowerAcceptor implements IEnergyProducerTile, IInventoryProvider {
|
||||
public class TileEntityFusionController extends TilePowerAcceptorProducer implements IInventoryProvider
|
||||
{
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileEntityFusionController", 64, this);
|
||||
|
||||
public boolean hasCoils;
|
||||
|
||||
public int recipeTickTime = 0;
|
||||
|
||||
public FusionReactorRecipe recipe = null;
|
||||
public boolean repeatSameRecipe = false;
|
||||
// 0= no coils, 1 = coils
|
||||
public int coilStatus = 0;
|
||||
public int crafingTickTime = 0;
|
||||
public int finalTickTime = 0;
|
||||
public int neededPower = 0;
|
||||
int topStackSlot = 0;
|
||||
int bottomStackSlot = 1;
|
||||
int outputStackSlot = 2;
|
||||
FusionReactorRecipe currentRecipe = null;
|
||||
boolean hasStartedCrafting = false;
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
|
@ -36,54 +39,66 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IEn
|
|||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return recipeTickTime == 0;
|
||||
return hasStartedCrafting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return recipeTickTime != 0;
|
||||
return !hasStartedCrafting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
if (!hasStartedCrafting)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
return EnumPowerTier.INSANE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
if(tagCompound.hasKey("recipeTickTime") && checkCoils()) {
|
||||
ItemStack topInput = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("TopInput"));
|
||||
ItemStack bottomInput = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("BottomInput"));
|
||||
FusionReactorRecipe newRecipe = findNewNBTRecipe(topInput, bottomInput);
|
||||
if(newRecipe != null) {
|
||||
this.recipeTickTime = tagCompound.getInteger("recipeTickTime");
|
||||
this.repeatSameRecipe = tagCompound.getBoolean("repeatSameRecipe");
|
||||
this.recipe = newRecipe;
|
||||
}
|
||||
}
|
||||
crafingTickTime = tagCompound.getInteger("crafingTickTime");
|
||||
finalTickTime = tagCompound.getInteger("finalTickTime");
|
||||
neededPower = tagCompound.getInteger("neededPower");
|
||||
hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
if(recipe != null) {
|
||||
tagCompound.setTag("TopInput", recipe.getTopInput().writeToNBT(new NBTTagCompound()));
|
||||
tagCompound.setTag("BottomInput", recipe.getBottomInput().writeToNBT(new NBTTagCompound()));
|
||||
|
||||
tagCompound.setInteger("recipeTickTime", recipeTickTime);
|
||||
tagCompound.setBoolean("repeatSameRecipe", repeatSameRecipe);
|
||||
if (crafingTickTime == -1)
|
||||
{
|
||||
crafingTickTime = 0;
|
||||
}
|
||||
if (finalTickTime == -1)
|
||||
{
|
||||
finalTickTime = 0;
|
||||
}
|
||||
if (neededPower == -1)
|
||||
{
|
||||
neededPower = 0;
|
||||
}
|
||||
tagCompound.setInteger("crafingTickTime", crafingTickTime);
|
||||
tagCompound.setInteger("finalTickTime", finalTickTime);
|
||||
tagCompound.setInteger("neededPower", neededPower);
|
||||
tagCompound.setBoolean("hasStartedCrafting", hasStartedCrafting);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
||||
public boolean checkCoils() {
|
||||
public boolean checkCoils()
|
||||
{
|
||||
if ((isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() + 1))
|
||||
&& (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ()))
|
||||
&& (isCoil(this.getPos().getX() + 3, this.getPos().getY(), this.getPos().getZ() - 1))
|
||||
|
@ -107,140 +122,211 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IEn
|
|||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 2))
|
||||
&& (isCoil(this.getPos().getX() - 1, this.getPos().getY(), this.getPos().getZ() - 3))
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() + 3))
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() - 3))) {
|
||||
hasCoils = true;
|
||||
&& (isCoil(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ() - 3)))
|
||||
{
|
||||
coilStatus = 1;
|
||||
return true;
|
||||
}
|
||||
hasCoils = false;
|
||||
coilStatus = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isCoil(int x, int y, int z) {
|
||||
private boolean isCoil(int x, int y, int z)
|
||||
{
|
||||
return worldObj.getBlockState(new BlockPos(x, y, z)).getBlock() == ModBlocks.FusionCoil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update()
|
||||
{
|
||||
super.update();
|
||||
// TODO improve this code a lot
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
checkCoils();
|
||||
}
|
||||
if (worldObj.getTotalWorldTime() % 20 == 0)
|
||||
{
|
||||
checkCoils();
|
||||
}
|
||||
|
||||
if (hasCoils) {
|
||||
if (recipe == null || inventory.hasChanged) {
|
||||
FusionReactorRecipe newRecipe = findNewRecipe();
|
||||
if (newRecipe != null && newRecipe != recipe) {
|
||||
this.recipe = newRecipe;
|
||||
this.repeatSameRecipe = false;
|
||||
this.recipeTickTime = 0;
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (coilStatus == 1)
|
||||
{
|
||||
if (currentRecipe == null)
|
||||
{
|
||||
if (inventory.hasChanged || crafingTickTime != 0)
|
||||
{
|
||||
for (FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes)
|
||||
{
|
||||
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), reactorRecipe.getTopInput(), true,
|
||||
true, true))
|
||||
{
|
||||
if (reactorRecipe.getBottomInput() != null)
|
||||
{
|
||||
if (!ItemUtils.isItemEqual(getStackInSlot(bottomStackSlot),
|
||||
reactorRecipe.getBottomInput(), true, true, true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (canFitStack(reactorRecipe.getOutput(), outputStackSlot, true))
|
||||
{
|
||||
currentRecipe = reactorRecipe;
|
||||
if (crafingTickTime != 0)
|
||||
{
|
||||
finalTickTime = currentRecipe.getTickTime();
|
||||
neededPower = (int) currentRecipe.getStartEU();
|
||||
}
|
||||
hasStartedCrafting = false;
|
||||
crafingTickTime = 0;
|
||||
finalTickTime = currentRecipe.getTickTime();
|
||||
neededPower = (int) currentRecipe.getStartEU();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (inventory.hasChanged)
|
||||
{
|
||||
if (!validateRecipe())
|
||||
{
|
||||
resetCrafter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!hasStartedCrafting)
|
||||
{
|
||||
if (canUseEnergy(currentRecipe.getStartEU() + 64))
|
||||
{
|
||||
useEnergy(currentRecipe.getStartEU());
|
||||
hasStartedCrafting = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (crafingTickTime < currentRecipe.getTickTime())
|
||||
{
|
||||
if (currentRecipe.getEuTick() > 0)
|
||||
{ // Power gen
|
||||
addEnergy(currentRecipe.getEuTick()); // Waste
|
||||
// power
|
||||
// if it
|
||||
// has
|
||||
// no
|
||||
// where
|
||||
// to go
|
||||
crafingTickTime++;
|
||||
} else
|
||||
{ // Power user
|
||||
if (canUseEnergy(currentRecipe.getEuTick() * -1))
|
||||
{
|
||||
setEnergy(getEnergy() - (currentRecipe.getEuTick() * -1));
|
||||
crafingTickTime++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true))
|
||||
{
|
||||
if (getStackInSlot(outputStackSlot) == null)
|
||||
{
|
||||
setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy());
|
||||
} else
|
||||
{
|
||||
decrStackSize(outputStackSlot, -currentRecipe.getOutput().stackSize);
|
||||
}
|
||||
decrStackSize(topStackSlot, currentRecipe.getTopInput().stackSize);
|
||||
if (currentRecipe.getBottomInput() != null)
|
||||
{
|
||||
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().stackSize);
|
||||
}
|
||||
resetCrafter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe != null) {
|
||||
if (recipeTickTime == 0) {
|
||||
if (canUseEnergy(recipe.getStartEU())) {
|
||||
useEnergy(recipe.getStartEU());
|
||||
consumeInputStacks();
|
||||
++recipeTickTime;
|
||||
}
|
||||
} else if (++recipeTickTime >= recipe.getTickTime()) {
|
||||
addOutputStack(recipe.getOutput());
|
||||
FusionReactorRecipe newRecipe = findNewRecipe();
|
||||
if (newRecipe == recipe) {
|
||||
consumeInputStacks();
|
||||
this.repeatSameRecipe = true;
|
||||
recipeTickTime = 1;
|
||||
} else {
|
||||
this.recipe = null;
|
||||
this.repeatSameRecipe = false;
|
||||
recipeTickTime = 0;
|
||||
}
|
||||
} else {
|
||||
double euTick = recipe.getEuTick();
|
||||
if (euTick > 0) addEnergy(euTick);
|
||||
else if (useEnergy(-euTick) != euTick) {
|
||||
this.recipeTickTime = 0;
|
||||
this.repeatSameRecipe = false;
|
||||
this.recipe = null;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (currentRecipe != null)
|
||||
{
|
||||
resetCrafter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote && getEnergy() > 0 && recipeTickTime != 0) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
double disposed = 0;
|
||||
for(EnumFacing facing : EnumFacing.VALUES) {
|
||||
if(canProvideEnergy(facing)) {
|
||||
double emitted = emitEnergy(facing, maxOutput);
|
||||
maxOutput -= emitted;
|
||||
disposed += emitted;
|
||||
}
|
||||
}
|
||||
if (disposed != 0)
|
||||
if (inventory.hasChanged)
|
||||
{
|
||||
inventory.hasChanged = false;
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote && getEnergy() > 0 && hasStartedCrafting) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
for(EnumFacing facing : EnumFacing.VALUES) {
|
||||
double disposed = emitEnergy(facing, maxOutput);
|
||||
if(disposed != 0) {
|
||||
maxOutput -= disposed;
|
||||
useEnergy(disposed);
|
||||
if (maxOutput == 0) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public FusionReactorRecipe findNewRecipe() {
|
||||
for(FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) {
|
||||
if(canFitStack(reactorRecipe.getOutput(), 2) &&
|
||||
canEmptyStack(reactorRecipe.getTopInput(), 0) &&
|
||||
canEmptyStack(reactorRecipe.getBottomInput(), 1)) {
|
||||
return reactorRecipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FusionReactorRecipe findNewNBTRecipe(ItemStack top, ItemStack bottom) {
|
||||
for(FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) {
|
||||
if(canFitStack(reactorRecipe.getOutput(), 2) &&
|
||||
ItemUtils.isItemEqual(top, reactorRecipe.getTopInput(), true, true) &&
|
||||
ItemUtils.isItemEqual(bottom, reactorRecipe.getBottomInput(), true, true)) {
|
||||
return reactorRecipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//TODO move to RebornCore
|
||||
public double emitEnergy(EnumFacing enumFacing, double amount) {
|
||||
BlockPos pos = getPos().offset(enumFacing);
|
||||
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
|
||||
worldObj, enumFacing.getOpposite(), pos);
|
||||
if (receiver != null) {
|
||||
if(receiver != null) {
|
||||
return receiver.receiveEnergy(amount, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void consumeInputStacks() {
|
||||
if(--getStackInSlot(0).stackSize == 0) setInventorySlotContents(0, null);
|
||||
if(--getStackInSlot(1).stackSize == 0) setInventorySlotContents(1, null);
|
||||
private boolean validateRecipe()
|
||||
{
|
||||
if (ItemUtils.isItemEqual(getStackInSlot(topStackSlot), currentRecipe.getTopInput(), true, true, true))
|
||||
{
|
||||
if (currentRecipe.getBottomInput() != null)
|
||||
{
|
||||
if (!ItemUtils.isItemEqual(getStackInSlot(bottomStackSlot), currentRecipe.getBottomInput(), true, true,
|
||||
true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addOutputStack(ItemStack output) {
|
||||
ItemStack stack = getStackInSlot(2);
|
||||
if(stack == null) setInventorySlotContents(2, output);
|
||||
else stack.stackSize++;
|
||||
private void resetCrafter()
|
||||
{
|
||||
currentRecipe = null;
|
||||
crafingTickTime = -1;
|
||||
finalTickTime = -1;
|
||||
neededPower = -1;
|
||||
hasStartedCrafting = false;
|
||||
}
|
||||
|
||||
public boolean canEmptyStack(ItemStack stack, int slot) {
|
||||
return inventory.getStackInSlot(slot) != null &&
|
||||
ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true);
|
||||
}
|
||||
|
||||
public boolean canFitStack(ItemStack stack, int slot) {
|
||||
if (stack == null || inventory.getStackInSlot(slot) == null) {
|
||||
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic)
|
||||
{// Checks to see if it can fit the stack
|
||||
if (stack == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) {
|
||||
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) {
|
||||
if (inventory.getStackInSlot(slot) == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic))
|
||||
{
|
||||
if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -248,23 +334,25 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IEn
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return "Fusion Reactor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TextComponentString(getName());
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,11 +101,19 @@ public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable {
|
|||
|
||||
if (!worldObj.isRemote && getEnergy() > 0) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
double disposed = emitEnergy(getFacingEnum(), maxOutput);
|
||||
if (maxOutput != 0 && disposed != 0) useEnergy(disposed);
|
||||
for(EnumFacing facing : EnumFacing.VALUES) {
|
||||
double disposed = emitEnergy(facing, maxOutput);
|
||||
if(disposed != 0) {
|
||||
maxOutput -= disposed;
|
||||
useEnergy(disposed);
|
||||
if (maxOutput == 0) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO move to RebornCore
|
||||
public double emitEnergy(EnumFacing enumFacing, double amount) {
|
||||
BlockPos pos = getPos().offset(enumFacing);
|
||||
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
|
||||
|
@ -116,16 +124,6 @@ public class TileIDSU extends TilePowerAcceptorProducer implements IWrenchable {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() == direction;
|
||||
}
|
||||
|
||||
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||
return false;
|
||||
|
|
|
@ -72,11 +72,19 @@ public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
|
|||
|
||||
if (!worldObj.isRemote && getEnergy() > 0) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
double disposed = emitEnergy(getFacingEnum(), maxOutput);
|
||||
if (maxOutput != 0 && disposed != 0) useEnergy(disposed);
|
||||
for(EnumFacing facing : EnumFacing.VALUES) {
|
||||
double disposed = emitEnergy(facing, maxOutput);
|
||||
if(disposed != 0) {
|
||||
maxOutput -= disposed;
|
||||
useEnergy(disposed);
|
||||
if (maxOutput == 0) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO move to RebornCore
|
||||
public double emitEnergy(EnumFacing enumFacing, double amount) {
|
||||
BlockPos pos = getPos().offset(enumFacing);
|
||||
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
|
||||
|
@ -87,16 +95,6 @@ public class TileLesu extends TilePowerAcceptorProducer {// TODO wrench
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() == direction;
|
||||
}
|
||||
|
||||
|
||||
public double getEuChange() {
|
||||
if (euChange == -1) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import techreborn.init.ModBlocks;
|
|||
public class TileBatBox extends TileEnergyStorage {
|
||||
|
||||
public TileBatBox() {
|
||||
super("BatBox", 2, ModBlocks.batBox, EnumPowerTier.LOW, 40000);
|
||||
super("BatBox", 2, ModBlocks.batBox, EnumPowerTier.LOW, 32, 32, 40000);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,9 @@ import net.minecraft.util.math.BlockPos;
|
|||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.api.power.tile.IEnergyProducerTile;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import reborncore.common.powerSystem.PoweredItem;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.tile.TilePowerAcceptorProducer;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.blocks.storage.BlockEnergyStorage;
|
||||
|
@ -24,19 +22,23 @@ import java.util.List;
|
|||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public class TileEnergyStorage extends TilePowerAcceptor implements IEnergyProducerTile, IWrenchable, ITickable, IInventoryProvider, IListInfoProvider {
|
||||
public class TileEnergyStorage extends TilePowerAcceptorProducer implements IWrenchable, ITickable, IInventoryProvider, IListInfoProvider {
|
||||
|
||||
public Inventory inventory;
|
||||
public String name;
|
||||
public Block wrenchDrop;
|
||||
public EnumPowerTier tier;
|
||||
public int maxInput;
|
||||
public int maxOutput;
|
||||
public int maxStorage;
|
||||
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxStorage) {
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
|
||||
inventory = new Inventory(invSize, "Tile" + name, 64, this);
|
||||
this.wrenchDrop = wrenchDrop;
|
||||
this.tier = tier;
|
||||
this.name = name;
|
||||
this.maxInput = maxInput;
|
||||
this.maxOutput = maxOuput;
|
||||
this.maxStorage = maxStorage;
|
||||
}
|
||||
|
||||
|
@ -91,13 +93,23 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IEnergyProdu
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!worldObj.isRemote && getEnergy() > 0) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
double disposed = emitEnergy(getFacingEnum(), maxOutput);
|
||||
if (maxOutput != 0 && disposed != 0) useEnergy(disposed);
|
||||
for(EnumFacing facing : EnumFacing.VALUES) {
|
||||
double disposed = emitEnergy(facing, maxOutput);
|
||||
if(disposed != 0) {
|
||||
maxOutput -= disposed;
|
||||
useEnergy(disposed);
|
||||
if (maxOutput == 0) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO move to RebornCore
|
||||
public double emitEnergy(EnumFacing enumFacing, double amount) {
|
||||
BlockPos pos = getPos().offset(enumFacing);
|
||||
EnergyUtils.PowerNetReceiver receiver = EnergyUtils.getReceiver(
|
||||
|
@ -108,16 +120,6 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IEnergyProdu
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacingEnum() == direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(EnumFacing enumFacing) {
|
||||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
|
||||
|
|
|
@ -9,7 +9,7 @@ import techreborn.init.ModBlocks;
|
|||
public class TileMFE extends TileEnergyStorage {
|
||||
|
||||
public TileMFE() {
|
||||
super("MFE", 2, ModBlocks.mfe, EnumPowerTier.HIGH, 4000000);
|
||||
super("MFE", 2, ModBlocks.mfe, EnumPowerTier.MEDIUM, 512, 512, 4000000);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,7 +9,7 @@ import techreborn.init.ModBlocks;
|
|||
public class TileMFSU extends TileEnergyStorage {
|
||||
|
||||
public TileMFSU() {
|
||||
super("MFSU", 2, ModBlocks.mfsu, EnumPowerTier.EXTREME, 40000000);
|
||||
super("MFSU", 2, ModBlocks.mfsu, EnumPowerTier.HIGH, 2048, 2048, 40000000);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue