fixed weird behavior of GUIs due to short Overflows

fixed Aqua Infused Gen not working underwater
did some changes to the reflected gens, still don't work.
This commit is contained in:
bartimaeusnek committed 2018-07-21 20:23:27 +02:00
1 parent d229201b90
commit 63f04556e2
13 files changed
+119 -202

No files matched your search

@@ -37,11 +37,11 @@ public class GuiGenerator extends GuiContainer {
if (this.tileentity.maxstorage<1000)
this.fontRendererObj.drawString(storageString + this.tileentity.storage + "/" + this.tileentity.maxstorage +"EU", 36, 22, 0);
else if (10000 <= this.tileentity.maxstorage && this.tileentity.maxstorage < 10000000)
this.fontRendererObj.drawString(storageString + (this.tileentity.storage/1000) + "/" + (this.tileentity.maxstorage/1000) +"kEU", 36, 22, 0);
this.fontRendererObj.drawString(storageString + (this.tileentity.mpshownstroage) + "/" + (this.tileentity.maxstorage/1000) +"kEU", 36, 22, 0);
else if (10000000 <= this.tileentity.maxstorage && this.tileentity.maxstorage < 1000000000)
this.fontRendererObj.drawString(storageString + (this.tileentity.storage/1000000) + "/" + (this.tileentity.maxstorage/1000000) +"MEU", 36, 22, 0);
this.fontRendererObj.drawString(storageString + (this.tileentity.mpshownstroage/1000) + "/" + (this.tileentity.maxstorage/1000000) +"MEU", 36, 22, 0);
else if (1000000000 <= this.tileentity.maxstorage)
this.fontRendererObj.drawString(storageString + (this.tileentity.storage/1000000000) + "/" + (this.tileentity.maxstorage/1000000000) +"GEU", 36, 22, 0);
this.fontRendererObj.drawString(storageString + (this.tileentity.mpshownstroage/1000000) + "/" + (this.tileentity.maxstorage/1000000000) +"GEU", 36, 22, 0);
if(this.tileentity.isActive)
this.fontRendererObj.drawString(I18n.format("emt.Generating",new Object[0])+Double.toString(this.tileentity.generating/20/20)+" EU/t", 36, 35, 0);
else
+8 -5
View File
@@ -77,12 +77,12 @@ public class GuiSolar extends GuiContainer {
int h = (this.width - this.xSize) / 2;
int k = (this.height - this.ySize) / 2;
drawTexturedModalRect(h, k, 0, 0, this.xSize, this.ySize);
if (this.tileentity.storage > 0)
if (this.tileentity.mp_storage > 0)
{
int l = this.tileentity.gaugeEnergyScaled(33);
drawTexturedModalRect(h + 18, k + 23, 195, 0, l, 14);
}
if (this.tileentity.generating>0)
if (this.tileentity.generating>9)
drawTexturedModalRect(h + 18, k + 42, 195, 20, 11, 14);
}
@@ -91,19 +91,22 @@ public class GuiSolar extends GuiContainer {
{
String formatPanelName = I18n.format(this.tileentity.getInventoryName(), new Object[0]);
int nmPos = (this.xSize - this.fontRendererObj.getStringWidth(formatPanelName)) / 2;
if(!color.equals("Terra"))
this.fontRendererObj.drawStringWithShadow(formatPanelName, 0, 7, 6618118);
else
this.fontRendererObj.drawStringWithShadow(formatPanelName, 0, 7, cColor);
String storageString = I18n.format("emt.Storage", new Object[0]);
if (this.tileentity.maxstorage<1000)
this.fontRendererObj.drawString(storageString + this.tileentity.storage + "/" + this.tileentity.maxstorage +"EU", 36, 22, 0);
else if (10000 <= this.tileentity.maxstorage && this.tileentity.maxstorage < 10000000)
this.fontRendererObj.drawString(storageString + (this.tileentity.storage/1000) + "/" + (this.tileentity.maxstorage/1000) +"kEU", 36, 22, 0);
this.fontRendererObj.drawString(storageString + (this.tileentity.mp_storage) + "/" + (this.tileentity.maxstorage/1000) +"kEU", 36, 22, 0);
else if (10000000 <= this.tileentity.maxstorage && this.tileentity.maxstorage < 1000000000)
this.fontRendererObj.drawString(storageString + (this.tileentity.storage/1000000) + "/" + (this.tileentity.maxstorage/1000000) +"MEU", 36, 22, 0);
this.fontRendererObj.drawString(storageString + (this.tileentity.mp_storage/1000) + "/" + (this.tileentity.maxstorage/1000000) +"MEU", 36, 22, 0);
else if (1000000000 <= this.tileentity.maxstorage)
this.fontRendererObj.drawString(storageString + (this.tileentity.storage/1000000000) + "/" + (this.tileentity.maxstorage/1000000000) +"GEU", 36, 22, 0);
this.fontRendererObj.drawString(storageString + (this.tileentity.mp_storage/1000000) + "/" + (this.tileentity.maxstorage/1000000000) +"GEU", 36, 22, 0);
if(this.tileentity.isActive)
if (Double.toString(this.tileentity.generating).length()>5)
this.fontRendererObj.drawString(I18n.format("emt.Generating",new Object[0])+Double.toString(this.tileentity.generating).substring(0, 4)+" EU/t", 36, 35, 0);
@@ -12,37 +12,19 @@ public class ConainerGenerator
extends Container
{
private TileEntityBaseGenerator tileentity;
public int storage;
public int fuel;
public int generating;
public ConainerGenerator(InventoryPlayer inventoryplayer, TileEntityBaseGenerator tileentity)
{
this.storage = 0;
this.fuel = 0;
this.tileentity = tileentity;
/* for (int j = 0; j < 4; j++) {
addSlotToContainer(new Slot(this.tileentity, j, 17 + j * 18, 59));
}
for (int i = 0; i < 3; i++) {
for (int k = 0; k < 9; k++) {
addSlotToContainer(new Slot(inventoryplayer, k + i * 9 + 9, 17 + k * 18, 86 + i * 18));
}
}
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryplayer, j, 17 + j * 18, 144));
}
addSlotToContainer(new Slot(this.tileentity, 5, 17 + 7 * 18, 59));*/
}
public void addCraftingToCrafters(ICrafting icrafting)
{
super.addCraftingToCrafters(icrafting);
icrafting.sendProgressBarUpdate(this, 0, (int) this.tileentity.generating);
icrafting.sendProgressBarUpdate(this, 1, this.tileentity.storage);
icrafting.sendProgressBarUpdate(this, 2, this.tileentity.fuel);
super.addCraftingToCrafters(icrafting);
icrafting.sendProgressBarUpdate(this, 0, (short) (this.tileentity.generating/400));
icrafting.sendProgressBarUpdate(this, 1, (byte) this.tileentity.fuel);
icrafting.sendProgressBarUpdate(this, 2, (short) this.tileentity.mpshownstroage);
}
public void detectAndSendChanges()
@@ -52,81 +34,35 @@ public class ConainerGenerator
{
ICrafting icrafting = (ICrafting)this.crafters.get(i);
icrafting.sendProgressBarUpdate(this, 0, (int) this.tileentity.generating);
icrafting.sendProgressBarUpdate(this, 1, this.tileentity.storage);
icrafting.sendProgressBarUpdate(this, 2, this.tileentity.fuel);
icrafting.sendProgressBarUpdate(this, 0, (short) (this.tileentity.generating/400));
icrafting.sendProgressBarUpdate(this, 1, (byte) this.tileentity.fuel);
icrafting.sendProgressBarUpdate(this, 2, (short) (this.tileentity.storage/1000));
}
this.generating = (int) this.tileentity.generating;
this.tileentity.storage = ((int)this.tileentity.energySource.getEnergyStored());
}
public void updateProgressBar(int i, int j)
{
if (i == 0) {
this.tileentity.generating = j;
this.tileentity.generating = (((int)j)*400);
}
if (i == 1) {
if (j<this.tileentity.maxstorage)
this.tileentity.storage = j;
else
this.tileentity.storage=this.tileentity.maxstorage;
this.tileentity.fuel=((byte) j);
}
if (i == 2) {
this.tileentity.fuel=j;
this.tileentity.mpshownstroage=(short) j;
}
}
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
int slot = par2;
ItemStack stack = null;
Slot slotObject = (Slot)this.inventorySlots.get(par2);
if ((slotObject != null) && (slotObject.getHasStack()))
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if ((slot >= 0) && (slot <= 3))
{
if (!mergeItemStack(stackInSlot, 4, 40, true)) {
return null;
}
}
else if ((slot >= 4) && (slot < 31))
{
if (!mergeItemStack(stackInSlot, 0, 4, false)) {
if (!mergeItemStack(stackInSlot, 31, 40, false)) {
return null;
}
}
}
else if ((slot >= 31) && (slot < 39))
{
if (!mergeItemStack(stackInSlot, 0, 30, false)) {
return null;
}
}
else if (!mergeItemStack(stackInSlot, 0, 30, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack(null);
} else {
slotObject.onSlotChanged();
}
if (stack.stackSize != stackInSlot.stackSize) {
slotObject.onPickupFromSlot(par1EntityPlayer, stackInSlot);
} else {
return null;
}
}
return stack;
return null;
}
public boolean canInteractWith(EntityPlayer entityplayer)
{
detectAndSendChanges();
this.detectAndSendChanges();
return this.tileentity.isUseableByPlayer(entityplayer);
}
}
@@ -5,121 +5,68 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerSolars
extends Container
{
private TileEntitySolarBase tileentity;
public int storage;
public ContainerSolars(InventoryPlayer inventoryplayer, TileEntitySolarBase tileentity)
{
this.storage = 0;
this.tileentity = tileentity;
/* for (int j = 0; j < 4; j++) {
addSlotToContainer(new Slot(this.tileentity, j, 17 + j * 18, 59));
}
for (int i = 0; i < 3; i++) {
for (int k = 0; k < 9; k++) {
addSlotToContainer(new Slot(inventoryplayer, k + i * 9 + 9, 17 + k * 18, 86 + i * 18));
}
}
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryplayer, j, 17 + j * 18, 144));
}
addSlotToContainer(new Slot(this.tileentity, 5, 17 + 7 * 18, 59));*/
}
public void addCraftingToCrafters(ICrafting icrafting)
{
super.addCraftingToCrafters(icrafting);
icrafting.sendProgressBarUpdate(this, 0, (int) this.tileentity.generating);
icrafting.sendProgressBarUpdate(this, 1, this.tileentity.storage);
{
super.addCraftingToCrafters(icrafting);
icrafting.sendProgressBarUpdate(this, 0, (short) this.tileentity.generating);
icrafting.sendProgressBarUpdate(this, 1, (short) this.tileentity.mp_storage);
}
public void detectAndSendChanges()
{
super.detectAndSendChanges();
float help = (float) (this.tileentity.generating*1000);
super.detectAndSendChanges();
short help = 0;
if (this.tileentity.generating < 326D && this.tileentity.generating > 9D)
help = (short) (this.tileentity.generating*100*-1);
else
help = (short) (this.tileentity.generating);
for (int i = 0; i < this.crafters.size(); i++)
{
ICrafting icrafting = (ICrafting)this.crafters.get(i);
icrafting.sendProgressBarUpdate(this, 0, (int) help);
icrafting.sendProgressBarUpdate(this, 1, this.tileentity.storage);
icrafting.sendProgressBarUpdate(this, 0, help);
icrafting.sendProgressBarUpdate(this, 1, (short) (this.tileentity.energySource.getEnergyStored()/1000));
}
this.tileentity.storage = ((int)this.tileentity.energySource.getEnergyStored());
}
public void updateProgressBar(int i, int j)
{
if (i == 0) {
float help = (float)j;
this.tileentity.generating = help/1000;
if (j < 0) {
double help= j;
help=help/100*-1;
this.tileentity.generating = help;
}
else
this.tileentity.generating=j;
}
if (i == 1) {
if (j<this.tileentity.maxstorage)
this.tileentity.storage = j;
else
this.tileentity.storage=(int) this.tileentity.maxstorage;
this.tileentity.mp_storage = (short) (j);
}
}
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
int slot = par2;
ItemStack stack = null;
Slot slotObject = (Slot)this.inventorySlots.get(par2);
if ((slotObject != null) && (slotObject.getHasStack()))
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if ((slot >= 0) && (slot <= 3))
{
if (!mergeItemStack(stackInSlot, 4, 40, true)) {
return null;
}
}
else if ((slot >= 4) && (slot < 31))
{
if (!mergeItemStack(stackInSlot, 0, 4, false)) {
if (!mergeItemStack(stackInSlot, 31, 40, false)) {
return null;
}
}
}
else if ((slot >= 31) && (slot < 39))
{
if (!mergeItemStack(stackInSlot, 0, 30, false)) {
return null;
}
}
else if (!mergeItemStack(stackInSlot, 0, 30, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack(null);
} else {
slotObject.onSlotChanged();
}
if (stack.stackSize != stackInSlot.stackSize) {
slotObject.onPickupFromSlot(par1EntityPlayer, stackInSlot);
} else {
return null;
}
}
return stack;
return null;
}
public boolean canInteractWith(EntityPlayer entityplayer)
{
detectAndSendChanges();
this.detectAndSendChanges();
return this.tileentity.isUseableByPlayer(entityplayer);
}
}