Finished the lesu
This commit is contained in:
parent
783765676b
commit
c9c664352c
8 changed files with 484 additions and 78 deletions
|
@ -2,12 +2,15 @@ package techreborn.blocks.storage;
|
|||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
public class BlockLesu extends BlockMachineBase {
|
||||
|
@ -54,5 +57,14 @@ public class BlockLesu extends BlockMachineBase {
|
|||
return new TileLesu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z,
|
||||
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.lesuID, world, x, y,
|
||||
z);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
271
src/main/java/techreborn/blocks/storage/EUStorageTile.java
Normal file
271
src/main/java/techreborn/blocks/storage/EUStorageTile.java
Normal file
|
@ -0,0 +1,271 @@
|
|||
package techreborn.blocks.storage;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.network.INetworkClientTileEntityEventListener;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
import ic2.core.IC2;
|
||||
import ic2.core.block.TileEntityInventory;
|
||||
import ic2.core.block.invslot.InvSlot;
|
||||
import ic2.core.block.invslot.InvSlotCharge;
|
||||
import ic2.core.block.invslot.InvSlotDischarge;
|
||||
import ic2.core.init.MainConfig;
|
||||
import ic2.core.util.ConfigUtil;
|
||||
import ic2.core.util.StackUtil;
|
||||
import ic2.core.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class EUStorageTile extends TileEntityInventory implements IEnergySink, IEnergySource, INetworkClientTileEntityEventListener, IEnergyStorage {
|
||||
public int tier;
|
||||
public int output;
|
||||
public double maxStorage;
|
||||
public double energy = 0.0D;
|
||||
public boolean hasRedstone = false;
|
||||
public byte redstoneMode = 0;
|
||||
public static byte redstoneModes = 7;
|
||||
private boolean isEmittingRedstone = false;
|
||||
private int redstoneUpdateInhibit = 5;
|
||||
public boolean addedToEnergyNet = false;
|
||||
public final InvSlotCharge chargeSlot;
|
||||
public final InvSlotDischarge dischargeSlot;
|
||||
|
||||
public EUStorageTile(int tier1, int output1, int maxStorage1) {
|
||||
this.tier = tier1;
|
||||
this.output = output1;
|
||||
this.maxStorage = maxStorage1;
|
||||
this.chargeSlot = new InvSlotCharge(this, 0, tier1);
|
||||
this.dischargeSlot = new InvSlotDischarge(this, 1, tier1, InvSlot.InvSide.BOTTOM);
|
||||
}
|
||||
|
||||
public float getChargeLevel() {
|
||||
float ret = (float)this.energy / (float)this.maxStorage;
|
||||
if(ret > 1.0F) {
|
||||
ret = 1.0F;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.energy = Util.limit(nbttagcompound.getDouble("energy"), 0.0D, (double) this.maxStorage + EnergyNet.instance.getPowerFromTier(this.tier));
|
||||
this.redstoneMode = nbttagcompound.getByte("redstoneMode");
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setDouble("energy", this.energy);
|
||||
nbttagcompound.setBoolean("active", this.getActive());
|
||||
nbttagcompound.setByte("redstoneMode", this.redstoneMode);
|
||||
}
|
||||
|
||||
public void onLoaded() {
|
||||
super.onLoaded();
|
||||
if(IC2.platform.isSimulating()) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
this.addedToEnergyNet = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onUnloaded() {
|
||||
if(IC2.platform.isSimulating() && this.addedToEnergyNet) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
this.addedToEnergyNet = false;
|
||||
}
|
||||
|
||||
super.onUnloaded();
|
||||
}
|
||||
|
||||
public boolean enableUpdateEntity() {
|
||||
return IC2.platform.isSimulating();
|
||||
}
|
||||
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
boolean needsInvUpdate = false;
|
||||
double shouldEmitRedstone;
|
||||
if(this.energy >= 1.0D) {
|
||||
shouldEmitRedstone = this.chargeSlot.charge(this.energy);
|
||||
this.energy -= shouldEmitRedstone;
|
||||
needsInvUpdate = shouldEmitRedstone > 0.0D;
|
||||
}
|
||||
|
||||
if(this.getDemandedEnergy() > 0.0D && !this.dischargeSlot.isEmpty()) {
|
||||
shouldEmitRedstone = this.dischargeSlot.discharge((double)this.maxStorage - this.energy, false);
|
||||
this.energy += shouldEmitRedstone;
|
||||
needsInvUpdate = shouldEmitRedstone > 0.0D;
|
||||
}
|
||||
|
||||
if(this.redstoneMode == 5 || this.redstoneMode == 6) {
|
||||
this.hasRedstone = this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
boolean shouldEmitRedstone1 = this.shouldEmitRedstone();
|
||||
if(shouldEmitRedstone1 != this.isEmittingRedstone) {
|
||||
this.isEmittingRedstone = shouldEmitRedstone1;
|
||||
this.setActive(this.isEmittingRedstone);
|
||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
|
||||
}
|
||||
|
||||
if(needsInvUpdate) {
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
|
||||
return !this.facingMatchesDirection(direction);
|
||||
}
|
||||
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
|
||||
return this.facingMatchesDirection(direction);
|
||||
}
|
||||
|
||||
public boolean facingMatchesDirection(ForgeDirection direction) {
|
||||
return direction.ordinal() == this.getFacing();
|
||||
}
|
||||
|
||||
public double getOfferedEnergy() {
|
||||
return this.energy >= (double)this.output && (this.redstoneMode != 5 || !this.hasRedstone) && (this.redstoneMode != 6 || !this.hasRedstone || this.energy >= (double)this.maxStorage)?Math.min(this.energy, (double)this.output):0.0D;
|
||||
}
|
||||
|
||||
public void drawEnergy(double amount) {
|
||||
this.energy -= amount;
|
||||
}
|
||||
|
||||
public double getDemandedEnergy() {
|
||||
return (double)this.maxStorage - this.energy;
|
||||
}
|
||||
|
||||
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
|
||||
if(this.energy >= (double)this.maxStorage) {
|
||||
return amount;
|
||||
} else {
|
||||
this.energy += amount;
|
||||
return 0.0D;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSourceTier() {
|
||||
return this.tier;
|
||||
}
|
||||
|
||||
public int getSinkTier() {
|
||||
return this.tier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onGuiClosed(EntityPlayer entityPlayer) {
|
||||
}
|
||||
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||
return this.getFacing() != side;
|
||||
}
|
||||
|
||||
public void setFacing(short facing) {
|
||||
if(this.addedToEnergyNet) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
}
|
||||
|
||||
super.setFacing(facing);
|
||||
if(this.addedToEnergyNet) {
|
||||
this.addedToEnergyNet = false;
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
this.addedToEnergyNet = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isEmittingRedstone() {
|
||||
return this.isEmittingRedstone;
|
||||
}
|
||||
|
||||
public boolean shouldEmitRedstone() {
|
||||
boolean shouldEmitRedstone = false;
|
||||
switch(this.redstoneMode) {
|
||||
case 1:
|
||||
shouldEmitRedstone = this.energy >= (double)(this.maxStorage - this.output * 20);
|
||||
break;
|
||||
case 2:
|
||||
shouldEmitRedstone = this.energy > (double)this.output && this.energy < (double)this.maxStorage;
|
||||
break;
|
||||
case 3:
|
||||
shouldEmitRedstone = this.energy > (double)this.output && this.energy < (double)this.maxStorage || this.energy < (double)this.output;
|
||||
break;
|
||||
case 4:
|
||||
shouldEmitRedstone = this.energy < (double)this.output;
|
||||
}
|
||||
|
||||
if(this.isEmittingRedstone != shouldEmitRedstone && this.redstoneUpdateInhibit != 0) {
|
||||
--this.redstoneUpdateInhibit;
|
||||
return this.isEmittingRedstone;
|
||||
} else {
|
||||
this.redstoneUpdateInhibit = 5;
|
||||
return shouldEmitRedstone;
|
||||
}
|
||||
}
|
||||
|
||||
public void onNetworkEvent(EntityPlayer player, int event) {
|
||||
++this.redstoneMode;
|
||||
if(this.redstoneMode >= redstoneModes) {
|
||||
this.redstoneMode = 0;
|
||||
}
|
||||
|
||||
IC2.platform.messagePlayer(player, this.getredstoneMode(), new Object[0]);
|
||||
}
|
||||
|
||||
public String getredstoneMode() {
|
||||
return this.redstoneMode <= 6 && this.redstoneMode >= 0? StatCollector.translateToLocal("ic2.EUStorage.gui.mod.redstone" + this.redstoneMode):"";
|
||||
}
|
||||
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
ItemStack ret = super.getWrenchDrop(entityPlayer);
|
||||
float energyRetainedInStorageBlockDrops = ConfigUtil.getFloat(MainConfig.get(), "balance/energyRetainedInStorageBlockDrops");
|
||||
if(energyRetainedInStorageBlockDrops > 0.0F) {
|
||||
NBTTagCompound nbttagcompound = StackUtil.getOrCreateNbtData(ret);
|
||||
nbttagcompound.setDouble("energy", this.energy * (double)energyRetainedInStorageBlockDrops);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getStored() {
|
||||
return (int)this.energy;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return (int) this.maxStorage;
|
||||
}
|
||||
|
||||
public int getOutput() {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
public double getOutputEnergyUnitsPerTick() {
|
||||
return (double)this.output;
|
||||
}
|
||||
|
||||
public void setStored(int energy1) {
|
||||
this.energy = (double)energy1;
|
||||
}
|
||||
|
||||
public int addEnergy(int amount) {
|
||||
this.energy += (double)amount;
|
||||
return amount;
|
||||
}
|
||||
|
||||
public boolean isTeleporterCompatible(ForgeDirection side) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -3,57 +3,12 @@ package techreborn.client;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.container.ContainerAesu;
|
||||
import techreborn.client.container.ContainerAlloyFurnace;
|
||||
import techreborn.client.container.ContainerAlloySmelter;
|
||||
import techreborn.client.container.ContainerAssemblingMachine;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
import techreborn.client.container.ContainerCentrifuge;
|
||||
import techreborn.client.container.ContainerChemicalReactor;
|
||||
import techreborn.client.container.ContainerChunkloader;
|
||||
import techreborn.client.container.ContainerDestructoPack;
|
||||
import techreborn.client.container.ContainerDieselGenerator;
|
||||
import techreborn.client.container.ContainerGrinder;
|
||||
import techreborn.client.container.ContainerImplosionCompressor;
|
||||
import techreborn.client.container.ContainerIndustrialElectrolyzer;
|
||||
import techreborn.client.container.ContainerIndustrialSawmill;
|
||||
import techreborn.client.container.ContainerLathe;
|
||||
import techreborn.client.container.ContainerMatterFabricator;
|
||||
import techreborn.client.container.ContainerPlateCuttingMachine;
|
||||
import techreborn.client.container.ContainerQuantumChest;
|
||||
import techreborn.client.container.ContainerQuantumTank;
|
||||
import techreborn.client.container.ContainerDigitalChest;
|
||||
import techreborn.client.container.ContainerRollingMachine;
|
||||
import techreborn.client.container.ContainerThermalGenerator;
|
||||
import techreborn.client.container.ContainerSemifluidGenerator;
|
||||
import techreborn.client.container.ContainerGasTurbine;
|
||||
import techreborn.client.gui.GuiAesu;
|
||||
import techreborn.client.gui.GuiAlloyFurnace;
|
||||
import techreborn.client.gui.GuiAlloySmelter;
|
||||
import techreborn.client.gui.GuiAssemblingMachine;
|
||||
import techreborn.client.gui.GuiBlastFurnace;
|
||||
import techreborn.client.gui.GuiCentrifuge;
|
||||
import techreborn.client.gui.GuiChemicalReactor;
|
||||
import techreborn.client.gui.GuiChunkLoader;
|
||||
import techreborn.client.gui.GuiDestructoPack;
|
||||
import techreborn.client.gui.GuiDieselGenerator;
|
||||
import techreborn.client.gui.GuiGrinder;
|
||||
import techreborn.client.gui.GuiImplosionCompressor;
|
||||
import techreborn.client.gui.GuiIndustrialElectrolyzer;
|
||||
import techreborn.client.gui.GuiIndustrialSawmill;
|
||||
import techreborn.client.gui.GuiLathe;
|
||||
import techreborn.client.gui.GuiMatterFabricator;
|
||||
import techreborn.client.gui.GuiPlateCuttingMachine;
|
||||
import techreborn.client.gui.GuiQuantumChest;
|
||||
import techreborn.client.gui.GuiQuantumTank;
|
||||
import techreborn.client.gui.GuiDigitalChest;
|
||||
import techreborn.client.gui.GuiRollingMachine;
|
||||
import techreborn.client.gui.GuiThermalGenerator;
|
||||
import techreborn.client.gui.GuiSemifluidGenerator;
|
||||
import techreborn.client.gui.GuiGasTurbine;
|
||||
import techreborn.client.container.*;
|
||||
import techreborn.client.gui.*;
|
||||
import techreborn.pda.GuiPda;
|
||||
import techreborn.tiles.*;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
|
@ -82,6 +37,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
public static final int gasTurbineID = 22;
|
||||
public static final int digitalChestID = 23;
|
||||
public static final int destructoPackID = 25;
|
||||
public static final int lesuID = 26;
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
||||
|
@ -184,7 +140,9 @@ public class GuiHandler implements IGuiHandler {
|
|||
return null;
|
||||
} else if (ID == destructoPackID) {
|
||||
return new ContainerDestructoPack(player);
|
||||
}
|
||||
} else if (ID == lesuID) {
|
||||
return new ContainerLesu((TileLesu) world.getTileEntity(x, y, z), player);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -290,7 +248,9 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new GuiPda(player);
|
||||
} else if (ID == destructoPackID) {
|
||||
return new GuiDestructoPack(new ContainerDestructoPack(player));
|
||||
}
|
||||
} else if (ID == lesuID) {
|
||||
return new GuiLesu(player, (TileLesu)world.getTileEntity(x, y, z));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
102
src/main/java/techreborn/client/container/ContainerLesu.java
Normal file
102
src/main/java/techreborn/client/container/ContainerLesu.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
public class ContainerLesu extends TechRebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
TileLesu tile;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int euOut;
|
||||
public int storedEu;
|
||||
public int euChange;
|
||||
public int connectedBlocks;
|
||||
public double euStorage;
|
||||
|
||||
public ContainerLesu(TileLesu tileaesu,
|
||||
EntityPlayer player)
|
||||
{
|
||||
tile = tileaesu;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
this.addSlotToContainer(new Slot(tileaesu.inventory, 0, 116, 23));
|
||||
this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 116, 59));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 7 + j * 16, 84 + i * 18 + 30));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 7 + i * 16,
|
||||
142 + 30));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting)this.crafters.get(i);
|
||||
if(this.euOut != tile.output){
|
||||
icrafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||
}
|
||||
if(this.storedEu != tile.energy){
|
||||
icrafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
|
||||
}
|
||||
if(this.euChange != tile.getEuChange() && tile.getEuChange() != -1){
|
||||
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||
}
|
||||
if(this.connectedBlocks != tile.connectedBlocks){
|
||||
icrafting.sendProgressBarUpdate(this, 3, tile.connectedBlocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||
crafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
|
||||
crafting.sendProgressBarUpdate(this, 2 , (int) tile.getEuChange());
|
||||
crafting.sendProgressBarUpdate(this, 3 , tile.connectedBlocks);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if(id == 0){
|
||||
this.euOut = value;
|
||||
} else if(id == 1){
|
||||
this.storedEu = value;
|
||||
} else if(id == 2){
|
||||
this.euChange = value;
|
||||
} else if(id == 3){
|
||||
this.connectedBlocks = value;
|
||||
} else if(id == 4){
|
||||
this.euStorage = value;
|
||||
}
|
||||
this.euStorage = (connectedBlocks * 100000) + 1000000000;
|
||||
}
|
||||
|
||||
}
|
77
src/main/java/techreborn/client/gui/GuiLesu.java
Normal file
77
src/main/java/techreborn/client/gui/GuiLesu.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.client.container.ContainerAesu;
|
||||
import techreborn.client.container.ContainerLesu;
|
||||
import techreborn.packets.PacketAesu;
|
||||
import techreborn.packets.PacketHandler;
|
||||
import techreborn.tiles.TileAesu;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Created by Mark on 14/06/2015.
|
||||
*/
|
||||
public class GuiLesu extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(
|
||||
"techreborn", "textures/gui/aesu.png");
|
||||
|
||||
TileLesu aesu;
|
||||
|
||||
ContainerLesu containerLesu;
|
||||
|
||||
public GuiLesu(EntityPlayer player,
|
||||
TileLesu tileaesu)
|
||||
{
|
||||
super(new ContainerLesu(tileaesu, player));
|
||||
this.xSize = 156;
|
||||
this.ySize = 200;
|
||||
aesu = tileaesu;
|
||||
this.containerLesu = (ContainerLesu) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.buttonList.clear();
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.buttonList.add(new GuiButton(0, k + 96, l + 8, 18, 20, "++"));
|
||||
this.buttonList.add(new GuiButton(1, k + 96, l + 8 + 22, 18, 20, "+"));
|
||||
this.buttonList.add(new GuiButton(2, k + 96, l + 8 + (22*2), 18, 20, "-"));
|
||||
this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22*3), 18, 20, "--"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
|
||||
int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
|
||||
int p_146979_2_)
|
||||
{
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("tile.techreborn.lesu.name"), 40, 10, Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(containerLesu.euOut + " eu/tick", 10, 20, Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(containerLesu.storedEu + " eu", 10, 30, Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(containerLesu.euChange + " eu change", 10, 40, Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(containerLesu.connectedBlocks + " blocks", 10, 50, Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(containerLesu.euStorage + " max eu", 10, 60, Color.WHITE.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
PacketHandler.sendPacketToServer(new PacketAesu(button.id, aesu));
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import ic2.core.util.Util;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import techreborn.blocks.storage.EUStorageTile;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.util.Inventory;
|
||||
|
@ -14,7 +15,7 @@ import techreborn.util.LogHelper;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
|
||||
public class TileAesu extends EUStorageTile implements IWrenchable {
|
||||
|
||||
public static final int MAX_OUTPUT = 8192;
|
||||
public static final int MAX_STORAGE = 1000000000; //One billion!
|
||||
|
@ -122,18 +123,7 @@ public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
|
|||
if(OUTPUT <= -1){
|
||||
OUTPUT = 0;
|
||||
}
|
||||
|
||||
//TODO make a better way and not use reflection for this.
|
||||
try {
|
||||
Field field = getClass().getSuperclass().getDeclaredField("output");
|
||||
field.setAccessible(true);
|
||||
field.set(this, OUTPUT);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
output = OUTPUT;
|
||||
LogHelper.debug("Set output to " + getOutput());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,10 @@ public class LesuNetwork {
|
|||
|
||||
public ArrayList<TileLesuStorage> storages = new ArrayList<TileLesuStorage>();
|
||||
|
||||
public TileLesu master;
|
||||
|
||||
public void addElement(TileLesuStorage lesuStorage){
|
||||
if(!storages.contains(lesuStorage)){
|
||||
if(!storages.contains(lesuStorage) && storages.size() < 5000){
|
||||
storages.add(lesuStorage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package techreborn.tiles.lesu;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.tiles.TileAesu;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileLesu extends TileAesu {
|
||||
|
@ -28,24 +27,17 @@ public class TileLesu extends TileAesu {
|
|||
if(((TileLesuStorage) worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)).network != null){
|
||||
LesuNetwork network = ((TileLesuStorage) worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)).network;
|
||||
if(!countedNetworks.contains(network)){
|
||||
connectedBlocks += network.storages.size();
|
||||
countedNetworks.add(network);
|
||||
if(network.master == null || network.master == this){
|
||||
connectedBlocks += network.storages.size();
|
||||
countedNetworks.add(network);
|
||||
network.master = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(currentBlocks != connectedBlocks){
|
||||
try {
|
||||
Field field = getClass().getSuperclass().getSuperclass().getDeclaredField("maxStorage");
|
||||
field.setAccessible(true);
|
||||
field.set(this, (connectedBlocks * storgeBlockSize) + baseEU);
|
||||
currentBlocks = connectedBlocks;
|
||||
System.out.println("set output to " + maxStorage + " using " + connectedBlocks);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
maxStorage = (connectedBlocks * storgeBlockSize) + baseEU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue