diff --git a/common/mekanism/common/block/BlockBasic.java b/common/mekanism/common/block/BlockBasic.java index 5c4ad405a..23625cad2 100644 --- a/common/mekanism/common/block/BlockBasic.java +++ b/common/mekanism/common/block/BlockBasic.java @@ -27,6 +27,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -260,10 +261,36 @@ public class BlockBasic extends Block { TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z); - if(entityplayer.getCurrentEquippedItem() != null) + if(bin.itemCount < bin.MAX_STORAGE) { - ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem()); - entityplayer.setCurrentItemOrArmor(0, remain); + if(bin.addTicks == 0) + { + if(entityplayer.getCurrentEquippedItem() != null) + { + ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem()); + entityplayer.setCurrentItemOrArmor(0, remain); + bin.addTicks = 5; + } + } + else { + ItemStack[] inv = entityplayer.inventory.mainInventory; + + for(int i = 0; i < inv.length; i++) + { + if(bin.itemCount == bin.MAX_STORAGE) + { + break; + } + + if(inv[i] != null) + { + ItemStack remain = bin.add(inv[i]); + inv[i] = remain; + } + + ((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory()); + } + } } return true; diff --git a/common/mekanism/common/tileentity/TileEntityBin.java b/common/mekanism/common/tileentity/TileEntityBin.java index 54a8c9798..a7d224038 100644 --- a/common/mekanism/common/tileentity/TileEntityBin.java +++ b/common/mekanism/common/tileentity/TileEntityBin.java @@ -27,6 +27,8 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento public final int MAX_DELAY = 10; + public int addTicks = 0; + public int delayTicks; public int itemCount; @@ -156,6 +158,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { if(!worldObj.isRemote) { + addTicks = Math.max(0, addTicks-1); delayTicks = Math.max(0, delayTicks-1); if(getStack() != null && isActive && delayTicks == 0) diff --git a/common/mekanism/induction/client/FXElectricBolt.java b/common/mekanism/induction/client/FXElectricBolt.java index 040529ff5..6f9fa8efe 100644 --- a/common/mekanism/induction/client/FXElectricBolt.java +++ b/common/mekanism/induction/client/FXElectricBolt.java @@ -64,22 +64,22 @@ public class FXElectricBolt extends EntityFX { super(world, startVec.x, startVec.y, startVec.z); - this.rand = new Random(); - this.start = new BoltPoint(startVec); - this.end = new BoltPoint(targetVec); + rand = new Random(); + start = new BoltPoint(startVec); + end = new BoltPoint(targetVec); - if (this.end.y == Double.POSITIVE_INFINITY) + if(end.y == Double.POSITIVE_INFINITY) { - this.end.y = Minecraft.getMinecraft().thePlayer.posY + 30; + end.y = Minecraft.getMinecraft().thePlayer.posY + 30; } /** By default, we do an electrical color */ - this.segmentCount = 1; - this.particleMaxAge = (3 + this.rand.nextInt(3) - 1); - this.complexity = 2f; - this.boltWidth = 0.05f; - this.boltLength = this.start.distance(this.end); - this.setUp(doSplits); + segmentCount = 1; + particleMaxAge = (3 + rand.nextInt(3) - 1); + complexity = 2f; + boltWidth = 0.05f; + boltLength = start.distance(end); + setUp(doSplits); } public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec) @@ -92,21 +92,21 @@ public class FXElectricBolt extends EntityFX */ private void setUp(boolean doSplits) { - this.segments.add(new BoltSegment(this.start, this.end)); - this.recalculate(); + segments.add(new BoltSegment(start, end)); + recalculate(); - if (doSplits) + if(doSplits) { - double offsetRatio = this.boltLength * this.complexity; - this.split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2); - this.split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2); - this.split(2, offsetRatio / 25, 0.5f, 0.1f, 28 / 2); - this.split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2); - this.split(2, offsetRatio / 55, 0, 0, 0); - this.split(2, offsetRatio / 70, 0, 0, 0); - this.recalculate(); + double offsetRatio = boltLength * complexity; + split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2); + split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2); + split(2, offsetRatio / 25, 0.5f, 0.1f, 28 / 2); + split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2); + split(2, offsetRatio / 55, 0, 0, 0); + split(2, offsetRatio / 70, 0, 0, 0); + recalculate(); - Collections.sort(this.segments, new Comparator() + Collections.sort(segments, new Comparator() { public int compare(BoltSegment bolt1, BoltSegment bolt2) { @@ -124,9 +124,9 @@ public class FXElectricBolt extends EntityFX public FXElectricBolt setColor(float r, float g, float b) { - this.particleRed = r + (this.rand.nextFloat() * 0.1f) - 0.1f; - this.particleGreen = g + (this.rand.nextFloat() * 0.1f) - 0.1f; - this.particleBlue = b + (this.rand.nextFloat() * 0.1f) - 0.1f; + particleRed = r + (rand.nextFloat() * 0.1f) - 0.1f; + particleGreen = g + (rand.nextFloat() * 0.1f) - 0.1f; + particleBlue = b + (rand.nextFloat() * 0.1f) - 0.1f; return this; } @@ -142,12 +142,12 @@ public class FXElectricBolt extends EntityFX public void split(int splitAmount, double offset, float splitChance, float splitLength, float splitAngle) { /** Temporarily store old segments in a new array */ - List oldSegments = this.segments; - this.segments = new ArrayList(); + List oldSegments = segments; + segments = new ArrayList(); /** Previous segment */ BoltSegment prev = null; - for (BoltSegment segment : oldSegments) + for(BoltSegment segment : oldSegments) { prev = segment.prev; /** Length of each subsegment */ @@ -165,46 +165,46 @@ public class FXElectricBolt extends EntityFX /** * Create bolt points. */ - for (int i = 1; i < splitAmount; i++) + for(int i = 1; i < splitAmount; i++) { - Vector3 newOffset = segment.difference.getPerpendicular().rotate(this.rand.nextFloat() * 360, segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset); + Vector3 newOffset = segment.difference.getPerpendicular().rotate(rand.nextFloat() * 360, segment.difference).scale((rand.nextFloat() - 0.5F) * offset); Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i)); newPoints[i] = new BoltPoint(basePoint, newOffset); } - for (int i = 0; i < splitAmount; i++) + for(int i = 0; i < splitAmount; i++) { BoltSegment next = new BoltSegment(newPoints[i], newPoints[(i + 1)], segment.alpha, segment.id * splitAmount + i, segment.splitID); next.prev = prev; - if (prev != null) + if(prev != null) { prev.next = next; } - if ((i != 0) && (this.rand.nextFloat() < splitChance)) + if((i != 0) && (rand.nextFloat() < splitChance)) { - Vector3 splitrot = next.difference.xCrossProduct().rotate(this.rand.nextFloat() * 360, next.difference); - Vector3 diff = next.difference.clone().rotate((this.rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).scale(splitLength); - this.maxSplitID += 1; - this.parentIDMap.put(this.maxSplitID, next.splitID); - BoltSegment split = new BoltSegment(newPoints[i], new BoltPoint(newPoints[(i + 1)].base, newPoints[(i + 1)].offset.clone().translate(diff)), segment.alpha / 2f, next.id, this.maxSplitID); + Vector3 splitrot = next.difference.xCrossProduct().rotate(rand.nextFloat() * 360, next.difference); + Vector3 diff = next.difference.clone().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).scale(splitLength); + maxSplitID += 1; + parentIDMap.put(maxSplitID, next.splitID); + BoltSegment split = new BoltSegment(newPoints[i], new BoltPoint(newPoints[(i + 1)].base, newPoints[(i + 1)].offset.clone().translate(diff)), segment.alpha / 2f, next.id, maxSplitID); split.prev = prev; - this.segments.add(split); + segments.add(split); } prev = next; - this.segments.add(next); + segments.add(next); } - if (segment.next != null) + if(segment.next != null) { segment.next.prev = prev; } } - this.segmentCount *= splitAmount; + segmentCount *= splitAmount; } @@ -212,15 +212,17 @@ public class FXElectricBolt extends EntityFX { HashMap lastActiveSegment = new HashMap(); - Collections.sort(this.segments, new Comparator() + Collections.sort(segments, new Comparator() { public int compare(BoltSegment o1, BoltSegment o2) { int comp = Integer.valueOf(o1.splitID).compareTo(Integer.valueOf(o2.splitID)); - if (comp == 0) + + if(comp == 0) { return Integer.valueOf(o1.id).compareTo(Integer.valueOf(o2.id)); } + return comp; } @@ -234,13 +236,13 @@ public class FXElectricBolt extends EntityFX int lastSplitCalc = 0; int lastActiveSeg = 0; - for (BoltSegment segment : this.segments) + for(BoltSegment segment : segments) { - if (segment.splitID > lastSplitCalc) + if(segment.splitID > lastSplitCalc) { lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = segment.splitID; - lastActiveSeg = lastActiveSegment.get(this.parentIDMap.get(segment.splitID)).intValue(); + lastActiveSeg = lastActiveSegment.get(parentIDMap.get(segment.splitID)).intValue(); } lastActiveSeg = segment.id; @@ -251,17 +253,17 @@ public class FXElectricBolt extends EntityFX lastActiveSeg = lastActiveSegment.get(0).intValue(); BoltSegment segment; - for (Iterator iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate()) + for(Iterator iterator = segments.iterator(); iterator.hasNext(); segment.recalculate()) { segment = iterator.next(); - if (lastSplitCalc != segment.splitID) + if(lastSplitCalc != segment.splitID) { lastSplitCalc = segment.splitID; lastActiveSeg = lastActiveSegment.get(segment.splitID); } - if (segment.id > lastActiveSeg) + if(segment.id > lastActiveSeg) { iterator.remove(); } @@ -271,13 +273,13 @@ public class FXElectricBolt extends EntityFX @Override public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; - if (this.particleAge++ >= this.particleMaxAge) + if(particleAge++ >= particleMaxAge) { - this.setDead(); + setDead(); } } @@ -304,29 +306,29 @@ public class FXElectricBolt extends EntityFX tessellator.setBrightness(15728880); Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch); - int renderlength = (int) ((this.particleAge + partialframe + (int) (this.boltLength * 3.0F)) / (int) (this.boltLength * 3.0F) * this.segmentCount); + int renderlength = (int)((particleAge + partialframe + (int)(boltLength * 3.0F)) / (int)(boltLength * 3.0F) * segmentCount); - for (BoltSegment segment : this.segments) + for(BoltSegment segment : segments) { - if (segment != null && segment.id <= renderlength) + if(segment != null && segment.id <= renderlength) { - double renderWidth = this.boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f); - renderWidth = Math.min(this.boltWidth, Math.max(renderWidth, 0)); + double renderWidth = boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f); + renderWidth = Math.min(boltWidth, Math.max(renderWidth, 0)); - if (segment.difference.getMagnitude() > 0 && segment.difference.getMagnitude() != Double.NaN && segment.difference.getMagnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY) + if(segment.difference.getMagnitude() > 0 && segment.difference.getMagnitude() != Double.NaN && segment.difference.getMagnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY) { Vector3 diffPrev = playerVector.crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev); Vector3 diffNext = playerVector.crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext); Vector3 startVec = segment.start; Vector3 endVec = segment.end; - float rx1 = (float) (startVec.x - interpPosX); - float ry1 = (float) (startVec.y - interpPosY); - float rz1 = (float) (startVec.z - interpPosZ); - float rx2 = (float) (endVec.x - interpPosX); - float ry2 = (float) (endVec.y - interpPosY); - float rz2 = (float) (endVec.z - interpPosZ); + float rx1 = (float)(startVec.x - interpPosX); + float ry1 = (float)(startVec.y - interpPosY); + float rz1 = (float)(startVec.z - interpPosZ); + float rx2 = (float)(endVec.x - interpPosX); + float ry2 = (float)(endVec.y - interpPosY); + float rz2 = (float)(endVec.z - interpPosZ); - tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, (1.0F - (this.particleAge >= 0 ? ((float) this.particleAge / (float) this.particleMaxAge) : 0.0F) * 0.6f) * segment.alpha); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, (1.0F - (particleAge >= 0 ? ((float)particleAge / (float)particleMaxAge) : 0.0F) * 0.6f) * segment.alpha); tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D); tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D); tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D); @@ -336,24 +338,24 @@ public class FXElectricBolt extends EntityFX * Render the bolts balls. */ - if (segment.next == null) + if(segment.next == null) { Vector3 roundEnd = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth)); - float rx3 = (float) (roundEnd.x - interpPosX); - float ry3 = (float) (roundEnd.y - interpPosY); - float rz3 = (float) (roundEnd.z - interpPosZ); + float rx3 = (float)(roundEnd.x - interpPosX); + float ry3 = (float)(roundEnd.y - interpPosY); + float rz3 = (float)(roundEnd.z - interpPosZ); tessellator.addVertexWithUV(rx3 - diffNext.x, ry3 - diffNext.y, rz3 - diffNext.z, 0.0D, 0.0D); tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D); tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D); tessellator.addVertexWithUV(rx3 + diffNext.x, ry3 + diffNext.y, rz3 + diffNext.z, 0.0D, 1.0D); } - if (segment.prev == null) + if(segment.prev == null) { Vector3 roundEnd = segment.start.clone().difference(segment.difference.clone().normalize().scale(renderWidth)); - float rx3 = (float) (roundEnd.x - interpPosX); - float ry3 = (float) (roundEnd.y - interpPosY); - float rz3 = (float) (roundEnd.z - interpPosZ); + float rx3 = (float)(roundEnd.x - interpPosX); + float ry3 = (float)(roundEnd.y - interpPosY); + float rz3 = (float)(roundEnd.z - interpPosZ); tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D); tessellator.addVertexWithUV(rx3 - diffPrev.x, ry3 - diffPrev.y, rz3 - diffPrev.z, 0.0D, 0.0D); tessellator.addVertexWithUV(rx3 + diffPrev.x, ry3 + diffPrev.y, rz3 + diffPrev.z, 0.0D, 1.0D); @@ -379,11 +381,11 @@ public class FXElectricBolt extends EntityFX public Vector3 base; public Vector3 offset; - public BoltPoint(Vector3 base, Vector3 offset) + public BoltPoint(Vector3 b, Vector3 o) { - super(base.clone().translate(offset)); - this.base = base; - this.offset = offset; + super(b.clone().translate(o)); + base = b; + offset = o; } public BoltPoint(Vector3 base) @@ -416,42 +418,40 @@ public class FXElectricBolt extends EntityFX this(start, end, 1, 0, 0); } - public BoltSegment(BoltPoint start, BoltPoint end, float alpha, int id, int splitID) + public BoltSegment(BoltPoint s, BoltPoint e, float a, int i, int id) { - this.start = start; - this.end = end; - this.alpha = alpha; - this.id = id; - this.splitID = splitID; - this.difference = this.end.clone().difference(this.start); + start = s; + end = e; + alpha = a; + id = i; + splitID = id; + difference = end.clone().difference(start); } public void recalculate() { - if (this.prev != null) + if(prev != null) { - Vector3 prevDiffNorm = this.prev.difference.clone().normalize(); - Vector3 diffNorm = this.difference.clone().normalize(); - this.prevDiff = diffNorm.clone().translate(prevDiffNorm).normalize(); - this.sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2); + Vector3 prevDiffNorm = prev.difference.clone().normalize(); + Vector3 diffNorm = difference.clone().normalize(); + prevDiff = diffNorm.clone().translate(prevDiffNorm).normalize(); + sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2); } - else - { - this.prevDiff = this.difference.clone().normalize(); - this.sinPrev = 1; + else { + prevDiff = difference.clone().normalize(); + sinPrev = 1; } - if (this.next != null) + if(next != null) { - Vector3 nextDiffNorm = this.next.difference.clone().normalize(); - Vector3 diffNorm = this.difference.clone().normalize(); - this.nextDiff = diffNorm.clone().translate(nextDiffNorm).normalize(); - this.sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2); + Vector3 nextDiffNorm = next.difference.clone().normalize(); + Vector3 diffNorm = difference.clone().normalize(); + nextDiff = diffNorm.clone().translate(nextDiffNorm).normalize(); + sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2); } - else - { - this.nextDiff = this.difference.clone().normalize(); - this.sinNext = 1; + else { + nextDiff = difference.clone().normalize(); + sinNext = 1; } } } diff --git a/common/mekanism/induction/client/gui/GuiBattery.java b/common/mekanism/induction/client/gui/GuiBattery.java index 4dfc48639..e02b1a639 100644 --- a/common/mekanism/induction/client/gui/GuiBattery.java +++ b/common/mekanism/induction/client/gui/GuiBattery.java @@ -43,7 +43,7 @@ public class GuiBattery extends GuiContainer } @Override - protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { mc.renderEngine.bindTexture(TEXTURE); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/common/mekanism/induction/client/gui/GuiMultimeter.java b/common/mekanism/induction/client/gui/GuiMultimeter.java index d5d99675a..977abd995 100644 --- a/common/mekanism/induction/client/gui/GuiMultimeter.java +++ b/common/mekanism/induction/client/gui/GuiMultimeter.java @@ -39,75 +39,69 @@ public class GuiMultimeter extends GuiContainer private int containerHeight; private GuiTextField textFieldLimit; - public GuiMultimeter(InventoryPlayer inventoryPlayer, TileEntityMultimeter tileEntity) + public GuiMultimeter(InventoryPlayer inventoryPlayer, TileEntityMultimeter tile) { - super(new ContainerMultimeter(inventoryPlayer, tileEntity)); - this.tileEntity = tileEntity; - this.ySize = 217; + super(new ContainerMultimeter(inventoryPlayer, tile)); + tileEntity = tile; + ySize = 217; } @Override public void initGui() { super.initGui(); - this.buttonList.add(new GuiButton(0, this.width / 2 + 20, this.height / 2 - 30, 50, 20, "Toggle")); - this.textFieldLimit = new GuiTextField(fontRenderer, 35, 82, 65, 12); - this.textFieldLimit.setMaxStringLength(8); - this.textFieldLimit.setText("" + this.tileEntity.getLimit()); + buttonList.add(new GuiButton(0, width / 2 + 20, height / 2 - 30, 50, 20, "Toggle")); + textFieldLimit = new GuiTextField(fontRenderer, 35, 82, 65, 12); + textFieldLimit.setMaxStringLength(8); + textFieldLimit.setText("" + tileEntity.getLimit()); } @Override protected void keyTyped(char par1, int par2) { super.keyTyped(par1, par2); - this.textFieldLimit.textboxKeyTyped(par1, par2); + textFieldLimit.textboxKeyTyped(par1, par2); - try - { - ArrayList data = new ArrayList(); - data.add((byte)3); - data.add(Float.parseFloat(textFieldLimit.getText())); - - PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity)), data); - } - catch (Exception e) - { - } + ArrayList data = new ArrayList(); + data.add((byte)3); + data.add(Float.parseFloat(textFieldLimit.getText())); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity)), data); } @Override protected void mouseClicked(int par1, int par2, int par3) { super.mouseClicked(par1, par2, par3); - this.textFieldLimit.mouseClicked(par1 - this.containerWidth, par2 - this.containerHeight, par3); + textFieldLimit.mouseClicked(par1 - containerWidth, par2 - containerHeight, par3); } @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - String s = this.tileEntity.getBlockType().getLocalizedName(); - this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752); - this.fontRenderer.drawString("Average Energy: " + Math.round(this.tileEntity.getAverageDetectedEnergy()) + " J", 35, 25, 4210752); - this.fontRenderer.drawString("Energy: " + Math.round(this.tileEntity.getDetectedEnergy()) + " J", 35, 35, 4210752); - this.fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752); - this.fontRenderer.drawString(this.tileEntity.getMode().display, 35, 65, 4210752); - this.fontRenderer.drawString("KiloJoules", 35, 100, 4210752); + String s = tileEntity.getBlockType().getLocalizedName(); + fontRenderer.drawString(s, xSize / 2 - fontRenderer.getStringWidth(s) / 2, 15, 4210752); + fontRenderer.drawString("Average Energy: " + Math.round(tileEntity.getAverageDetectedEnergy()) + " J", 35, 25, 4210752); + fontRenderer.drawString("Energy: " + Math.round(tileEntity.getDetectedEnergy()) + " J", 35, 35, 4210752); + fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752); + fontRenderer.drawString(tileEntity.getMode().display, 35, 65, 4210752); + fontRenderer.drawString("KiloJoules", 35, 100, 4210752); - this.textFieldLimit.drawTextBox(); + textFieldLimit.drawTextBox(); } @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - this.containerWidth = (this.width - this.xSize) / 2; - this.containerHeight = (this.height - this.ySize) / 2; + containerWidth = (width - xSize) / 2; + containerHeight = (height - ySize) / 2; - this.mc.renderEngine.bindTexture(TEXTURE); + mc.renderEngine.bindTexture(TEXTURE); GL11.glColor4f(1, 1, 1, 1); - this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize); + drawTexturedModalRect(containerWidth, containerHeight, 0, 0, xSize, ySize); - int length = Math.min((int) (this.tileEntity.getDetectedEnergy() / this.tileEntity.getPeak()) * 115, 115); - this.drawTexturedModalRect(this.containerWidth + 14, this.containerHeight + 126 - length, 176, 115 - length, 6, length); + int length = Math.min((int) (tileEntity.getDetectedEnergy() / tileEntity.getPeak()) * 115, 115); + drawTexturedModalRect(containerWidth + 14, containerHeight + 126 - length, 176, 115 - length, 6, length); } @Override @@ -118,5 +112,4 @@ public class GuiMultimeter extends GuiContainer PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data)); } - } diff --git a/common/mekanism/induction/common/TeslaGrid.java b/common/mekanism/induction/common/TeslaGrid.java index db11358a0..13c551e99 100644 --- a/common/mekanism/induction/common/TeslaGrid.java +++ b/common/mekanism/induction/common/TeslaGrid.java @@ -12,10 +12,6 @@ import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; -/** - * @author Calclavia - * - */ public class TeslaGrid { private static final TeslaGrid INSTANCE_CLIENT = new TeslaGrid(); @@ -25,15 +21,15 @@ public class TeslaGrid public void register(ITesla iTesla) { - Iterator it = this.tileEntities.iterator(); + Iterator it = tileEntities.iterator(); - while (it.hasNext()) + while(it.hasNext()) { ITesla tesla = it.next(); - if (tesla instanceof TileEntity) + if(tesla instanceof TileEntity) { - if (!((TileEntity) tesla).isInvalid()) + if(!((TileEntity) tesla).isInvalid()) { continue; } @@ -43,22 +39,22 @@ public class TeslaGrid } - this.tileEntities.add(iTesla); + tileEntities.add(iTesla); } public void unregister(ITesla iTesla) { - this.tileEntities.remove(iTesla); + tileEntities.remove(iTesla); } public Set get() { - return this.tileEntities; + return tileEntities; } public static TeslaGrid instance() { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { return INSTANCE_SERVER; } diff --git a/common/mekanism/induction/common/block/BlockEMContractor.java b/common/mekanism/induction/common/block/BlockEMContractor.java index e18e6cef3..28e490c3b 100644 --- a/common/mekanism/induction/common/block/BlockEMContractor.java +++ b/common/mekanism/induction/common/block/BlockEMContractor.java @@ -1,21 +1,19 @@ package mekanism.induction.common.block; +import mekanism.api.Object3D; import mekanism.common.Mekanism; import mekanism.induction.client.render.BlockRenderingHandler; -import mekanism.induction.common.MekanismInduction; import mekanism.induction.common.item.ItemCoordLink; import mekanism.induction.common.tileentity.TileEntityEMContractor; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.core.vector.Vector3; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -24,8 +22,8 @@ public class BlockEMContractor extends Block implements ITileEntityProvider public BlockEMContractor(int id) { super(id, Material.piston); - this.setCreativeTab(Mekanism.tabMekanism); - this.setTextureName("mekanism:machine"); + setCreativeTab(Mekanism.tabMekanism); + setTextureName("mekanism:machine"); setHardness(5F); setResistance(10F); } @@ -42,32 +40,33 @@ public class BlockEMContractor extends Block implements ITileEntityProvider { TileEntityEMContractor contractor = (TileEntityEMContractor) world.getBlockTileEntity(par2, par3, par4); - if (entityPlayer.getCurrentEquippedItem() != null) + if(entityPlayer.getCurrentEquippedItem() != null) { - if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) + if(entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) { contractor.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage()); - if (!entityPlayer.capabilities.isCreativeMode) + if(!entityPlayer.capabilities.isCreativeMode) { entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); } + return true; } - else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink) + else if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink) { ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem()); - Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem()); + Object3D linkVec = link.getLink(entityPlayer.getCurrentEquippedItem()); - if (linkVec != null) + if(linkVec != null) { - if (linkVec.getTileEntity(world) instanceof TileEntityEMContractor) + if(linkVec.getTileEntity(world) instanceof TileEntityEMContractor) { contractor.setLink((TileEntityEMContractor) linkVec.getTileEntity(world), true); - if (world.isRemote) + if(world.isRemote) { - entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]"); + entityPlayer.addChatMessage("Linked " + getLocalizedName() + " with " + " [" + (int) linkVec.xCoord + ", " + (int) linkVec.yCoord + ", " + (int) linkVec.zCoord + "]"); } link.clearLink(entityPlayer.getCurrentEquippedItem()); @@ -80,12 +79,11 @@ public class BlockEMContractor extends Block implements ITileEntityProvider } } - if (!entityPlayer.isSneaking()) + if(!entityPlayer.isSneaking()) { contractor.incrementFacing(); } - else - { + else { contractor.suck = !contractor.suck; contractor.updatePath(); } @@ -98,13 +96,13 @@ public class BlockEMContractor extends Block implements ITileEntityProvider { TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z); - if (!world.isRemote && !tileContractor.isLatched()) + if(!world.isRemote && !tileContractor.isLatched()) { - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tileEntity = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ); - if (tileEntity instanceof IInventory) + if(tileEntity instanceof IInventory) { tileContractor.setFacing(side.getOpposite()); return; diff --git a/common/mekanism/induction/common/block/BlockTesla.java b/common/mekanism/induction/common/block/BlockTesla.java index 6aabdd0e6..1dc73b483 100644 --- a/common/mekanism/induction/common/block/BlockTesla.java +++ b/common/mekanism/induction/common/block/BlockTesla.java @@ -3,6 +3,7 @@ */ package mekanism.induction.common.block; +import mekanism.api.Object3D; import mekanism.common.Mekanism; import mekanism.induction.client.render.BlockRenderingHandler; import mekanism.induction.common.item.ItemCoordLink; @@ -48,54 +49,54 @@ public class BlockTesla extends Block implements ITileEntityProvider TileEntity t = world.getBlockTileEntity(x, y, z); TileEntityTesla tileEntity = ((TileEntityTesla) t).getControllingTelsa(); - if (entityPlayer.getCurrentEquippedItem() != null) + if(entityPlayer.getCurrentEquippedItem() != null) { - if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) + if(entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) { tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage()); - if (!entityPlayer.capabilities.isCreativeMode) + if(!entityPlayer.capabilities.isCreativeMode) { entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); } return true; } - else if (entityPlayer.getCurrentEquippedItem().itemID == Item.redstone.itemID) + else if(entityPlayer.getCurrentEquippedItem().itemID == Item.redstone.itemID) { boolean status = tileEntity.toggleEntityAttack(); - if (!entityPlayer.capabilities.isCreativeMode) + if(!entityPlayer.capabilities.isCreativeMode) { entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); } - if (!world.isRemote) + if(!world.isRemote) { entityPlayer.addChatMessage("Toggled entity attack to: " + status); } return true; } - else if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink) + else if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemCoordLink) { - if (tileEntity.linked == null) + if(tileEntity.linked == null) { ItemCoordLink link = ((ItemCoordLink) entityPlayer.getCurrentEquippedItem().getItem()); - Vector3 linkVec = link.getLink(entityPlayer.getCurrentEquippedItem()); + Object3D linkObj = link.getLink(entityPlayer.getCurrentEquippedItem()); - if (linkVec != null) + if(linkObj != null) { - if (!world.isRemote) + if(!world.isRemote) { int dimID = link.getLinkDim(entityPlayer.getCurrentEquippedItem()); World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID); - if (linkVec.getTileEntity(otherWorld) instanceof TileEntityTesla) + if(linkObj.getTileEntity(otherWorld) instanceof TileEntityTesla) { - tileEntity.setLink(new Vector3(((TileEntityTesla) linkVec.getTileEntity(otherWorld)).getTopTelsa()), dimID, true); + tileEntity.setLink(Object3D.get(((TileEntityTesla) linkObj.getTileEntity(otherWorld)).getTopTelsa()), dimID, true); - entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkVec.x + ", " + (int) linkVec.y + ", " + (int) linkVec.z + "]"); + entityPlayer.addChatMessage("Linked " + this.getLocalizedName() + " with " + " [" + (int) linkObj.xCoord + ", " + (int) linkObj.yCoord + ", " + (int) linkObj.zCoord + "]"); link.clearLink(entityPlayer.getCurrentEquippedItem()); world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "ambient.weather.thunder", 5, 1); @@ -105,11 +106,10 @@ public class BlockTesla extends Block implements ITileEntityProvider } } } - else - { + else { tileEntity.setLink(null, world.provider.dimensionId, true); - if (!world.isRemote) + if(!world.isRemote) { entityPlayer.addChatMessage("Unlinked Tesla."); } @@ -118,11 +118,10 @@ public class BlockTesla extends Block implements ITileEntityProvider } } } - else - { + else { boolean receiveMode = tileEntity.toggleReceive(); - if (world.isRemote) + if(world.isRemote) { entityPlayer.addChatMessage("Tesla receive mode is now " + receiveMode); } @@ -146,8 +145,8 @@ public class BlockTesla extends Block implements ITileEntityProvider return new TileEntityTesla(); } - @SideOnly(Side.CLIENT) @Override + @SideOnly(Side.CLIENT) public int getRenderType() { return BlockRenderingHandler.INSTANCE.getRenderId(); @@ -164,5 +163,4 @@ public class BlockTesla extends Block implements ITileEntityProvider { return false; } - } diff --git a/common/mekanism/induction/common/item/ItemCoordLink.java b/common/mekanism/induction/common/item/ItemCoordLink.java index 9dc5b9344..cceb9d168 100644 --- a/common/mekanism/induction/common/item/ItemCoordLink.java +++ b/common/mekanism/induction/common/item/ItemCoordLink.java @@ -5,12 +5,11 @@ package mekanism.induction.common.item; import java.util.List; -import mekanism.common.Mekanism; +import mekanism.api.Object3D; import mekanism.common.item.ItemMekanism; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import universalelectricity.core.vector.Vector3; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -34,10 +33,10 @@ public abstract class ItemCoordLink extends ItemMekanism if (hasLink(itemstack)) { - Vector3 vec = getLink(itemstack); + Object3D obj = getLink(itemstack); int dimID = getLinkDim(itemstack); - list.add("Bound to [" + (int) vec.x + ", " + (int) vec.y + ", " + (int) vec.z + "], dimension '" + dimID + "'"); + list.add("Bound to [" + (int) obj.xCoord + ", " + (int) obj.yCoord + ", " + (int) obj.zCoord + "], dimension '" + dimID + "'"); } else { @@ -50,23 +49,23 @@ public abstract class ItemCoordLink extends ItemMekanism return getLink(itemStack) != null; } - public Vector3 getLink(ItemStack itemStack) + public Object3D getLink(ItemStack itemStack) { if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("position")) { return null; } - return new Vector3(itemStack.getTagCompound().getCompoundTag("position")); + return Object3D.read(itemStack.getTagCompound().getCompoundTag("position")); } - public void setLink(ItemStack itemStack, Vector3 vec, int dimID) + public void setLink(ItemStack itemStack, Object3D obj, int dimID) { if (itemStack.getTagCompound() == null) { itemStack.setTagCompound(new NBTTagCompound()); } - itemStack.getTagCompound().setCompoundTag("position", vec.writeToNBT(new NBTTagCompound())); + itemStack.getTagCompound().setCompoundTag("position", obj.write(new NBTTagCompound())); itemStack.stackTagCompound.setInteger("dimID", dimID); } diff --git a/common/mekanism/induction/common/item/ItemLinker.java b/common/mekanism/induction/common/item/ItemLinker.java index 5e771884c..752704ad1 100644 --- a/common/mekanism/induction/common/item/ItemLinker.java +++ b/common/mekanism/induction/common/item/ItemLinker.java @@ -3,10 +3,10 @@ */ package mekanism.induction.common.item; +import mekanism.api.Object3D; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import universalelectricity.core.vector.Vector3; /** * @author Calclavia @@ -26,7 +26,7 @@ public class ItemLinker extends ItemCoordLink { int dimID = world.provider.dimensionId; player.addChatMessage("Set link to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'"); - this.setLink(stack, new Vector3(x, y, z), dimID); + this.setLink(stack, new Object3D(x, y, z), dimID); } return true; diff --git a/common/mekanism/induction/common/tileentity/TileEntityEMContractor.java b/common/mekanism/induction/common/tileentity/TileEntityEMContractor.java index ae237e7f6..349924253 100644 --- a/common/mekanism/induction/common/tileentity/TileEntityEMContractor.java +++ b/common/mekanism/induction/common/tileentity/TileEntityEMContractor.java @@ -594,9 +594,6 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements ITileN } } - /** - * @param itemDamage - */ public void setDye(int dye) { dyeID = dye; diff --git a/common/mekanism/induction/common/tileentity/TileEntityMultimeter.java b/common/mekanism/induction/common/tileentity/TileEntityMultimeter.java index fa83b4c8f..4caf45227 100644 --- a/common/mekanism/induction/common/tileentity/TileEntityMultimeter.java +++ b/common/mekanism/induction/common/tileentity/TileEntityMultimeter.java @@ -52,9 +52,9 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet public String display; - private DetectMode(String display) + private DetectMode(String s) { - this.display = display; + display = s; } } @@ -70,12 +70,12 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet { super.updateEntity(); - if (!this.worldObj.isRemote) + if(!worldObj.isRemote) { - if (this.ticks % 20 == 0) + if(ticks % 20 == 0) { - float prevDetectedEnergy = this.detectedEnergy; - this.updateDetection(this.doGetDetectedEnergy()); + float prevDetectedEnergy = detectedEnergy; + updateDetection(doGetDetectedEnergy()); boolean outputRedstone = false; @@ -84,38 +84,38 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet default: break; case EQUAL: - outputRedstone = this.detectedEnergy == this.energyLimit; + outputRedstone = detectedEnergy == energyLimit; break; case GREATER_THAN: - outputRedstone = this.detectedEnergy > this.energyLimit; + outputRedstone = detectedEnergy > energyLimit; break; case GREATER_THAN_EQUAL: - outputRedstone = this.detectedEnergy >= this.energyLimit; + outputRedstone = detectedEnergy >= energyLimit; break; case LESS_THAN: - outputRedstone = this.detectedEnergy < this.energyLimit; + outputRedstone = detectedEnergy < energyLimit; break; case LESS_THAN_EQUAL: - outputRedstone = this.detectedEnergy <= this.energyLimit; + outputRedstone = detectedEnergy <= energyLimit; break; } - if (outputRedstone != this.redstoneOn) + if(outputRedstone != redstoneOn) { - this.redstoneOn = outputRedstone; - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, MekanismInduction.Multimeter.blockID); + redstoneOn = outputRedstone; + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismInduction.Multimeter.blockID); } - if (prevDetectedEnergy != this.detectedEnergy) + if(prevDetectedEnergy != detectedEnergy) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } } - if (!this.worldObj.isRemote) + if(!worldObj.isRemote) { - for (EntityPlayer player : this.playersUsing) + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player); } @@ -128,15 +128,15 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet switch (input.readByte()) { default: - this.detectMode = DetectMode.values()[input.readByte()]; - this.detectedEnergy = input.readFloat(); - this.energyLimit = input.readFloat(); + detectMode = DetectMode.values()[input.readByte()]; + detectedEnergy = input.readFloat(); + energyLimit = input.readFloat(); break; case 2: - this.toggleMode(); + toggleMode(); break; case 3: - this.energyLimit = input.readFloat(); + energyLimit = input.readFloat(); break; } } @@ -165,41 +165,41 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet public float doGetDetectedEnergy() { - ForgeDirection direction = this.getDirection(); - TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ); + ForgeDirection direction = getDirection(); + TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ); return getDetectedEnergy(direction.getOpposite(), tileEntity); } public static float getDetectedEnergy(ForgeDirection side, TileEntity tileEntity) { - if (tileEntity instanceof TileEntityElectrical) + if(tileEntity instanceof TileEntityElectrical) { return ((TileEntityElectrical) tileEntity).getEnergyStored(); } - else if (tileEntity instanceof IElectricalStorage) + else if(tileEntity instanceof IElectricalStorage) { return ((IElectricalStorage) tileEntity).getEnergyStored(); } - else if (tileEntity instanceof IConductor) + else if(tileEntity instanceof IConductor) { IElectricityNetwork network = ((IConductor) tileEntity).getNetwork(); - if (MultimeterEventHandler.getCache(tileEntity.worldObj).containsKey(network) && MultimeterEventHandler.getCache(tileEntity.worldObj).get(network) instanceof Float) + if(MultimeterEventHandler.getCache(tileEntity.worldObj).containsKey(network) && MultimeterEventHandler.getCache(tileEntity.worldObj).get(network) instanceof Float) { return MultimeterEventHandler.getCache(tileEntity.worldObj).get(network); } } - else if (tileEntity instanceof IEnergyStorage) + else if(tileEntity instanceof IEnergyStorage) { return ((IEnergyStorage) tileEntity).getStored(); } - else if (tileEntity instanceof IEnergyStorage) + else if(tileEntity instanceof IEnergyStorage) { return ((IEnergyStorage) tileEntity).getStored(); } - else if (tileEntity instanceof IPowerReceptor) + else if(tileEntity instanceof IPowerReceptor) { - if (((IPowerReceptor) tileEntity).getPowerReceiver(side) != null) + if(((IPowerReceptor) tileEntity).getPowerReceiver(side) != null) { return ((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored(); } @@ -210,82 +210,72 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements ITileNet public void updateDetection(float detected) { - this.detectedEnergy = detected; - this.detectedAverageEnergy = (detectedAverageEnergy + this.detectedEnergy) / 2; - this.peakDetection = Math.max(peakDetection, this.detectedEnergy); + detectedEnergy = detected; + detectedAverageEnergy = (detectedAverageEnergy + detectedEnergy) / 2; + peakDetection = Math.max(peakDetection, detectedEnergy); } public float getDetectedEnergy() { - return this.detectedEnergy; + return detectedEnergy; } public float getAverageDetectedEnergy() { - return this.detectedAverageEnergy; + return detectedAverageEnergy; } public void toggleMode() { - this.detectMode = DetectMode.values()[(this.detectMode.ordinal() + 1) % DetectMode.values().length]; + detectMode = DetectMode.values()[(detectMode.ordinal() + 1) % DetectMode.values().length]; } - /** - * Reads a tile entity from NBT. - */ @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - this.detectMode = DetectMode.values()[nbt.getInteger("detectMode")]; - this.energyLimit = nbt.getFloat("energyLimit"); + detectMode = DetectMode.values()[nbt.getInteger("detectMode")]; + energyLimit = nbt.getFloat("energyLimit"); } - /** - * Writes a tile entity to NBT. - */ @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("detectMode", this.detectMode.ordinal()); - nbt.setFloat("energyLimit", this.energyLimit); + nbt.setInteger("detectMode", detectMode.ordinal()); + nbt.setFloat("energyLimit", energyLimit); } public DetectMode getMode() { - return this.detectMode; + return detectMode; } public float getLimit() { - return this.energyLimit; + return energyLimit; } - /** - * @return - */ public float getPeak() { - return this.peakDetection; + return peakDetection; } @Override public boolean canConnect(ForgeDirection direction) { - return direction == this.getDirection(); + return direction == getDirection(); } @Override public ForgeDirection getDirection() { - return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); + return ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); } @Override public void setDirection(ForgeDirection direction) { - this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, direction.ordinal(), 3); + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3); } - } diff --git a/common/mekanism/induction/common/tileentity/TileEntityTesla.java b/common/mekanism/induction/common/tileentity/TileEntityTesla.java index 8c5162c6d..abf500f6a 100644 --- a/common/mekanism/induction/common/tileentity/TileEntityTesla.java +++ b/common/mekanism/induction/common/tileentity/TileEntityTesla.java @@ -69,7 +69,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT /** * Quantum Tesla */ - public Vector3 linked; + public Object3D linked; public int linkDim; /** @@ -90,47 +90,47 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT { super.updateEntity(); - boolean doPacketUpdate = this.getEnergyStored() > 0; + boolean doPacketUpdate = getEnergyStored() > 0; /** * Only transfer if it is the bottom controlling Tesla tower. */ - if (this.isController()) + if(isController()) { - this.produce(); + produce(); - if (this.ticks % (5 + this.worldObj.rand.nextInt(2)) == 0 && ((this.worldObj.isRemote && this.doTransfer) || (this.getEnergyStored() > 0 && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)))) + if(ticks % (5 + worldObj.rand.nextInt(2)) == 0 && ((worldObj.isRemote && doTransfer) || (getEnergyStored() > 0 && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)))) { - final TileEntityTesla topTesla = this.getTopTelsa(); + final TileEntityTesla topTesla = getTopTelsa(); final Vector3 topTeslaVector = new Vector3(topTesla); /** * Quantum transportation. */ - if (this.linked != null || this.isLinkedClient) + if(linked != null || isLinkedClient) { - if (!this.worldObj.isRemote) + if(!worldObj.isRemote) { - World dimWorld = MinecraftServer.getServer().worldServerForDimension(this.linkDim); + World dimWorld = MinecraftServer.getServer().worldServerForDimension(linkDim); - if (dimWorld != null) + if(dimWorld != null) { - TileEntity transferTile = this.linked.getTileEntity(dimWorld); + TileEntity transferTile = linked.getTileEntity(dimWorld); - if (transferTile instanceof TileEntityTesla && !transferTile.isInvalid()) + if(transferTile instanceof TileEntityTesla && !transferTile.isInvalid()) { - this.transfer(((TileEntityTesla) transferTile), Math.min(this.getProvide(ForgeDirection.UNKNOWN), TRANSFER_CAP)); + transfer(((TileEntityTesla) transferTile), Math.min(getProvide(ForgeDirection.UNKNOWN), TRANSFER_CAP)); - if (this.zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS) + if(zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", getEnergyStored() / 25, 1.3f - 0.5f * (dyeID / 16f)); } } } } else { - MekanismInduction.proxy.renderElectricShock(this.worldObj, topTeslaVector.clone().translate(0.5), topTeslaVector.clone().translate(new Vector3(0.5, Double.POSITIVE_INFINITY, 0.5)), false); + MekanismInduction.proxy.renderElectricShock(worldObj, topTeslaVector.clone().translate(0.5), topTeslaVector.clone().translate(new Vector3(0.5, Double.POSITIVE_INFINITY, 0.5)), false); } } else @@ -138,18 +138,18 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT List transferTeslaCoils = new ArrayList(); - for (ITesla tesla : TeslaGrid.instance().get()) + for(ITesla tesla : TeslaGrid.instance().get()) { - if (new Vector3((TileEntity) tesla).distance(new Vector3(this)) < this.getRange()) + if(new Vector3((TileEntity) tesla).distance(new Vector3(this)) < getRange()) { /** * Make sure Tesla is not part of this tower. */ - if (!this.connectedTeslas.contains(tesla) && tesla.canReceive(this)) + if(!connectedTeslas.contains(tesla) && tesla.canReceive(this)) { - if (tesla instanceof TileEntityTesla) + if(tesla instanceof TileEntityTesla) { - if (((TileEntityTesla) tesla).getHeight() <= 1) + if(((TileEntityTesla) tesla).getHeight() <= 1) { continue; } @@ -172,11 +172,11 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT double distance1 = new Vector3(topTesla).distance(new Vector3((TileEntity) o1)); double distance2 = new Vector3(topTesla).distance(new Vector3((TileEntity) o2)); - if (distance1 < distance2) + if(distance1 < distance2) { return 1; } - else if (distance1 > distance2) + else if(distance1 > distance2) { return -1; } @@ -191,51 +191,51 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT } }); - if (transferTeslaCoils.size() > 0) + if(transferTeslaCoils.size() > 0) { - float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size(); + float transferEnergy = getEnergyStored() / transferTeslaCoils.size(); int count = 0; boolean sentPacket = false; - for (ITesla tesla : transferTeslaCoils) + for(ITesla tesla : transferTeslaCoils) { - if (this.zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS) + if(zapCounter % 5 == 0 && MekanismInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, MekanismInduction.PREFIX + "electricshock", getEnergyStored() / 25, 1.3f - 0.5f * (dyeID / 16f)); } Vector3 targetVector = new Vector3((TileEntity) tesla); - if (tesla instanceof TileEntityTesla) + if(tesla instanceof TileEntityTesla) { ((TileEntityTesla) tesla).getControllingTelsa().outputBlacklist.add(this); targetVector = new Vector3(((TileEntityTesla) tesla).getTopTelsa()); } double distance = topTeslaVector.distance(targetVector); - MekanismInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) MekanismInduction.DYE_COLORS[this.dyeID].x, (float) MekanismInduction.DYE_COLORS[this.dyeID].y, (float) MekanismInduction.DYE_COLORS[this.dyeID].z); + MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) MekanismInduction.DYE_COLORS[dyeID].x, (float) MekanismInduction.DYE_COLORS[dyeID].y, (float) MekanismInduction.DYE_COLORS[dyeID].z); - this.transfer(tesla, Math.min(transferEnergy, TRANSFER_CAP)); + transfer(tesla, Math.min(transferEnergy, TRANSFER_CAP)); - if (!sentPacket && transferEnergy > 0) + if(!sentPacket && transferEnergy > 0) { - this.sendPacket(3); + sendPacket(3); } - if (this.attackEntities && this.zapCounter % 5 == 0) + if(attackEntities && zapCounter % 5 == 0) { - MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(this.worldObj, targetVector.clone().translate(0.5)); + MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(worldObj, targetVector.clone().translate(0.5)); - if (mop != null && mop.entityHit != null) + if(mop != null && mop.entityHit != null) { - if (mop.entityHit instanceof EntityLivingBase) + if(mop.entityHit instanceof EntityLivingBase) { mop.entityHit.attackEntityFrom(DamageSource.magic, 4); - MekanismInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit)); + MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit)); } } } - if (count++ > 1) + if(count++ > 1) { break; } @@ -243,27 +243,27 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT } } - this.zapCounter++; - this.outputBlacklist.clear(); + zapCounter++; + outputBlacklist.clear(); - this.doTransfer = false; + doTransfer = false; } - if (!this.worldObj.isRemote && this.getEnergyStored() > 0 != doPacketUpdate) + if(!worldObj.isRemote && getEnergyStored() > 0 != doPacketUpdate) { - this.sendPacket(2); + sendPacket(2); } } - this.clearCache(); + clearCache(); } private void transfer(ITesla tesla, float transferEnergy) { - if (transferEnergy > 0) + if(transferEnergy > 0) { - tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true); - this.transfer(-transferEnergy, true); + tesla.transfer(transferEnergy * (1 - (worldObj.rand.nextFloat() * 0.1f)), true); + transfer(-transferEnergy, true); } } @@ -276,13 +276,13 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT @Override public boolean canReceive(TileEntity tileEntity) { - return this.canReceive && !this.outputBlacklist.contains(tileEntity) && this.getRequest(ForgeDirection.UNKNOWN) > 0; + return canReceive && !outputBlacklist.contains(tileEntity) && getRequest(ForgeDirection.UNKNOWN) > 0; } @Override public boolean canConnect(ForgeDirection direction) { - return this.isController(); + return isController(); } @Override @@ -320,7 +320,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT public void sendPacket(int id) { - switch (id) + switch(id) { case 1: PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList()))); @@ -337,80 +337,80 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT @Override public void handlePacketData(ByteArrayDataInput input) { - switch (input.readByte()) + switch(input.readByte()) { case 1: - this.setEnergyStored(input.readFloat()); - this.dyeID = input.readInt(); - this.canReceive = input.readBoolean(); - this.attackEntities = input.readBoolean(); - this.isLinkedClient = input.readBoolean(); + setEnergyStored(input.readFloat()); + dyeID = input.readInt(); + canReceive = input.readBoolean(); + attackEntities = input.readBoolean(); + isLinkedClient = input.readBoolean(); break; case 2: - this.setEnergyStored(input.readFloat()); + setEnergyStored(input.readFloat()); break; case 3: - this.doTransfer = true; + doTransfer = true; } } private boolean isController() { - return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord) == 0; + return worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0; } private void clearCache() { - this.topCache = null; - this.controlCache = null; + topCache = null; + controlCache = null; } @Override public float transfer(float transferEnergy, boolean doTransfer) { - if (isController() || this.getControllingTelsa() == this) + if(isController() || getControllingTelsa() == this) { - if (doTransfer) + if(doTransfer) { - this.receiveElectricity(transferEnergy, true); + receiveElectricity(transferEnergy, true); } - this.sendPacket(2); + sendPacket(2); return transferEnergy; } else { - if (this.getEnergyStored() > 0) + if(getEnergyStored() > 0) { - transferEnergy += this.getEnergyStored(); - this.setEnergyStored(0); + transferEnergy += getEnergyStored(); + setEnergyStored(0); } - return this.getControllingTelsa().transfer(transferEnergy, doTransfer); + return getControllingTelsa().transfer(transferEnergy, doTransfer); } } public int getRange() { - return Math.min(4 * (this.getHeight() - 1), 50); + return Math.min(4 * (getHeight() - 1), 50); } public void updatePositionStatus() { - boolean isTop = new Vector3(this).translate(new Vector3(0, 1, 0)).getTileEntity(this.worldObj) instanceof TileEntityTesla; - boolean isBottom = new Vector3(this).translate(new Vector3(0, -1, 0)).getTileEntity(this.worldObj) instanceof TileEntityTesla; + boolean isTop = new Vector3(this).translate(new Vector3(0, 1, 0)).getTileEntity(worldObj) instanceof TileEntityTesla; + boolean isBottom = new Vector3(this).translate(new Vector3(0, -1, 0)).getTileEntity(worldObj) instanceof TileEntityTesla; - if (isTop && isBottom) + if(isTop && isBottom) { - this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 1, 3); + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 3); } - else if (isBottom) + else if(isBottom) { - this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 2, 3); + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 3); } else { - this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 0, 3); + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3); } } @@ -421,22 +421,22 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT */ public TileEntityTesla getTopTelsa() { - if (this.topCache != null) + if(topCache != null) { - return this.topCache; + return topCache; } - this.connectedTeslas.clear(); + connectedTeslas.clear(); Vector3 checkPosition = new Vector3(this); TileEntityTesla returnTile = this; while (true) { - TileEntity t = checkPosition.getTileEntity(this.worldObj); + TileEntity t = checkPosition.getTileEntity(worldObj); - if (t instanceof TileEntityTesla) + if(t instanceof TileEntityTesla) { - this.connectedTeslas.add((TileEntityTesla) t); + connectedTeslas.add((TileEntityTesla) t); returnTile = (TileEntityTesla) t; } else @@ -447,7 +447,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT checkPosition.y++; } - this.topCache = returnTile; + topCache = returnTile; return returnTile; } @@ -458,9 +458,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT */ public TileEntityTesla getControllingTelsa() { - if (this.controlCache != null) + if(controlCache != null) { - return this.controlCache; + return controlCache; } Vector3 checkPosition = new Vector3(this); @@ -468,9 +468,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT while (true) { - TileEntity t = checkPosition.getTileEntity(this.worldObj); + TileEntity t = checkPosition.getTileEntity(worldObj); - if (t instanceof TileEntityTesla) + if(t instanceof TileEntityTesla) { returnTile = (TileEntityTesla) t; } @@ -482,7 +482,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT checkPosition.y--; } - this.controlCache = returnTile; + controlCache = returnTile; return returnTile; } @@ -493,16 +493,16 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT */ public int getHeight() { - this.connectedTeslas.clear(); + connectedTeslas.clear(); int y = 0; while (true) { - TileEntity t = new Vector3(this).translate(new Vector3(0, y, 0)).getTileEntity(this.worldObj); + TileEntity t = new Vector3(this).translate(new Vector3(0, y, 0)).getTileEntity(worldObj); - if (t instanceof TileEntityTesla) + if(t instanceof TileEntityTesla) { - this.connectedTeslas.add((TileEntityTesla) t); + connectedTeslas.add((TileEntityTesla) t); y++; } else @@ -535,19 +535,19 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT public void setDye(int id) { - this.dyeID = id; - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + dyeID = id; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } public boolean toggleReceive() { - return this.canReceive = !this.canReceive; + return canReceive = !canReceive; } public boolean toggleEntityAttack() { - boolean returnBool = this.attackEntities = !this.attackEntities; - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + boolean returnBool = attackEntities = !attackEntities; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return returnBool; } @@ -558,14 +558,14 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - this.dyeID = nbt.getInteger("dyeID"); - this.canReceive = nbt.getBoolean("canReceive"); - this.attackEntities = nbt.getBoolean("attackEntities"); + dyeID = nbt.getInteger("dyeID"); + canReceive = nbt.getBoolean("canReceive"); + attackEntities = nbt.getBoolean("attackEntities"); - if (nbt.hasKey("link_x") && nbt.hasKey("link_y") && nbt.hasKey("link_z")) + if(nbt.hasKey("linked")) { - this.linked = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z")); - this.linkDim = nbt.getInteger("linkDim"); + linked = Object3D.read(nbt.getCompoundTag("linked")); + linkDim = nbt.getInteger("linkDim"); } } @@ -576,48 +576,46 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("dyeID", this.dyeID); - nbt.setBoolean("canReceive", this.canReceive); - nbt.setBoolean("attackEntities", this.attackEntities); + nbt.setInteger("dyeID", dyeID); + nbt.setBoolean("canReceive", canReceive); + nbt.setBoolean("attackEntities", attackEntities); - if (this.linked != null) + if(linked != null) { - nbt.setInteger("link_x", (int) this.linked.x); - nbt.setInteger("link_y", (int) this.linked.y); - nbt.setInteger("link_z", (int) this.linked.z); - nbt.setInteger("linkDim", this.linkDim); + nbt.setCompoundTag("linked", linked.write(new NBTTagCompound())); + nbt.setInteger("linkDim", linkDim); } } - public void setLink(Vector3 vector3, int dimID, boolean setOpponent) + public void setLink(Object3D obj, int dimID, boolean setOpponent) { - if (!this.worldObj.isRemote) + if(!worldObj.isRemote) { - World otherWorld = MinecraftServer.getServer().worldServerForDimension(this.linkDim); + World otherWorld = MinecraftServer.getServer().worldServerForDimension(linkDim); - if (setOpponent && this.linked != null && otherWorld != null) + if(setOpponent && linked != null && otherWorld != null) { - TileEntity tileEntity = this.linked.getTileEntity(otherWorld); + TileEntity tileEntity = linked.getTileEntity(otherWorld); - if (tileEntity instanceof TileEntityTesla) + if(tileEntity instanceof TileEntityTesla) { - ((TileEntityTesla) tileEntity).setLink(null, this.linkDim, false); + ((TileEntityTesla) tileEntity).setLink(null, linkDim, false); } } - this.linked = vector3; - this.linkDim = dimID; - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + linked = obj; + linkDim = dimID; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - World newOtherWorld = MinecraftServer.getServer().worldServerForDimension(this.linkDim); + World newOtherWorld = MinecraftServer.getServer().worldServerForDimension(linkDim); - if (setOpponent && newOtherWorld != null && this.linked != null) + if(setOpponent && newOtherWorld != null && linked != null) { - TileEntity tileEntity = this.linked.getTileEntity(newOtherWorld); + TileEntity tileEntity = linked.getTileEntity(newOtherWorld); - if (tileEntity instanceof TileEntityTesla) + if(tileEntity instanceof TileEntityTesla) { - ((TileEntityTesla) tileEntity).setLink(new Vector3(this), this.worldObj.provider.dimensionId, false); + ((TileEntityTesla) tileEntity).setLink(Object3D.get(this), worldObj.provider.dimensionId, false); } } } @@ -626,9 +624,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT @Override public float getRequest(ForgeDirection direction) { - if (direction != ForgeDirection.DOWN) + if(direction != ForgeDirection.DOWN) { - return this.getMaxEnergyStored() - this.getEnergyStored(); + return getMaxEnergyStored() - getEnergyStored(); } return 0; @@ -637,9 +635,9 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT @Override public float getProvide(ForgeDirection direction) { - if (this.isController() && direction == ForgeDirection.DOWN) + if(isController() && direction == ForgeDirection.DOWN) { - return this.getEnergyStored(); + return getEnergyStored(); } return 0;