diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index 99b284104..b42828c0b 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -4,6 +4,8 @@ import com.hbm.blocks.BlockContainerBase; import com.hbm.tileentity.INBTPacketReceiver; import api.hbm.block.IInsertable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; @@ -53,7 +55,7 @@ public class PistonInserter extends BlockContainerBase { protected boolean checkRedstone(World world, int x, int y, int z) { for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - if(world.getIndirectPowerOutput(x, y, z, dir.ordinal())) + if(world.getIndirectPowerOutput(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.ordinal())) return true; } @@ -63,18 +65,9 @@ public class PistonInserter extends BlockContainerBase { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if(player.getHeldItem() != null) { - if(!world.isRemote) { - TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); - - if(piston.slot == null) { - piston.slot = player.inventory.decrStackSize(player.inventory.currentItem, 1); - player.inventoryContainer.detectAndSendChanges(); - } - } - - return true; - } else if(player.isSneaking()) { + if(side != world.getBlockMetadata(x, y, z)) return false; + + if(player.isSneaking()) { if(!world.isRemote) { TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); @@ -91,6 +84,17 @@ public class PistonInserter extends BlockContainerBase { } } + return true; + } else if(player.getHeldItem() != null) { + if(!world.isRemote) { + TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); + + if(piston.slot == null) { + piston.slot = player.inventory.decrStackSize(player.inventory.currentItem, 1); + player.inventoryContainer.detectAndSendChanges(); + } + } + return true; } @@ -160,7 +164,7 @@ public class PistonInserter extends BlockContainerBase { public ItemStack slot; - public int extend; + public int extend; //why don't we just make all these ones serverside? we're never using them on the client anyway public static final int maxExtend = 25; public boolean isRetracting = true; public int delay; @@ -168,10 +172,16 @@ public class PistonInserter extends BlockContainerBase { //prevents funkies from happening with block updates or loading into a server private boolean lastState; + //when a fake animatorcel gives you something so 20fps you gotta hit him with the true interpolation stare + @SideOnly(Side.CLIENT) public double renderExtend; + @SideOnly(Side.CLIENT) public double lastExtend; + @SideOnly(Side.CLIENT) private int syncExtend; //what are these for? + @SideOnly(Side.CLIENT) private int turnProgress; //idk man, i can't find the convo bob had about them + public TileEntityPistonInserter() { } @Override - public void updateEntity() { //what is this amalgamation + public void updateEntity() { if(!worldObj.isRemote) { @@ -183,7 +193,7 @@ public class PistonInserter extends BlockContainerBase { this.extend++; if(this.extend >= this.maxExtend) { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:block.pressOperate", 1.5F, 1.0F); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:block.pressOperate", 1.0F, 1.5F); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); Block b = worldObj.getBlock(xCoord + dir.offsetX * 2, yCoord + dir.offsetY * 2, zCoord + dir.offsetZ * 2); @@ -211,19 +221,30 @@ public class PistonInserter extends BlockContainerBase { INBTPacketReceiver.networkPack(this, data, 25); + } else { + this.lastExtend = this.renderExtend; + + if(this.turnProgress > 0) { + this.renderExtend += (this.syncExtend - this.renderExtend) / (double) this.turnProgress; + this.turnProgress--; + } else { + this.renderExtend = this.syncExtend; + } } } @Override public void networkUnpack(NBTTagCompound nbt) { - this.extend = nbt.getInteger("extend"); + this.syncExtend = nbt.getInteger("extend"); if(nbt.hasKey("stack")) { NBTTagCompound stack = nbt.getCompoundTag("stack"); this.slot = ItemStack.loadItemStackFromNBT(stack); } else this.slot = null; + + this.turnProgress = 2; } /* :3 NBT stuff */ diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java index 8e45d7aec..9d8b2fc8f 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java @@ -145,8 +145,7 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements if(baseBlock == null) return false; final int side = dir.ordinal(); - final int baseMeta = world.getBlockMetadata(x, y, z); - final int pureMeta = baseMeta & 3; //in case it's shrouded in aluminum + final int pureMeta = world.getBlockMetadata(x, y, z) & 3; //in case it's shrouded in aluminum if(side == pureMeta * 2 || side == pureMeta * 2 + 1) { //first, make sure we can even push rods out @@ -157,13 +156,14 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements Block b = world.getBlock(ix, iy, iz); - if(b instanceof BlockGraphiteDrilledBase) { - if((world.getBlockMetadata(ix, iy, iz) & 3) != pureMeta) //wrong orientation + if(b instanceof BlockGraphiteDrilledBase) { + int baseMeta = world.getBlockMetadata(ix, iy, iz); + if((baseMeta & 3) != pureMeta) //wrong orientation return false; - if(((BlockGraphiteDrilledBase)b).getInsertedItem() == null) //if there's nothing to push + if(((BlockGraphiteDrilledBase)b).getInsertedItem(baseMeta) == null) //if there's nothing to push break; - else if(i >= 4) //if there is stuff to push and we reach our limit + else if(i >= 3) //if there is stuff to push and we reach our limit return false; } else { if(b.isNormalCube()) //obstructions @@ -174,7 +174,7 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements } //TODO convert old methods to use itemstack for flexibility - int oldMeta = baseMeta | baseBlock.meta; //metablocks are kinda inconvenient to work with so + int oldMeta = pureMeta | baseBlock.meta; //metablocks are kinda inconvenient to work with so Block oldBlock = baseBlock.block; NBTTagCompound oldTag = new NBTTagCompound(); //In case of TEs @@ -193,10 +193,15 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements if(newBlock instanceof BlockGraphiteDrilledTE) { TileEntity te = world.getTileEntity(ix, iy, iz); te.writeToNBT(newTag); + newTag.setInteger("x", newTag.getInteger("x") + dir.offsetX); //malformed positions is very very bad and prevents the pile TEs from ticking + newTag.setInteger("y", newTag.getInteger("y") + dir.offsetY); + newTag.setInteger("z", newTag.getInteger("z") + dir.offsetZ); } world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 2); + //TODO: fix buggy interaction when a pu239 rod is inserted into another pu239 rod. the te doesn't disappear in time (even when invalidated) so the progress is 'duplicated' in the new rod. + //the fix might be to make an additional part after the oldTag is initalized, where the id + x,y,z are set, meaning that all other values will be set back to 0 and fixed. if(oldBlock instanceof BlockGraphiteDrilledTE && !oldTag.hasNoTags()) { //safety first TileEntity te = world.getTileEntity(ix, iy, iz); te.readFromNBT(oldTag); @@ -211,7 +216,7 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements } else { Item eject = ((BlockGraphiteDrilledBase) oldBlock).getInsertedItem(oldMeta); //TODO old methods to itemstack this.ejectItem(world, ix - dir.offsetX, iy - dir.offsetY, iz - dir.offsetZ, dir, new ItemStack(eject)); - world.playSoundEffect(ix + 0.5, iy + 0.5, iz + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F); + world.playSoundEffect(ix + 0.5, iy + 0.5, iz + 0.5, "hbm:item.upgradePlug", 1.25F, 1.0F); break; } diff --git a/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java b/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java index f75aa3857..dc15763fe 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java +++ b/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java @@ -10,6 +10,7 @@ import com.hbm.render.item.ItemRenderBase; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; import net.minecraftforge.client.IItemRenderer; public class RenderPistonInserter extends TileEntitySpecialRenderer implements IItemRendererProvider { @@ -36,8 +37,8 @@ public class RenderPistonInserter extends TileEntitySpecialRenderer implements I ResourceManager.piston_inserter.renderPart("Frame"); TileEntityPistonInserter piston = (TileEntityPistonInserter)tile; - double e = piston.extend / (double)piston.maxExtend; - GL11.glTranslated(0, -e, 0); + double e = (piston.lastExtend + (piston.renderExtend - piston.lastExtend) * interp) / (double) piston.maxExtend; + GL11.glTranslated(0, e * 0.9375D, 0); ResourceManager.piston_inserter.renderPart("Piston"); GL11.glPopMatrix(); diff --git a/src/main/resources/assets/hbm/models/machines/piston_inserter.obj b/src/main/resources/assets/hbm/models/machines/piston_inserter.obj index 8d78694b6..ff7cc6c6d 100644 --- a/src/main/resources/assets/hbm/models/machines/piston_inserter.obj +++ b/src/main/resources/assets/hbm/models/machines/piston_inserter.obj @@ -75,6 +75,54 @@ v -0.125000 0.062500 0.125000 v -0.312500 0.062500 0.375000 v -0.125000 0.062500 0.062500 v -0.062500 0.062500 0.125000 +v 0.312500 0.062500 -0.375000 +v 0.375000 0.062500 -0.375000 +v 0.125000 0.062500 -0.125000 +v 0.375000 0.062500 -0.312500 +v 0.062500 0.062500 -0.125000 +v 0.125000 0.062500 -0.062500 +v -0.312500 0.062500 0.375000 +v -0.375000 0.062500 0.375000 +v -0.125000 0.062500 0.125000 +v -0.375000 0.062500 0.312500 +v -0.062500 0.062500 0.125000 +v -0.125000 0.062500 0.062500 +v 0.375000 0.062500 0.312500 +v 0.375000 0.062500 0.375000 +v 0.125000 0.062500 0.125000 +v 0.312500 0.062500 0.375000 +v 0.125000 0.062500 0.062500 +v 0.062500 0.062500 0.125000 +v -0.375000 0.062500 -0.312500 +v -0.375000 0.062500 -0.375000 +v -0.125000 0.062500 -0.125000 +v -0.312500 0.062500 -0.375000 +v -0.125000 0.062500 -0.062500 +v -0.062500 0.062500 -0.125000 +v 0.312500 0.937500 -0.375000 +v 0.375000 0.937500 -0.375000 +v 0.125000 0.937500 -0.125000 +v 0.375000 0.937500 -0.312500 +v 0.062500 0.937500 -0.125000 +v 0.125000 0.937500 -0.062500 +v -0.312500 0.937500 0.375000 +v -0.375000 0.937500 0.375000 +v -0.125000 0.937500 0.125000 +v -0.375000 0.937500 0.312500 +v -0.062500 0.937500 0.125000 +v -0.125000 0.937500 0.062500 +v 0.375000 0.937500 0.312500 +v 0.375000 0.937500 0.375000 +v 0.125000 0.937500 0.125000 +v 0.312500 0.937500 0.375000 +v 0.125000 0.937500 0.062500 +v 0.062500 0.937500 0.125000 +v -0.375000 0.937500 -0.312500 +v -0.375000 0.937500 -0.375000 +v -0.125000 0.937500 -0.125000 +v -0.312500 0.937500 -0.375000 +v -0.125000 0.937500 -0.062500 +v -0.062500 0.937500 -0.125000 vt 0.571429 0.666667 vt 0.000000 0.333333 vt 0.571429 0.333333 @@ -154,6 +202,30 @@ vt 0.071429 0.270833 vt 0.357143 0.125000 vt 0.464286 0.041667 vt 0.500000 0.062500 +vt 0.214286 0.125000 +vt 0.071429 0.062500 +vt 0.107143 0.041667 +vt 0.357143 0.208333 +vt 0.500000 0.270833 +vt 0.464286 0.291667 +vt 0.214286 0.208333 +vt 0.107143 0.291667 +vt 0.071429 0.270833 +vt 0.357143 0.125000 +vt 0.464286 0.041667 +vt 0.500000 0.062500 +vt 0.214286 0.125000 +vt 0.071429 0.062500 +vt 0.107143 0.041667 +vt 0.357143 0.208333 +vt 0.500000 0.270833 +vt 0.464286 0.291667 +vt 0.214286 0.208333 +vt 0.107143 0.291667 +vt 0.071429 0.270833 +vt 0.357143 0.125000 +vt 0.464286 0.041667 +vt 0.500000 0.062500 vt -0.000000 0.666667 vt 0.000000 0.666667 vt 0.000000 0.666667 @@ -191,6 +263,30 @@ vt 0.071429 0.291667 vt 0.357143 0.145833 vt 0.321429 0.125000 vt 0.500000 0.041667 +vt 0.250000 0.125000 +vt 0.214286 0.145833 +vt 0.071429 0.041667 +vt 0.321429 0.208333 +vt 0.357143 0.187500 +vt 0.500000 0.291667 +vt 0.214286 0.187500 +vt 0.250000 0.208333 +vt 0.071429 0.291667 +vt 0.357143 0.145833 +vt 0.321429 0.125000 +vt 0.500000 0.041667 +vt 0.250000 0.125000 +vt 0.214286 0.145833 +vt 0.071429 0.041667 +vt 0.321429 0.208333 +vt 0.357143 0.187500 +vt 0.500000 0.291667 +vt 0.214286 0.187500 +vt 0.250000 0.208333 +vt 0.071429 0.291667 +vt 0.357143 0.145833 +vt 0.321429 0.125000 +vt 0.500000 0.041667 vn -1.0000 0.0000 0.0000 vn 0.0000 0.0000 -1.0000 vn 1.0000 0.0000 0.0000 @@ -229,12 +325,20 @@ f 52/68/5 53/69/5 50/70/5 f 58/71/5 59/72/5 56/73/5 f 64/74/5 65/75/5 62/76/5 f 70/77/5 71/78/5 68/79/5 +f 76/80/6 77/81/6 74/82/6 +f 82/83/6 83/84/6 80/85/6 +f 88/86/6 89/87/6 86/88/6 +f 94/89/6 95/90/6 92/91/6 +f 100/92/6 101/93/6 98/94/6 +f 106/95/6 107/96/6 104/97/6 +f 112/98/6 113/99/6 110/100/6 +f 118/101/6 119/102/6 116/103/6 f 9/1/1 10/22/1 13/2/1 -f 10/4/2 11/80/2 15/5/2 -f 11/7/3 12/81/3 16/8/3 -f 12/10/4 9/82/4 14/11/4 -f 7/13/5 5/83/5 1/14/5 -f 4/16/6 2/84/6 6/17/6 +f 10/4/2 11/104/2 15/5/2 +f 11/7/3 12/105/3 16/8/3 +f 12/10/4 9/106/4 14/11/4 +f 7/13/5 5/107/5 1/14/5 +f 4/16/6 2/108/6 6/17/6 f 18/19/6 10/22/6 9/1/6 f 19/21/6 11/24/6 10/22/6 f 20/23/6 12/25/6 11/24/6 @@ -243,38 +347,62 @@ f 22/26/5 14/31/5 13/6/5 f 21/27/5 13/6/5 15/5/5 f 23/28/5 15/5/5 16/29/5 f 24/30/5 16/29/5 14/31/5 -f 8/32/2 7/85/2 3/33/2 -f 6/35/3 5/86/3 7/36/3 -f 2/38/4 1/87/4 5/39/4 -f 4/41/1 3/88/1 1/42/1 -f 23/44/1 24/89/1 20/45/1 -f 24/47/2 22/90/2 17/48/2 -f 22/50/3 21/91/3 18/51/3 -f 21/53/4 23/92/4 19/54/4 -f 25/58/5 30/93/5 27/56/5 -f 27/56/5 31/94/5 28/57/5 -f 28/57/5 26/95/5 25/58/5 -f 32/61/5 36/96/5 34/59/5 -f 34/59/5 37/97/5 35/60/5 -f 35/60/5 33/98/5 32/61/5 -f 38/64/5 42/99/5 40/62/5 -f 40/62/5 43/100/5 41/63/5 -f 41/63/5 39/101/5 38/64/5 -f 44/67/5 48/102/5 46/65/5 -f 46/65/5 49/103/5 47/66/5 -f 47/66/5 45/104/5 44/67/5 -f 50/70/5 54/105/5 52/68/5 -f 52/68/5 55/106/5 53/69/5 -f 53/69/5 51/107/5 50/70/5 -f 56/73/5 60/108/5 58/71/5 -f 58/71/5 61/109/5 59/72/5 -f 59/72/5 57/110/5 56/73/5 -f 62/76/5 66/111/5 64/74/5 -f 64/74/5 67/112/5 65/75/5 -f 65/75/5 63/113/5 62/76/5 -f 68/79/5 72/114/5 70/77/5 -f 70/77/5 73/115/5 71/78/5 -f 71/78/5 69/116/5 68/79/5 +f 8/32/2 7/109/2 3/33/2 +f 6/35/3 5/110/3 7/36/3 +f 2/38/4 1/111/4 5/39/4 +f 4/41/1 3/112/1 1/42/1 +f 23/44/1 24/113/1 20/45/1 +f 24/47/2 22/114/2 17/48/2 +f 22/50/3 21/115/3 18/51/3 +f 21/53/4 23/116/4 19/54/4 +f 25/58/5 30/117/5 27/56/5 +f 27/56/5 31/118/5 28/57/5 +f 28/57/5 26/119/5 25/58/5 +f 32/61/5 36/120/5 34/59/5 +f 34/59/5 37/121/5 35/60/5 +f 35/60/5 33/122/5 32/61/5 +f 38/64/5 42/123/5 40/62/5 +f 40/62/5 43/124/5 41/63/5 +f 41/63/5 39/125/5 38/64/5 +f 44/67/5 48/126/5 46/65/5 +f 46/65/5 49/127/5 47/66/5 +f 47/66/5 45/128/5 44/67/5 +f 50/70/5 54/129/5 52/68/5 +f 52/68/5 55/130/5 53/69/5 +f 53/69/5 51/131/5 50/70/5 +f 56/73/5 60/132/5 58/71/5 +f 58/71/5 61/133/5 59/72/5 +f 59/72/5 57/134/5 56/73/5 +f 62/76/5 66/135/5 64/74/5 +f 64/74/5 67/136/5 65/75/5 +f 65/75/5 63/137/5 62/76/5 +f 68/79/5 72/138/5 70/77/5 +f 70/77/5 73/139/5 71/78/5 +f 71/78/5 69/140/5 68/79/5 +f 74/82/6 78/141/6 76/80/6 +f 76/80/6 79/142/6 77/81/6 +f 77/81/6 75/143/6 74/82/6 +f 80/85/6 84/144/6 82/83/6 +f 82/83/6 85/145/6 83/84/6 +f 83/84/6 81/146/6 80/85/6 +f 86/88/6 90/147/6 88/86/6 +f 88/86/6 91/148/6 89/87/6 +f 89/87/6 87/149/6 86/88/6 +f 92/91/6 96/150/6 94/89/6 +f 94/89/6 97/151/6 95/90/6 +f 95/90/6 93/152/6 92/91/6 +f 98/94/6 102/153/6 100/92/6 +f 100/92/6 103/154/6 101/93/6 +f 101/93/6 99/155/6 98/94/6 +f 104/97/6 108/156/6 106/95/6 +f 106/95/6 109/157/6 107/96/6 +f 107/96/6 105/158/6 104/97/6 +f 110/100/6 114/159/6 112/98/6 +f 112/98/6 115/160/6 113/99/6 +f 113/99/6 111/161/6 110/100/6 +f 116/103/6 120/162/6 118/101/6 +f 118/101/6 121/163/6 119/102/6 +f 119/102/6 117/164/6 116/103/6 l 27 29 o Piston v -0.062500 1.000000 0.062500 @@ -349,31 +477,31 @@ vn 0.0000 1.0000 0.0000 vn 0.0000 -1.0000 0.0000 usemtl None s off -f 75/117/7 82/118/7 83/119/7 -f 77/120/8 84/121/8 82/122/8 -f 81/123/9 85/124/9 84/125/9 -f 79/126/10 83/127/10 85/128/10 -f 78/129/9 88/130/9 80/131/9 -f 77/132/11 79/133/11 81/134/11 -f 74/135/12 82/136/12 76/137/12 -f 76/137/12 84/138/12 80/139/12 -f 80/139/12 85/140/12 78/141/12 -f 78/141/12 83/142/12 74/135/12 -f 88/143/12 87/144/12 86/145/12 -f 76/146/7 87/147/7 74/148/7 -f 74/149/10 89/150/10 78/151/10 -f 80/152/8 86/153/8 76/154/8 -f 75/117/7 77/155/7 82/118/7 -f 77/120/8 81/156/8 84/121/8 -f 81/123/9 79/157/9 85/124/9 -f 79/126/10 75/158/10 83/127/10 -f 78/129/9 89/159/9 88/130/9 -f 77/132/11 75/160/11 79/133/11 -f 74/135/12 83/142/12 82/136/12 -f 76/137/12 82/136/12 84/138/12 -f 80/139/12 84/138/12 85/140/12 -f 78/141/12 85/140/12 83/142/12 -f 88/143/12 89/161/12 87/144/12 -f 76/146/7 86/162/7 87/147/7 -f 74/149/10 87/163/10 89/150/10 -f 80/152/8 88/164/8 86/153/8 +f 123/165/7 130/166/7 131/167/7 +f 125/168/8 132/169/8 130/170/8 +f 129/171/9 133/172/9 132/173/9 +f 127/174/10 131/175/10 133/176/10 +f 126/177/9 136/178/9 128/179/9 +f 125/180/11 127/181/11 129/182/11 +f 122/183/12 130/184/12 124/185/12 +f 124/185/12 132/186/12 128/187/12 +f 128/187/12 133/188/12 126/189/12 +f 126/189/12 131/190/12 122/183/12 +f 136/191/12 135/192/12 134/193/12 +f 124/194/7 135/195/7 122/196/7 +f 122/197/10 137/198/10 126/199/10 +f 128/200/8 134/201/8 124/202/8 +f 123/165/7 125/203/7 130/166/7 +f 125/168/8 129/204/8 132/169/8 +f 129/171/9 127/205/9 133/172/9 +f 127/174/10 123/206/10 131/175/10 +f 126/177/9 137/207/9 136/178/9 +f 125/180/11 123/208/11 127/181/11 +f 122/183/12 131/190/12 130/184/12 +f 124/185/12 130/184/12 132/186/12 +f 128/187/12 132/186/12 133/188/12 +f 126/189/12 133/188/12 131/190/12 +f 136/191/12 137/209/12 135/192/12 +f 124/194/7 134/210/7 135/195/7 +f 122/197/10 135/211/10 137/198/10 +f 128/200/8 136/212/8 134/201/8