Some clean up of some code
This commit is contained in:
parent
9e4151f5fa
commit
43da219936
7 changed files with 171 additions and 169 deletions
|
@ -1,6 +1,9 @@
|
||||||
package techreborn.client.container;
|
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.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import techreborn.tiles.idsu.TileIDSU;
|
import techreborn.tiles.idsu.TileIDSU;
|
||||||
|
|
||||||
|
@ -12,74 +15,76 @@ public class ContainerIDSU extends TechRebornContainer {
|
||||||
TileIDSU tile;
|
TileIDSU tile;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player)
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int euOut;
|
public int euOut;
|
||||||
public int storedEu;
|
public int storedEu;
|
||||||
public int euChange;
|
public int euChange;
|
||||||
|
public int channel;
|
||||||
|
|
||||||
public ContainerIDSU(TileIDSU tileIDSU,
|
public ContainerIDSU(TileIDSU tileIDSU,
|
||||||
EntityPlayer player)
|
EntityPlayer player) {
|
||||||
{
|
|
||||||
tile = tileIDSU;
|
tile = tileIDSU;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i)
|
for (i = 0; i < 3; ++i) {
|
||||||
{
|
for (int j = 0; j < 9; ++j) {
|
||||||
for (int j = 0; j < 9; ++j)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||||
+ 9, 7 + j * 16, 84 + i * 18 + 30));
|
+ 9, 7 + j * 16, 84 + i * 18 + 30));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 9; ++i)
|
for (i = 0; i < 9; ++i) {
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(player.inventory, i, 7 + i * 16,
|
this.addSlotToContainer(new Slot(player.inventory, i, 7 + i * 16,
|
||||||
142 + 30));
|
142 + 30));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void detectAndSendChanges() {
|
public void detectAndSendChanges() {
|
||||||
// super.detectAndSendChanges();
|
super.detectAndSendChanges();
|
||||||
// for (int i = 0; i < this.crafters.size(); i++) {
|
for (int i = 0; i < this.crafters.size(); i++) {
|
||||||
// ICrafting icrafting = (ICrafting)this.crafters.get(i);
|
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||||
// if(this.euOut != tile.output){
|
if (this.euOut != tile.output) {
|
||||||
// icrafting.sendProgressBarUpdate(this, 0, tile.output);
|
icrafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||||
// }
|
}
|
||||||
// if(this.storedEu != tile.energy){
|
if (this.storedEu != (int) tile.getEnergy()) {
|
||||||
// icrafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
|
icrafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
||||||
// }
|
}
|
||||||
// if(this.euChange != tile.getEuChange() && tile.getEuChange() != -1){
|
if (this.euChange != tile.getEuChange() && tile.getEuChange() != -1) {
|
||||||
// icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||||
// }
|
}
|
||||||
// }
|
if (this.channel != tile.channelID) {
|
||||||
// }
|
icrafting.sendProgressBarUpdate(this, 3, tile.channelID);
|
||||||
//
|
}
|
||||||
// @Override
|
}
|
||||||
// public void addCraftingToCrafters(ICrafting crafting) {
|
}
|
||||||
// super.addCraftingToCrafters(crafting);
|
|
||||||
// crafting.sendProgressBarUpdate(this, 0, tile.output);
|
@Override
|
||||||
// crafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
|
public void addCraftingToCrafters(ICrafting crafting) {
|
||||||
// crafting.sendProgressBarUpdate(this, 2 , (int) tile.getEuChange());
|
super.addCraftingToCrafters(crafting);
|
||||||
// }
|
crafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||||
//
|
crafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
||||||
// @SideOnly(Side.CLIENT)
|
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||||
// @Override
|
crafting.sendProgressBarUpdate(this, 3, tile.channelID);
|
||||||
// public void updateProgressBar(int id, int value) {
|
}
|
||||||
// if(id == 0){
|
|
||||||
// this.euOut = value;
|
@SideOnly(Side.CLIENT)
|
||||||
// } else if(id == 1){
|
@Override
|
||||||
// this.storedEu = value;
|
public void updateProgressBar(int id, int value) {
|
||||||
// } else if(id == 2){
|
if (id == 0) {
|
||||||
// this.euChange = value;
|
this.euOut = value;
|
||||||
// }
|
} else if (id == 1) {
|
||||||
// }
|
this.storedEu = value;
|
||||||
|
} else if (id == 2) {
|
||||||
|
this.euChange = value;
|
||||||
|
} else if (id == 3) {
|
||||||
|
this.channel = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,25 +4,16 @@ import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import techreborn.client.container.ContainerIDSU;
|
import techreborn.client.container.ContainerIDSU;
|
||||||
import techreborn.client.gui.componets.TabIDConfig;
|
|
||||||
import techreborn.cofhLib.gui.GuiBase;
|
import techreborn.cofhLib.gui.GuiBase;
|
||||||
import techreborn.cofhLib.gui.element.ElementListBox;
|
import techreborn.cofhLib.gui.element.ElementListBox;
|
||||||
import techreborn.cofhLib.gui.element.ElementTextField;
|
import techreborn.cofhLib.gui.element.ElementTextField;
|
||||||
import techreborn.cofhLib.gui.element.ElementTextFieldLimited;
|
import techreborn.cofhLib.gui.element.ElementTextFieldLimited;
|
||||||
import techreborn.cofhLib.gui.element.listbox.IListBoxElement;
|
|
||||||
import techreborn.cofhLib.gui.element.listbox.ListBoxElementText;
|
|
||||||
import techreborn.packets.PacketHandler;
|
import techreborn.packets.PacketHandler;
|
||||||
import techreborn.packets.PacketIdsu;
|
import techreborn.packets.PacketIdsu;
|
||||||
import techreborn.tiles.idsu.ClientSideIDSUManager;
|
|
||||||
import techreborn.tiles.idsu.IDSUManager;
|
|
||||||
import techreborn.tiles.idsu.TileIDSU;
|
import techreborn.tiles.idsu.TileIDSU;
|
||||||
import techreborn.util.LogHelper;
|
import techreborn.util.LogHelper;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiIDSU extends GuiBase {
|
public class GuiIDSU extends GuiBase {
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,15 +27,13 @@ public class GuiIDSU extends GuiBase {
|
||||||
ElementTextField nameFeild;
|
ElementTextField nameFeild;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GuiIDSU(EntityPlayer player,
|
public GuiIDSU(EntityPlayer player,
|
||||||
TileIDSU tileIDSU)
|
TileIDSU tileIDSU) {
|
||||||
{
|
|
||||||
super(new ContainerIDSU(tileIDSU, player));
|
super(new ContainerIDSU(tileIDSU, player));
|
||||||
this.xSize = 156;
|
this.xSize = 156;
|
||||||
this.ySize = 200;
|
this.ySize = 200;
|
||||||
idsu = tileIDSU;
|
idsu = tileIDSU;
|
||||||
this.containerIDSU = (ContainerIDSU) this.inventorySlots;
|
this.containerIDSU = (ContainerIDSU) this.inventorySlots;
|
||||||
texture = new ResourceLocation(
|
texture = new ResourceLocation(
|
||||||
"techreborn", "textures/gui/aesu.png");
|
"techreborn", "textures/gui/aesu.png");
|
||||||
drawTitle = false;
|
drawTitle = false;
|
||||||
|
@ -60,17 +49,18 @@ public class GuiIDSU extends GuiBase {
|
||||||
int l = (this.height - this.ySize) / 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(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(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(2, k + 96, l + 8 + (22 * 2), 18, 20, "-"));
|
||||||
this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22*3), 18, 20, "--"));
|
this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22 * 3), 18, 20, "--"));
|
||||||
this.buttonList.add(new GuiButton(4, k + 40, l + 10, 10, 10, "+"));
|
this.buttonList.add(new GuiButton(4, k + 40, l + 10, 10, 10, "+"));
|
||||||
|
|
||||||
listBox.gui = this;
|
listBox.gui = this;
|
||||||
|
listBox.setSelectedIndex(containerIDSU.channel);
|
||||||
|
|
||||||
// listBox.borderColor = new GuiColor(120, 120, 120, 0).getColor();
|
// listBox.borderColor = new GuiColor(120, 120, 120, 0).getColor();
|
||||||
// listBox.backgroundColor = new GuiColor(0, 0, 0, 32).getColor();
|
// listBox.backgroundColor = new GuiColor(0, 0, 0, 32).getColor();
|
||||||
addElement(listBox);
|
addElement(listBox);
|
||||||
|
|
||||||
idFeild = new ElementTextFieldLimited(this, 10, 10, 30, 10, (short) 4);
|
idFeild = new ElementTextFieldLimited(this, 10, 10, 30, 10, (short) 4);
|
||||||
idFeild.setFilter("1234567890", false);
|
idFeild.setFilter("1234567890", false);
|
||||||
|
|
||||||
addElement(idFeild);
|
addElement(idFeild);
|
||||||
|
@ -87,7 +77,7 @@ public class GuiIDSU extends GuiBase {
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button) {
|
protected void actionPerformed(GuiButton button) {
|
||||||
super.actionPerformed(button);
|
super.actionPerformed(button);
|
||||||
if(isInteger(idFeild.getText())){
|
if (isInteger(idFeild.getText())) {
|
||||||
PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), nameFeild.getText()));
|
PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), nameFeild.getText()));
|
||||||
} else {
|
} else {
|
||||||
LogHelper.info("There was an issue in the gui!, Please report this to the TechReborn Devs");
|
LogHelper.info("There was an issue in the gui!, Please report this to the TechReborn Devs");
|
||||||
|
@ -96,17 +86,17 @@ public class GuiIDSU extends GuiBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInteger(String s) {
|
public static boolean isInteger(String s) {
|
||||||
return isInteger(s,10);
|
return isInteger(s, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInteger(String s, int radix) {
|
public static boolean isInteger(String s, int radix) {
|
||||||
if(s.isEmpty()) return false;
|
if (s.isEmpty()) return false;
|
||||||
for(int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
if(i == 0 && s.charAt(i) == '-') {
|
if (i == 0 && s.charAt(i) == '-') {
|
||||||
if(s.length() == 1) return false;
|
if (s.length() == 1) return false;
|
||||||
else continue;
|
else continue;
|
||||||
}
|
}
|
||||||
if(Character.digit(s.charAt(i),radix) < 0) return false;
|
if (Character.digit(s.charAt(i), radix) < 0) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ public class TechRebornDevCommand extends CommandBase {
|
||||||
@Override
|
@Override
|
||||||
public void processCommand(ICommandSender sender, String[] args) {
|
public void processCommand(ICommandSender sender, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.addChatMessage(new ChatComponentText("You need to use arguments"));
|
sender.addChatMessage(new ChatComponentText("You need to use arguments, see /trdev help"));
|
||||||
} else if ("help".equals(args[0])) {
|
} else if ("help".equals(args[0])) {
|
||||||
sender.addChatMessage(new ChatComponentText("recipes - Shows size of the recipe array"));
|
sender.addChatMessage(new ChatComponentText("recipes - Shows size of the recipe array"));
|
||||||
sender.addChatMessage(new ChatComponentText("idsu - Resyncs the idsu server instance to the senders client"));
|
sender.addChatMessage(new ChatComponentText("idsu - Resyncs the idsu server instance to the senders client"));
|
||||||
} else if ("recipes".equals(args[0])) {
|
} else if ("recipes".equals(args[0])) {
|
||||||
sender.addChatMessage(new ChatComponentText(RecipeHandler.recipeList.size() + " recipes loaded"));
|
sender.addChatMessage(new ChatComponentText(RecipeHandler.recipeList.size() + " recipes loaded"));
|
||||||
} else if ("idsu".equals(args[0])){
|
} else if ("idsu".equals(args[0])){
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class PacketSendIDSUManager extends SimplePacket {
|
||||||
@Override
|
@Override
|
||||||
public void readData(ByteBuf in) throws IOException {
|
public void readData(ByteBuf in) throws IOException {
|
||||||
PacketBuffer buffer = new PacketBuffer(in);
|
PacketBuffer buffer = new PacketBuffer(in);
|
||||||
json = buffer.readStringFromBuffer(99999999);
|
json = buffer.readStringFromBuffer(Integer.MAX_VALUE / 4);
|
||||||
player = readPlayer(in);
|
player = readPlayer(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,18 +44,16 @@ public class PacketSendIDSUManager extends SimplePacket {
|
||||||
if(player.worldObj != null){
|
if(player.worldObj != null){
|
||||||
GuiIDSU.listBox._elements.clear();
|
GuiIDSU.listBox._elements.clear();
|
||||||
for(World world : ClientSideIDSUManager.CLIENT.worldData.keySet()){
|
for(World world : ClientSideIDSUManager.CLIENT.worldData.keySet()){
|
||||||
// System.out.println(world.n + ":" + idsu.getWorldObj().getProviderName());
|
|
||||||
//if(world.getProviderName().equals(idsu.getWorldObj().getProviderName())){
|
|
||||||
IDSUManager.IDSUWorldSaveData saveData = ClientSideIDSUManager.CLIENT.getWorldDataFormWorld(world);
|
IDSUManager.IDSUWorldSaveData saveData = ClientSideIDSUManager.CLIENT.getWorldDataFormWorld(world);
|
||||||
for(Integer id : saveData.idsuValues.keySet()){
|
for(Integer id : saveData.idsuValues.keySet()){
|
||||||
IDSUManager.IDSUValueSaveData valueSaveData = saveData.idsuValues.get(id);
|
IDSUManager.IDSUValueSaveData valueSaveData = saveData.idsuValues.get(id);
|
||||||
|
System.out.println("added " + valueSaveData.name + " - " + id);
|
||||||
if(!valueSaveData.name.isEmpty()){
|
if(!valueSaveData.name.isEmpty()){
|
||||||
GuiIDSU.listBox._elements.add(new ListBoxElementText(valueSaveData.name + " - " + id));
|
GuiIDSU.listBox._elements.add(new ListBoxElementText(valueSaveData.name + " - " + id));
|
||||||
} else {
|
} else {
|
||||||
GuiIDSU.listBox._elements.add(new ListBoxElementText(id.toString()));
|
GuiIDSU.listBox._elements.add(new ListBoxElementText(id.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class ClientSideIDSUManager {
|
||||||
public static IDSUManager CLIENT = new IDSUManager();
|
public static IDSUManager CLIENT = new IDSUManager();
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
public void worldLoad(WorldEvent.Load event){
|
public void worldLoad(WorldEvent.Load event) {
|
||||||
CLIENT = new IDSUManager();
|
CLIENT = new IDSUManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.storage.ISaveHandler;
|
import net.minecraft.world.storage.ISaveHandler;
|
||||||
|
@ -25,40 +23,38 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
public class IDSUManager {
|
public class IDSUManager {
|
||||||
|
|
||||||
|
|
||||||
public static IDSUManager INSTANCE;
|
public static IDSUManager INSTANCE;
|
||||||
|
|
||||||
|
public static final String savename = "idsu.json";
|
||||||
|
|
||||||
public HashMap<World, IDSUWorldSaveData> worldData = new HashMap<World, IDSUWorldSaveData>();
|
public HashMap<World, IDSUWorldSaveData> worldData = new HashMap<World, IDSUWorldSaveData>();
|
||||||
|
|
||||||
//@SideOnly(Side.SERVER)
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
public void worldSave(WorldEvent.Save event){
|
public void worldSave(WorldEvent.Save event) {
|
||||||
if(event.world != null && event.world.getSaveHandler() != null && event.world.getSaveHandler().getWorldDirectory() != null){
|
if (event.world != null && event.world.getSaveHandler() != null && event.world.getSaveHandler().getWorldDirectory() != null) {
|
||||||
if(worldData.containsKey(event.world)){
|
if (worldData.containsKey(event.world)) {
|
||||||
worldData.get(event.world).save();
|
worldData.get(event.world).save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SideOnly(Side.SERVER)
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
public void worldLoad(WorldEvent.Load event){
|
public void worldLoad(WorldEvent.Load event) {
|
||||||
if(event.world != null && event.world.getSaveHandler() != null && event.world.getSaveHandler().getWorldDirectory() != null){
|
if (event.world != null && event.world.getSaveHandler() != null && event.world.getSaveHandler().getWorldDirectory() != null) {
|
||||||
if(worldData.containsKey(event.world)){
|
if (worldData.containsKey(event.world)) {
|
||||||
worldData.get(event.world).load();
|
worldData.get(event.world).load();
|
||||||
} else {
|
} else {
|
||||||
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(event.world);
|
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(event.world);
|
||||||
worldData.put(event.world ,worldSaveData);
|
worldData.put(event.world, worldSaveData);
|
||||||
worldSaveData.load();
|
worldSaveData.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SideOnly(Side.SERVER)
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||||
public void worldClosed(WorldEvent.Unload event){
|
public void worldClosed(WorldEvent.Unload event) {
|
||||||
if(event.world != null && event.world.getSaveHandler() != null && event.world.getSaveHandler().getWorldDirectory() != null){
|
if (event.world != null && event.world.getSaveHandler() != null && event.world.getSaveHandler().getWorldDirectory() != null) {
|
||||||
if(worldData.containsKey(event.world)){
|
if (worldData.containsKey(event.world)) {
|
||||||
worldData.get(event.world).save();
|
worldData.get(event.world).save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,59 +62,54 @@ public class IDSUManager {
|
||||||
worldData.clear();
|
worldData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDSUValueSaveData getSaveDataForWorld(World world, int channel){
|
public IDSUValueSaveData getSaveDataForWorld(World world, int channel) {
|
||||||
if(worldData.containsKey(world)){
|
if (worldData.containsKey(world)) {
|
||||||
return worldData.get(world).getSaves(channel);
|
return worldData.get(world).getSaves(channel);
|
||||||
} else {
|
} else {
|
||||||
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
|
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
|
||||||
worldData.put(world ,worldSaveData);
|
worldData.put(world, worldSaveData);
|
||||||
worldSaveData.load();
|
worldSaveData.load();
|
||||||
return worldSaveData.getSaves(channel);
|
return worldSaveData.getSaves(channel);
|
||||||
}
|
}
|
||||||
//LogHelper.fatal("FAILED TO GET SAVEDATA!!! This should NEVER have been called, report to TechReborn DEV!");
|
|
||||||
//return new IDSUValueSaveData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IDSUWorldSaveData getWorldDataFormWorld(World world){
|
public IDSUWorldSaveData getWorldDataFormWorld(World world) {
|
||||||
//System.out.println(world);
|
if (worldData.containsKey(world)) {
|
||||||
if(worldData.containsKey(world)){
|
|
||||||
return worldData.get(world);
|
return worldData.get(world);
|
||||||
} else {
|
} else {
|
||||||
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
|
IDSUWorldSaveData worldSaveData = new IDSUWorldSaveData(world);
|
||||||
worldData.put(world ,worldSaveData);
|
worldData.put(world, worldSaveData);
|
||||||
worldSaveData.load();
|
worldSaveData.load();
|
||||||
return worldSaveData;
|
return worldSaveData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SideOnly(Side.SERVER)
|
public PacketSendIDSUManager getPacket(World world, EntityPlayer player) {
|
||||||
public PacketSendIDSUManager getPacket(World world, EntityPlayer player){
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(getWorldDataFormWorld(world).idsuValues);
|
String json = gson.toJson(getWorldDataFormWorld(world).idsuValues);
|
||||||
if(getWorldDataFormWorld(world).idsuValues.isEmpty()){
|
if (getWorldDataFormWorld(world).idsuValues.isEmpty()) {
|
||||||
json = "EMPTY";
|
json = "EMPTY";
|
||||||
}
|
}
|
||||||
return new PacketSendIDSUManager(json, player);
|
return new PacketSendIDSUManager(json, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SideOnly(Side.CLIENT)
|
public void loadFromString(String json, World world) {
|
||||||
public void loadFromString(String json, World world){
|
if (json.equals("EMPTY")) {
|
||||||
if(json.equals("EMPTY")){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IDSUWorldSaveData worldSaveData;
|
IDSUWorldSaveData worldSaveData;
|
||||||
if(worldData.containsKey(world)){
|
if (worldData.containsKey(world)) {
|
||||||
worldSaveData = worldData.get(world);
|
worldSaveData = worldData.get(world);
|
||||||
} else {
|
} else {
|
||||||
worldSaveData = new IDSUWorldSaveData(world);
|
worldSaveData = new IDSUWorldSaveData(world);
|
||||||
worldData.put(world ,worldSaveData);
|
worldData.put(world, worldSaveData);
|
||||||
}
|
}
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>() { }.getType();
|
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>() {
|
||||||
|
}.getType();
|
||||||
worldSaveData.idsuValues.clear();
|
worldSaveData.idsuValues.clear();
|
||||||
worldSaveData.idsuValues = gson.fromJson(json, typeOfHashMap);
|
worldSaveData.idsuValues = gson.fromJson(json, typeOfHashMap);
|
||||||
//System.out.println(world);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,11 +129,11 @@ public class IDSUManager {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.saveHandler = world.getSaveHandler();
|
this.saveHandler = world.getSaveHandler();
|
||||||
folder = new File(saveHandler.getWorldDirectory(), "idsuData");
|
folder = new File(saveHandler.getWorldDirectory(), "idsuData");
|
||||||
file = new File(folder,"idsu.json");
|
file = new File(folder, savename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDSUValueSaveData getSaves(int i){
|
public IDSUValueSaveData getSaves(int i) {
|
||||||
if(idsuValues.containsKey(i)){
|
if (idsuValues.containsKey(i)) {
|
||||||
return idsuValues.get(i);
|
return idsuValues.get(i);
|
||||||
} else {
|
} else {
|
||||||
IDSUValueSaveData data = new IDSUValueSaveData();
|
IDSUValueSaveData data = new IDSUValueSaveData();
|
||||||
|
@ -151,15 +142,15 @@ public class IDSUManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SideOnly(Side.SERVER)
|
public void load() {
|
||||||
public void load(){
|
if (!file.exists()) {
|
||||||
if(!file.exists()){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>() { }.getType();
|
Type typeOfHashMap = new TypeToken<TreeMap<Integer, IDSUValueSaveData>>() {
|
||||||
|
}.getType();
|
||||||
idsuValues.clear();
|
idsuValues.clear();
|
||||||
idsuValues = gson.fromJson(reader, typeOfHashMap);
|
idsuValues = gson.fromJson(reader, typeOfHashMap);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -167,13 +158,12 @@ public class IDSUManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@SideOnly(Side.SERVER)
|
public void save() {
|
||||||
public void save(){
|
if (idsuValues.isEmpty()) {
|
||||||
if(idsuValues.isEmpty()){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!file.exists()){
|
if (!file.exists()) {
|
||||||
if(!folder.exists()){
|
if (!folder.exists()) {
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package techreborn.tiles.idsu;
|
package techreborn.tiles.idsu;
|
||||||
|
|
||||||
import ic2.api.energy.EnergyNet;
|
|
||||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||||
import ic2.api.energy.tile.IEnergySink;
|
import ic2.api.energy.tile.IEnergySink;
|
||||||
|
@ -9,10 +8,6 @@ import ic2.api.network.INetworkClientTileEntityEventListener;
|
||||||
import ic2.api.tile.IEnergyStorage;
|
import ic2.api.tile.IEnergyStorage;
|
||||||
import ic2.core.IC2;
|
import ic2.core.IC2;
|
||||||
import ic2.core.block.TileEntityBlock;
|
import ic2.core.block.TileEntityBlock;
|
||||||
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.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -20,6 +15,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import techreborn.config.ConfigTechReborn;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
import techreborn.packets.PacketHandler;
|
import techreborn.packets.PacketHandler;
|
||||||
|
|
||||||
public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySource, INetworkClientTileEntityEventListener, IEnergyStorage {
|
public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySource, INetworkClientTileEntityEventListener, IEnergyStorage {
|
||||||
|
@ -27,21 +24,21 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
public int channelID = 0;
|
public int channelID = 0;
|
||||||
|
|
||||||
public void handleGuiInputFromClient(int buttonID, int channel, EntityPlayer player, String name) {
|
public void handleGuiInputFromClient(int buttonID, int channel, EntityPlayer player, String name) {
|
||||||
if(buttonID == 4){
|
if (buttonID == 4) {
|
||||||
channelID = channel;
|
channelID = channel;
|
||||||
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name;
|
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channel).name = name;
|
||||||
IDSUManager.INSTANCE.getWorldDataFormWorld(worldObj).save();
|
IDSUManager.INSTANCE.getWorldDataFormWorld(worldObj).save();
|
||||||
if(worldObj.isRemote){
|
if (worldObj.isRemote) {
|
||||||
PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(worldObj, player), player);
|
PacketHandler.sendPacketToPlayer(IDSUManager.INSTANCE.getPacket(worldObj, player), player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEnergy(){
|
public double getEnergy() {
|
||||||
return IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channelID).storedPower;
|
return IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channelID).storedPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(double energy){
|
public void setEnergy(double energy) {
|
||||||
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channelID).storedPower = energy;
|
IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, channelID).storedPower = energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +51,9 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
private boolean isEmittingRedstone = false;
|
private boolean isEmittingRedstone = false;
|
||||||
private int redstoneUpdateInhibit = 5;
|
private int redstoneUpdateInhibit = 5;
|
||||||
public boolean addedToEnergyNet = false;
|
public boolean addedToEnergyNet = false;
|
||||||
|
private double euLastTick = 0;
|
||||||
|
private double euChange;
|
||||||
|
private int ticks;
|
||||||
|
|
||||||
public TileIDSU(int tier1, int output1, int maxStorage1) {
|
public TileIDSU(int tier1, int output1, int maxStorage1) {
|
||||||
this.tier = tier1;
|
this.tier = tier1;
|
||||||
|
@ -62,8 +62,8 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getChargeLevel() {
|
public float getChargeLevel() {
|
||||||
float ret = (float)this.getEnergy() / (float)this.maxStorage;
|
float ret = (float) this.getEnergy() / (float) this.maxStorage;
|
||||||
if(ret > 1.0F) {
|
if (ret > 1.0F) {
|
||||||
ret = 1.0F;
|
ret = 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,19 +72,19 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
super.readFromNBT(nbttagcompound);
|
super.readFromNBT(nbttagcompound);
|
||||||
setEnergy(Util.limit(nbttagcompound.getDouble("energy"), 0.0D, (double) this.maxStorage + EnergyNet.instance.getPowerFromTier(this.tier)));
|
|
||||||
this.redstoneMode = nbttagcompound.getByte("redstoneMode");
|
this.redstoneMode = nbttagcompound.getByte("redstoneMode");
|
||||||
|
this.channelID = nbttagcompound.getInteger("channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||||
super.writeToNBT(nbttagcompound);
|
super.writeToNBT(nbttagcompound);
|
||||||
nbttagcompound.setDouble("energy", this.getEnergy());
|
|
||||||
nbttagcompound.setByte("redstoneMode", this.redstoneMode);
|
nbttagcompound.setByte("redstoneMode", this.redstoneMode);
|
||||||
|
nbttagcompound.setInteger("channel", this.channelID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoaded() {
|
public void onLoaded() {
|
||||||
super.onLoaded();
|
super.onLoaded();
|
||||||
if(IC2.platform.isSimulating()) {
|
if (IC2.platform.isSimulating()) {
|
||||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||||
this.addedToEnergyNet = true;
|
this.addedToEnergyNet = true;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUnloaded() {
|
public void onUnloaded() {
|
||||||
if(IC2.platform.isSimulating() && this.addedToEnergyNet) {
|
if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
|
||||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||||
this.addedToEnergyNet = false;
|
this.addedToEnergyNet = false;
|
||||||
}
|
}
|
||||||
|
@ -106,20 +106,35 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
|
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
|
if (ticks == ConfigTechReborn.aveargeEuOutTickTime) {
|
||||||
|
euChange = -1;
|
||||||
|
ticks = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ticks++;
|
||||||
|
euChange += getStored() - euLastTick;
|
||||||
|
if (euLastTick == getStored()) {
|
||||||
|
euChange = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
euLastTick = getStored();
|
||||||
|
|
||||||
boolean needsInvUpdate = false;
|
boolean needsInvUpdate = false;
|
||||||
|
|
||||||
if(this.redstoneMode == 5 || this.redstoneMode == 6) {
|
if (this.redstoneMode == 5 || this.redstoneMode == 6) {
|
||||||
this.hasRedstone = this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord);
|
this.hasRedstone = this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldEmitRedstone1 = this.shouldEmitRedstone();
|
boolean shouldEmitRedstone1 = this.shouldEmitRedstone();
|
||||||
if(shouldEmitRedstone1 != this.isEmittingRedstone) {
|
if (shouldEmitRedstone1 != this.isEmittingRedstone) {
|
||||||
this.isEmittingRedstone = shouldEmitRedstone1;
|
this.isEmittingRedstone = shouldEmitRedstone1;
|
||||||
this.setActive(this.isEmittingRedstone);
|
this.setActive(this.isEmittingRedstone);
|
||||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
|
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needsInvUpdate) {
|
if (needsInvUpdate) {
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +153,7 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOfferedEnergy() {
|
public double getOfferedEnergy() {
|
||||||
return this.getEnergy() >= (double)this.output && (this.redstoneMode != 5 || !this.hasRedstone) && (this.redstoneMode != 6 || !this.hasRedstone || this.getEnergy() >= (double)this.maxStorage)?Math.min(this.getEnergy(), (double)this.output):0.0D;
|
return this.getEnergy() >= (double) this.output && (this.redstoneMode != 5 || !this.hasRedstone) && (this.redstoneMode != 6 || !this.hasRedstone || this.getEnergy() >= (double) this.maxStorage) ? Math.min(this.getEnergy(), (double) this.output) : 0.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawEnergy(double amount) {
|
public void drawEnergy(double amount) {
|
||||||
|
@ -146,11 +161,11 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDemandedEnergy() {
|
public double getDemandedEnergy() {
|
||||||
return (double)this.maxStorage - this.getEnergy();
|
return (double) this.maxStorage - this.getEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
|
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
|
||||||
if(this.getEnergy() >= (double)this.maxStorage) {
|
if (this.getEnergy() >= (double) this.maxStorage) {
|
||||||
return amount;
|
return amount;
|
||||||
} else {
|
} else {
|
||||||
setEnergy(this.getEnergy() + amount);
|
setEnergy(this.getEnergy() + amount);
|
||||||
|
@ -167,7 +182,6 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void onGuiClosed(EntityPlayer entityPlayer) {
|
public void onGuiClosed(EntityPlayer entityPlayer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,12 +190,12 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacing(short facing) {
|
public void setFacing(short facing) {
|
||||||
if(this.addedToEnergyNet) {
|
if (this.addedToEnergyNet) {
|
||||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setFacing(facing);
|
super.setFacing(facing);
|
||||||
if(this.addedToEnergyNet) {
|
if (this.addedToEnergyNet) {
|
||||||
this.addedToEnergyNet = false;
|
this.addedToEnergyNet = false;
|
||||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||||
this.addedToEnergyNet = true;
|
this.addedToEnergyNet = true;
|
||||||
|
@ -191,21 +205,21 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
|
|
||||||
public boolean shouldEmitRedstone() {
|
public boolean shouldEmitRedstone() {
|
||||||
boolean shouldEmitRedstone = false;
|
boolean shouldEmitRedstone = false;
|
||||||
switch(this.redstoneMode) {
|
switch (this.redstoneMode) {
|
||||||
case 1:
|
case 1:
|
||||||
shouldEmitRedstone = this.getEnergy() >= (double)(this.maxStorage - this.output * 20);
|
shouldEmitRedstone = this.getEnergy() >= (double) (this.maxStorage - this.output * 20);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
shouldEmitRedstone = this.getEnergy() > (double)this.output && this.getEnergy() < (double)this.maxStorage;
|
shouldEmitRedstone = this.getEnergy() > (double) this.output && this.getEnergy() < (double) this.maxStorage;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
shouldEmitRedstone = this.getEnergy() > (double)this.output && this.getEnergy() < (double)this.maxStorage || this.getEnergy() < (double)this.output;
|
shouldEmitRedstone = this.getEnergy() > (double) this.output && this.getEnergy() < (double) this.maxStorage || this.getEnergy() < (double) this.output;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
shouldEmitRedstone = this.getEnergy() < (double)this.output;
|
shouldEmitRedstone = this.getEnergy() < (double) this.output;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isEmittingRedstone != shouldEmitRedstone && this.redstoneUpdateInhibit != 0) {
|
if (this.isEmittingRedstone != shouldEmitRedstone && this.redstoneUpdateInhibit != 0) {
|
||||||
--this.redstoneUpdateInhibit;
|
--this.redstoneUpdateInhibit;
|
||||||
return this.isEmittingRedstone;
|
return this.isEmittingRedstone;
|
||||||
} else {
|
} else {
|
||||||
|
@ -216,7 +230,7 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
|
|
||||||
public void onNetworkEvent(EntityPlayer player, int event) {
|
public void onNetworkEvent(EntityPlayer player, int event) {
|
||||||
++this.redstoneMode;
|
++this.redstoneMode;
|
||||||
if(this.redstoneMode >= redstoneModes) {
|
if (this.redstoneMode >= redstoneModes) {
|
||||||
this.redstoneMode = 0;
|
this.redstoneMode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,22 +238,20 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getredstoneMode() {
|
public String getredstoneMode() {
|
||||||
return this.redstoneMode <= 6 && this.redstoneMode >= 0? StatCollector.translateToLocal("ic2.EUStorage.gui.mod.redstone" + this.redstoneMode):"";
|
return this.redstoneMode <= 6 && this.redstoneMode >= 0 ? StatCollector.translateToLocal("ic2.EUStorage.gui.mod.redstone" + this.redstoneMode) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||||
ItemStack ret = super.getWrenchDrop(entityPlayer);
|
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||||
float energyRetainedInStorageBlockDrops = ConfigUtil.getFloat(MainConfig.get(), "balance/energyRetainedInStorageBlockDrops");
|
ItemStack dropStack = new ItemStack(ModBlocks.Idsu, 1);
|
||||||
if(energyRetainedInStorageBlockDrops > 0.0F) {
|
writeToNBT(tileEntity);
|
||||||
NBTTagCompound nbttagcompound = StackUtil.getOrCreateNbtData(ret);
|
dropStack.setTagCompound(new NBTTagCompound());
|
||||||
nbttagcompound.setDouble("energy", this.getEnergy() * (double)energyRetainedInStorageBlockDrops);
|
dropStack.stackTagCompound.setTag("tileEntity", tileEntity);
|
||||||
}
|
return dropStack;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStored() {
|
public int getStored() {
|
||||||
return (int)this.getEnergy();
|
return (int) this.getEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCapacity() {
|
public int getCapacity() {
|
||||||
|
@ -251,7 +263,7 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOutputEnergyUnitsPerTick() {
|
public double getOutputEnergyUnitsPerTick() {
|
||||||
return (double)this.output;
|
return (double) this.output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStored(int energy1) {
|
public void setStored(int energy1) {
|
||||||
|
@ -266,4 +278,11 @@ public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySou
|
||||||
public boolean isTeleporterCompatible(ForgeDirection side) {
|
public boolean isTeleporterCompatible(ForgeDirection side) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getEuChange() {
|
||||||
|
if (euChange == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return (euChange / ticks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue