From afcbc81d350b03aaef015ec5dc09778ed9166c94 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 7 Jul 2015 12:32:25 +0200 Subject: [PATCH] Changed some tiny things --- .../event/RenderPlayerEventAA.java | 48 +++++++++---------- .../gadget/RenderSpecial.java | 2 + .../tile/TileEntityBreaker.java | 32 ++----------- .../tile/TileEntityPhantomPlacer.java | 6 +-- .../actuallyadditions/util/WorldUtil.java | 25 ++++++++++ 5 files changed, 56 insertions(+), 57 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java b/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java index bc3672dba..c13e96954 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java +++ b/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java @@ -19,35 +19,33 @@ public class RenderPlayerEventAA{ @SubscribeEvent(priority = EventPriority.HIGHEST) public void RenderPlayerEvent(RenderPlayerEvent.Pre event){ - if(!event.entityPlayer.isInvisible() && !event.entityPlayer.getHideCape()){ - //Ellpeck - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("3f9f4a94-95e3-40fe-8895-e8e3e84d1468"))){ - ellpeckRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); - return; - } + //Ellpeck + if(event.entityPlayer.getUniqueID().equals(UUID.fromString("3f9f4a94-95e3-40fe-8895-e8e3e84d1468"))){ + ellpeckRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); + return; + } - //Paktosan - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("0bac71ad-9156-487e-9ade-9c5b57274b23"))){ - paktoRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); - return; - } + //Paktosan + if(event.entityPlayer.getUniqueID().equals(UUID.fromString("0bac71ad-9156-487e-9ade-9c5b57274b23"))){ + paktoRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); + return; + } - //TwoOfEight - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("a57d2829-9711-4552-a7de-ee800802f643"))){ - glenRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); - return; - } + //TwoOfEight + if(event.entityPlayer.getUniqueID().equals(UUID.fromString("a57d2829-9711-4552-a7de-ee800802f643"))){ + glenRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); + return; + } - //dqmhose - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("cb7b293a-5031-484e-b5be-b4f2f4e92726"))){ - hoseRender.render(event.entityPlayer, event.partialRenderTick, 0.5F, 1.3F); - return; - } + //dqmhose + if(event.entityPlayer.getUniqueID().equals(UUID.fromString("cb7b293a-5031-484e-b5be-b4f2f4e92726"))){ + hoseRender.render(event.entityPlayer, event.partialRenderTick, 0.5F, 1.3F); + return; + } - //Lordi - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("990ecf6d-15dd-442c-b91b-323a6420c78e"))){ - lordiRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); - } + //Lordi + if(event.entityPlayer.getUniqueID().equals(UUID.fromString("990ecf6d-15dd-442c-b91b-323a6420c78e"))){ + lordiRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java b/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java index 861358e1b..844fd4b21 100644 --- a/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java +++ b/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java @@ -21,6 +21,8 @@ public class RenderSpecial{ } public void render(EntityPlayer player, float renderTick, float size, float offsetUp){ + if(player.isInvisible() || player.getHideCape()) return; + int bobHeight = 70; long theTime = Minecraft.getSystemTime(); long time = theTime/50; diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java index 37d37e94b..4a074775a 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java @@ -53,15 +53,15 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ int meta = worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()); drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), meta, 0)); - if(addToInventory(this.slots, drops, false)){ + if(WorldUtil.addToInventory(this.slots, drops, false)){ worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(blockToBreak) + (meta << 12)); WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); - addToInventory(this.slots, drops, true); + WorldUtil.addToInventory(this.slots, drops, true); this.markDirty(); } } else if(this.isPlacer && worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()).isReplaceable(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){ - int theSlot = testInventory(this.slots); + int theSlot = WorldUtil.findFirstEmptySlot(this.slots); this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, this.slots[theSlot])); if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null; } @@ -85,32 +85,6 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ this.currentTime = compound.getInteger("CurrentTime"); } - public static boolean addToInventory(ItemStack[] slots, ArrayList stacks, boolean actuallyDo){ - int working = 0; - for(ItemStack stack : stacks){ - for(int i = 0; i < slots.length; i++){ - if(slots[i] == null || (slots[i].isItemEqual(stack) && slots[i].stackSize <= stack.getMaxStackSize()-stack.stackSize)){ - working++; - if(actuallyDo){ - if(slots[i] == null) slots[i] = stack.copy(); - else slots[i].stackSize += stack.stackSize; - } - break; - } - } - } - return working >= stacks.size(); - } - - public static int testInventory(ItemStack[] slots){ - for(int i = 0; i < slots.length; i++){ - if(slots[i] != null){ - return i; - } - } - return 0; - } - @Override public boolean isItemValidForSlot(int i, ItemStack stack){ return this.isPlacer; diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java index f031804a1..c85842376 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java @@ -63,17 +63,17 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase{ int meta = boundPosition.getWorld().getBlockMetadata(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()); drops.addAll(blockToBreak.getDrops(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0)); - if(TileEntityBreaker.addToInventory(this.slots, drops, false)){ + if(WorldUtil.addToInventory(this.slots, drops, false)){ boundPosition.getWorld().playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12)); WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()); - TileEntityBreaker.addToInventory(this.slots, drops, true); + WorldUtil.addToInventory(this.slots, drops, true); this.markDirty(); } } } else{ if(boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()).isReplaceable(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ())){ - int theSlot = TileEntityBreaker.testInventory(this.slots); + int theSlot = WorldUtil.findFirstEmptySlot(this.slots); this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), this.slots[theSlot])); if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null; } diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index 2eef39653..1e1a5cc77 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -183,4 +183,29 @@ public class WorldUtil{ return blocks; } + public static boolean addToInventory(ItemStack[] slots, ArrayList stacks, boolean actuallyDo){ + int working = 0; + for(ItemStack stack : stacks){ + for(int i = 0; i < slots.length; i++){ + if(slots[i] == null || (slots[i].isItemEqual(stack) && slots[i].stackSize <= stack.getMaxStackSize()-stack.stackSize)){ + working++; + if(actuallyDo){ + if(slots[i] == null) slots[i] = stack.copy(); + else slots[i].stackSize += stack.stackSize; + } + break; + } + } + } + return working >= stacks.size(); + } + + public static int findFirstEmptySlot(ItemStack[] slots){ + for(int i = 0; i < slots.length; i++){ + if(slots[i] != null){ + return i; + } + } + return 0; + } }