From 9055ae71d538ceef51b9ae5b50072a53a1226f94 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Mon, 5 Aug 2013 12:35:56 -0400 Subject: [PATCH] Round energy, fixed NBT, added new texture for battery when in multi block form --- .../textures/models/battery_multi.png | Bin 0 -> 2150 bytes src/resonantinduction/api/IBattery.java | 2 +- src/resonantinduction/battery/GuiBattery.java | 2 +- .../battery/ItemCapacitor.java | 15 ++++++++---- .../battery/TileEntityBattery.java | 23 +++++++++++++----- .../render/RenderBattery.java | 13 +++++++++- 6 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 resources/assets/resonantinduction/textures/models/battery_multi.png diff --git a/resources/assets/resonantinduction/textures/models/battery_multi.png b/resources/assets/resonantinduction/textures/models/battery_multi.png new file mode 100644 index 0000000000000000000000000000000000000000..58104395c4e0fd8cca28269974344f07b0b9afc3 GIT binary patch literal 2150 zcmcIm2Uio=622)$S_lDzK#(q7iIfdus7Zu?LTDD2T|lYAO5%nR;h7*xam8R%#D_{* z)`n691(c48$oc}hhy^4P3AzXf0Rn`O7uMr@Z-2l$XXehCIp55k@6J8<+&rqE7g9-A z2>^hkc#{IIIO8rds1@K}#s9styGlvg6x$$dqd_r9M2Q0-V#NaLA=NqJD0 zLEg&u!!LGg5x!MN?|h8^qq1 zG6bng`bR?iy9QE2xISW^fj*kVnLuC^7Z0#18-fSy0Jy-`F?OcV;9u-m6pwI zc%d3=#VTPFu2r?%r}TXL^+kbp)%o^C=K{E~Ayh6xMFxY>SXii)Q*-*rNDOQ0#KR35H@vIoX+OqVN(jEmp2p}fDhoX9JN*uO2Z{IF$Xl`g2%s+Li@#V|i z2IZ0by8iwE)_a%Mc_NYM>RRP*l35m3&q(yv*-8q4<$4TLFEUK*O}QjXF8Ja0FE&BZ zI>zpJJEAe=oUvkG{;el=A%#ZJ|3HSHocuc^ZeywU8$@p)40rvUF*y)s!M)dUr(Qjd zYRM$|)ET%FkQ}7%O9sSu}gl`Xxk;_eXc6 zCtByYWjq&U{A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jrWbX z`TjS3$X0&6e1~#F0{i9fe7{0Ot-?6$cOFl2mV`@ckLizt-r(<7jF3fSrGMi5Gjj 0) @@ -75,13 +81,18 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver prevStructure = structure; - if(structure != null) - { - structure.didTick = false; - } + structure.wroteInventory = false; + structure.didTick = false; } } + @Override + public void invalidate() + { + TeslaGrid.instance().unregister(this); + super.invalidate(); + } + @Override public void readFromNBT(NBTTagCompound nbtTags) { @@ -207,7 +218,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver IBattery battery = (IBattery)itemStack.getItem(); float needed = amount-added; - float itemAdd = Math.min(battery.getMaxEnergyStored()-battery.getEnergyStored(itemStack), needed); + float itemAdd = Math.min(battery.getMaxEnergyStored(itemStack)-battery.getEnergyStored(itemStack), needed); if(doAdd) { @@ -273,7 +284,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver { if (itemStack.getItem() instanceof IBattery) { - max += ((IBattery) itemStack.getItem()).getMaxEnergyStored(); + max += ((IBattery) itemStack.getItem()).getMaxEnergyStored(itemStack); } } } diff --git a/src/resonantinduction/render/RenderBattery.java b/src/resonantinduction/render/RenderBattery.java index 9d5fdfad..faa3b3a1 100644 --- a/src/resonantinduction/render/RenderBattery.java +++ b/src/resonantinduction/render/RenderBattery.java @@ -22,6 +22,7 @@ import net.minecraftforge.common.ForgeDirection; import org.lwjgl.opengl.GL11; import resonantinduction.ResonantInduction; +import resonantinduction.battery.TileEntityBattery; import resonantinduction.model.ModelBattery; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -34,6 +35,8 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderBattery extends TileEntitySpecialRenderer { public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery.png"); + public static final ResourceLocation TEXTURE_MULTI = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery_multi.png"); + public static final ModelBattery MODEL = new ModelBattery(); private EntityItem fakeBattery; private Random random = new Random(); @@ -56,7 +59,15 @@ public class RenderBattery extends TileEntitySpecialRenderer GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.func_110628_a(TEXTURE); + + if(((TileEntityBattery)t).structure.isMultiblock) + { + this.func_110628_a(TEXTURE_MULTI); + } + else { + this.func_110628_a(TEXTURE); + } + MODEL.render(0.0625f); GL11.glPopMatrix();