From f52eb08301a69226e61bd97c8cd3402c0c90e106 Mon Sep 17 00:00:00 2001 From: Vaern Date: Sat, 13 May 2023 22:34:48 -0700 Subject: [PATCH 1/8] :3 Added IBlowable for fan; created TE for a piston-based inserter (IInsertable). The former will improve cooling for pile setups and the latter will allow for automation, in combination with comparator output for pile fuel. --- src/main/java/api/hbm/block/IBlowable.java | 10 + src/main/java/api/hbm/block/IInsertable.java | 10 + .../com/hbm/blocks/machine/MachineFan.java | 10 +- .../hbm/blocks/machine/PistonInserter.java | 210 ++++++++++++++++++ .../pile/BlockGraphiteBreedingFuel.java | 1 + .../machine/pile/BlockGraphiteFuel.java | 9 +- .../machine/pile/TileEntityPileBase.java | 20 +- .../machine/pile/TileEntityPileFuel.java | 15 ++ .../machine/pile/TileEntityPileSource.java | 2 +- 9 files changed, 274 insertions(+), 13 deletions(-) create mode 100644 src/main/java/api/hbm/block/IBlowable.java create mode 100644 src/main/java/api/hbm/block/IInsertable.java create mode 100644 src/main/java/com/hbm/blocks/machine/PistonInserter.java diff --git a/src/main/java/api/hbm/block/IBlowable.java b/src/main/java/api/hbm/block/IBlowable.java new file mode 100644 index 000000000..625e8a14a --- /dev/null +++ b/src/main/java/api/hbm/block/IBlowable.java @@ -0,0 +1,10 @@ +package api.hbm.block; + +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public interface IBlowable { //sloppy toppy + + /** Called server-side when a fan blows on an IBlowable in range every tick. */ + public void applyFan(World world, int x, int y, int z, ForgeDirection dir, int dist); +} diff --git a/src/main/java/api/hbm/block/IInsertable.java b/src/main/java/api/hbm/block/IInsertable.java new file mode 100644 index 000000000..b53a4849a --- /dev/null +++ b/src/main/java/api/hbm/block/IInsertable.java @@ -0,0 +1,10 @@ +package api.hbm.block; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public interface IInsertable { //uwu + + public boolean insertItem(World world, int x, int y, int z, ForgeDirection dir, ItemStack stack); +} diff --git a/src/main/java/com/hbm/blocks/machine/MachineFan.java b/src/main/java/com/hbm/blocks/machine/MachineFan.java index f9321d052..6a37de202 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineFan.java +++ b/src/main/java/com/hbm/blocks/machine/MachineFan.java @@ -2,9 +2,11 @@ package com.hbm.blocks.machine; import java.util.List; +import api.hbm.block.IBlowable; import api.hbm.block.IToolable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; @@ -79,7 +81,13 @@ public class MachineFan extends BlockContainer implements IToolable { double push = 0.1; for(int i = 1; i <= range; i++) { - if(worldObj.getBlock(xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i).isNormalCube()) { + Block block = worldObj.getBlock(xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i); + boolean blowable = block instanceof IBlowable; + + if(block.isNormalCube() || blowable) { + if(!worldObj.isRemote && blowable) + ((IBlowable) block).applyFan(worldObj, xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i, dir, i); + break; } diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java new file mode 100644 index 000000000..f7093a8f7 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -0,0 +1,210 @@ +package com.hbm.blocks.machine; + +import com.hbm.blocks.BlockContainerBase; +import com.hbm.tileentity.INBTPacketReceiver; + +import api.hbm.block.IInsertable; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class PistonInserter extends BlockContainerBase { + + public PistonInserter() { + super(Material.iron); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityPistonInserter(); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) { + this.updateState(world, x, y, z); + } + + protected void updateState(World world, int x, int y, int z) { + if(!world.isRemote) { + ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); + + if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).isNormalCube()) + return; //no obstructions allowed! + + if(checkRedstone(world, x, y, z)) { //if necessary, add lastState (if block updates are too unreliable). + TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); + + if(piston.extend <= 0) + piston.isRetracting = false; + } + } + } + + 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())) + return true; + } + + return false; + } + + // $%&#$& + // %$&&@$%%#% + //______ $%@--$@@%&$%$ + // | %/ *--$#@&&$$ + // | / --__ %$%@$& + // | (----^`--- $@##% + // | /___\ `-----*#@$ + // | /(()_) / /___\ /__ + // | / \___// (()_) //-,| + // | /____|_ / \___// )_/ + // | \____/ `^-___|___/ | + // | \/ \____/ /_-^-. + // | / _-' |___. \_ + // | / _-' / `\ \\___ + // | `'\____~~+~^/ _)/ \____ + // | \`----' | __/ _) + // | /( /~-' ,-' | + // | / `| | / | + // | / ( ) / `) + // | / `-==-' | | + // | / /| | | + // | / / \ | | + // | / / | | | + // | / / \ _____,.____| | + // | / _ / |<`____, ____,| | + // | / / \_ / _ | <_____/ | ) + // | / / ^/,^=-~---~' `z---..._______/ | + // |--' / /| |/ .^ ,^\ \ ) + // | |_|| || |(_( ) | | + // | \_/`-``-`----'___/_____ | + // |___..---' _|____`-----..-----'\ + // |_____________________| @ | ) + // average coding session involving tile entities + public static class TileEntityPistonInserter extends TileEntity implements IInventory, INBTPacketReceiver { + + public ItemStack slot; + + public int extend; + public static final int maxExtend = 25; + public boolean isRetracting; + public int delay; + + private int lastState; + + public TileEntityPistonInserter() { } + + @Override + public void updateEntity() { //what is this amalgamation + + if(!worldObj.isRemote) { + + if(delay <= 0) { + + if(this.isRetracting && this.extend > 0) { + this.extend--; + } else if(!this.isRetracting) { + this.extend++; + + if(this.extend >= this.maxExtend) { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:block.pressOperate", 1.5F, 1.0F); + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); + Block b = worldObj.getBlock(xCoord + dir.offsetX * 2, yCoord + dir.offsetY * 2, zCoord + dir.offsetZ * 2); + + if(b instanceof IInsertable && ((IInsertable) b).insertItem(worldObj, xCoord + dir.offsetX * 2, yCoord + dir.offsetY * 2, zCoord + dir.offsetZ * 2, dir, slot)) { + this.decrStackSize(0, 1); + } + + this.isRetracting = true; + this.delay = 5; + } + } + + } else { + delay--; + } + + NBTTagCompound data = new NBTTagCompound(); + data.setInteger("extend", extend); + if(this.slot != null) { + NBTTagCompound stack = new NBTTagCompound(); + slot.writeToNBT(stack); + data.setTag("stack", stack); + } + + INBTPacketReceiver.networkPack(this, data, 25); + + } + + } + + @Override + public void networkUnpack(NBTTagCompound nbt) { + this.extend = nbt.getInteger("extend"); + + if(nbt.hasKey("stack")) { + NBTTagCompound stack = nbt.getCompoundTag("stack"); + this.slot = ItemStack.loadItemStackFromNBT(stack); + } else + this.slot = null; + } + + /* BS inventory stuff */ + + @Override public int getSizeInventory() { return 1; } + + @Override public ItemStack getStackInSlot(int slot) { return this.slot; } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + if(this.slot != null) { + if(this.slot.stackSize <= amount) { + ItemStack stack = this.slot; + this.slot = null; + return stack; + } + + ItemStack stack = this.slot.splitStack(amount); + if(this.slot.stackSize == 0) + this.slot = null; + + return stack; + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { return null; } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + this.slot = stack; + if(stack != null && stack.stackSize > this.getInventoryStackLimit()) + stack.stackSize = this.getInventoryStackLimit(); + } + + @Override public String getInventoryName() { return null; } + + @Override public boolean hasCustomInventoryName() { return false; } + + @Override public int getInventoryStackLimit() { return 1; } + + @Override public boolean isUseableByPlayer(EntityPlayer player) { return false; } + + @Override public void openInventory() {} + + @Override public void closeInventory() {} + + @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; } + + } +} diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteBreedingFuel.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteBreedingFuel.java index 46231bca4..fdfcac709 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteBreedingFuel.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteBreedingFuel.java @@ -64,4 +64,5 @@ public class BlockGraphiteBreedingFuel extends BlockGraphiteDrilledTE implements protected Item getInsertedItem() { return ModItems.pile_rod_lithium; } + } diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java index d3b768d6c..3a315e2cf 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java @@ -5,6 +5,7 @@ import com.hbm.items.ModItems; import com.hbm.lib.RefStrings; import com.hbm.tileentity.machine.pile.TileEntityPileFuel; +import api.hbm.block.IBlowable; import api.hbm.block.IToolable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -19,7 +20,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolable { +public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolable, IBlowable { @Override public TileEntity createNewTileEntity(World world, int mets) { @@ -68,4 +69,10 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab protected Item getInsertedItem(int meta) { return (meta & 8) == 8 ? ModItems.pile_rod_pu239 : ModItems.pile_rod_uranium; } + + @Override + public void applyFan(World world, int x, int y, int z, ForgeDirection dir, int dist) { + TileEntityPileFuel pile = (TileEntityPileFuel) world.getTileEntity(x, y, z); + pile.heat -= pile.heat * 0.025; + } } diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileBase.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileBase.java index 90d3cd483..30d6c3552 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileBase.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileBase.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Random; import com.hbm.blocks.ModBlocks; +import com.hbm.main.MainRegistry; import com.hbm.util.ContaminationUtil; import com.hbm.util.ContaminationUtil.ContaminationType; import com.hbm.util.ContaminationUtil.HazardType; @@ -11,6 +12,7 @@ import com.hbm.util.ContaminationUtil.HazardType; import api.hbm.block.IPileNeutronReceiver; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; @@ -21,11 +23,8 @@ public abstract class TileEntityPileBase extends TileEntity { public abstract void updateEntity(); protected void castRay(int flux, int range) { - Random rand = worldObj.rand; - int[] vecVals = { 0, 0, 0,}; - vecVals[rand.nextInt(3)] = 1; - Vec3 vec = Vec3.createVectorHelper(vecVals[0], vecVals[1], vecVals[2]); + Vec3 vec = Vec3.createVectorHelper(1, 0, 0); vec.rotateAroundZ((float)(rand.nextDouble() * Math.PI * 2D)); vec.rotateAroundY((float)(rand.nextDouble() * Math.PI * 2D)); vec.rotateAroundX((float)(rand.nextDouble() * Math.PI * 2D)); @@ -47,13 +46,14 @@ public abstract class TileEntityPileBase extends TileEntity { prevY = y; prevZ = z; - /*if(i == range) { + /*if(i == range || i == 1) { NBTTagCompound data2 = new NBTTagCompound(); data2.setString("type", "vanillaExt"); - data2.setString("mode", "greendust"); - data2.setDouble("posX", xCoord + 0.5 + vec.xCoord * range); - data2.setDouble("posY", yCoord + 0.5 + vec.yCoord * range); - data2.setDouble("posZ", zCoord + 0.5 + vec.zCoord * range); + data2.setString("mode", i == range ? "greendust" : + i == 1 ? "reddust" : "bluedust"); + data2.setDouble("posX", xCoord + 0.5 + vec.xCoord * i); + data2.setDouble("posY", yCoord + 0.5 + vec.yCoord * i); + data2.setDouble("posZ", zCoord + 0.5 + vec.zCoord * i); MainRegistry.proxy.effectNT(data2); }*/ @@ -91,7 +91,7 @@ public abstract class TileEntityPileBase extends TileEntity { if(entities != null) for(EntityLivingBase e : entities) { - ContaminationUtil.contaminate(e, HazardType.RADIATION, ContaminationType.CREATIVE, flux / 2); + ContaminationUtil.contaminate(e, HazardType.RADIATION, ContaminationType.CREATIVE, flux / 4F); } } } diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java index 7a48e4f83..869971e6f 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java @@ -2,8 +2,12 @@ package com.hbm.tileentity.machine.pile; import com.hbm.blocks.ModBlocks; import com.hbm.config.GeneralConfig; +import com.hbm.main.MainRegistry; +import com.hbm.packet.AuxParticlePacketNT; +import com.hbm.packet.PacketDispatcher; import api.hbm.block.IPileNeutronReceiver; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutronReceiver { @@ -28,10 +32,21 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.gas_radon_dense); } + if(worldObj.rand.nextFloat() * 2F <= this.heat / (float)this.maxHeat) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "vanillaExt"); + data.setString("mode", "smoke"); + data.setDouble("mY", 0.05); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 1, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5), + new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 20)); + MainRegistry.proxy.effectNT(data); + } + if(this.progress >= this.maxProgress) { worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.block_graphite_plutonium, this.getBlockMetadata() & 7, 3); } } + } private void dissipateHeat() { diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java index c297f9dfb..0c164657f 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java @@ -11,7 +11,7 @@ public class TileEntityPileSource extends TileEntityPileBase { int n = this.getBlockType() == ModBlocks.block_graphite_source ? 1 : 2; - for(int i = 0; i < 12; i++) { + for(int i = 0; i < 12 * 5; i++) { this.castRay(n, 5); } } From 5c36e1aa044a488c7330fd0f3d29510d91c71ba2 Mon Sep 17 00:00:00 2001 From: Vaern Date: Sun, 14 May 2023 22:22:45 -0700 Subject: [PATCH 2/8] piston inserter --- src/main/java/com/hbm/blocks/ModBlocks.java | 6 + .../hbm/blocks/machine/PistonInserter.java | 112 +++++- .../pile/BlockGraphiteDrilledBase.java | 111 ++++- src/main/java/com/hbm/main/ClientProxy.java | 2 + .../java/com/hbm/main/ResourceManager.java | 6 + .../tileentity/RenderPistonInserter.java | 65 +++ .../java/com/hbm/tileentity/TileMappings.java | 2 + .../hbm/models/machines/piston_inserter.obj | 379 ++++++++++++++++++ .../models/machines/piston_inserter.png | Bin 0 -> 544 bytes 9 files changed, 673 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java create mode 100644 src/main/resources/assets/hbm/models/machines/piston_inserter.obj create mode 100644 src/main/resources/assets/hbm/textures/models/machines/piston_inserter.png diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 3605f9a2f..8d85225ec 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -786,6 +786,8 @@ public class ModBlocks { public static Block crane_splitter; public static Block fan; + + public static Block piston_inserter; public static Block chain; @@ -1912,6 +1914,8 @@ public class ModBlocks { crane_splitter = new CraneSplitter().setBlockName("crane_splitter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":crane_side"); fan = new MachineFan().setBlockName("fan").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); + piston_inserter = new PistonInserter().setBlockName("piston_inserter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); + chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain"); ladder_sturdy = new BlockNTMLadder().setBlockName("ladder_sturdy").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":ladder_sturdy"); @@ -3120,6 +3124,8 @@ public class ModBlocks { GameRegistry.registerBlock(crane_splitter, crane_splitter.getUnlocalizedName()); GameRegistry.registerBlock(fan, fan.getUnlocalizedName()); + GameRegistry.registerBlock(piston_inserter, piston_inserter.getUnlocalizedName()); + GameRegistry.registerBlock(chain, chain.getUnlocalizedName()); GameRegistry.registerBlock(ladder_sturdy, ladder_sturdy.getUnlocalizedName()); GameRegistry.registerBlock(ladder_iron, ladder_iron.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index f7093a8f7..99b284104 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -5,12 +5,16 @@ import com.hbm.tileentity.INBTPacketReceiver; import api.hbm.block.IInsertable; import net.minecraft.block.Block; +import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -37,12 +41,13 @@ public class PistonInserter extends BlockContainerBase { if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).isNormalCube()) return; //no obstructions allowed! - if(checkRedstone(world, x, y, z)) { //if necessary, add lastState (if block updates are too unreliable). - TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); - - if(piston.extend <= 0) - piston.isRetracting = false; - } + boolean flag = checkRedstone(world, x, y, z); + TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); + + if(flag && !piston.lastState && piston.extend <= 0) + piston.isRetracting = false; + + piston.lastState = flag; } } @@ -55,6 +60,69 @@ public class PistonInserter extends BlockContainerBase { return false; } + @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(!world.isRemote) { + TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); + + if(piston.slot != null) { + ForgeDirection dir = ForgeDirection.getOrientation(piston.getBlockMetadata()); + + EntityItem dust = new EntityItem(world, x + 0.5D + dir.offsetX * 0.75D, y + 0.5D + dir.offsetY * 0.75D, z + 0.5D + dir.offsetZ * 0.75D, piston.slot); + piston.slot = null; + + dust.motionX = dir.offsetX * 0.25; + dust.motionY = dir.offsetY * 0.25; + dust.motionZ = dir.offsetZ * 0.25; + world.spawnEntityInWorld(dust); + } + } + + return true; + } + + return false; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { + int l = BlockPistonBase.determineOrientation(world, x, y, z, player); + world.setBlockMetadataWithNotify(x, y, z, l, 2); + } + + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return world.getBlockMetadata(x, y, z) != side.ordinal(); + } + + @Override + public int getRenderType(){ + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + // $%&#$& // %$&&@$%%#% //______ $%@--$@@%&$%$ @@ -94,10 +162,11 @@ public class PistonInserter extends BlockContainerBase { public int extend; public static final int maxExtend = 25; - public boolean isRetracting; + public boolean isRetracting = true; public int delay; - private int lastState; + //prevents funkies from happening with block updates or loading into a server + private boolean lastState; public TileEntityPistonInserter() { } @@ -157,6 +226,33 @@ public class PistonInserter extends BlockContainerBase { this.slot = null; } + /* :3 NBT stuff */ + + @Override + public void writeToNBT(NBTTagCompound nbt) { + nbt.setInteger("extend", extend); + nbt.setBoolean("retract", isRetracting); + nbt.setBoolean("state", lastState); //saved so loading into a world doesn't cause issues + if(this.slot != null) { + NBTTagCompound stack = new NBTTagCompound(); + slot.writeToNBT(stack); + nbt.setTag("stack", stack); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + this.extend = nbt.getInteger("extend"); + this.isRetracting = nbt.getBoolean("retract"); + this.lastState = nbt.getBoolean("state"); + if(nbt.hasKey("stack")) { + NBTTagCompound stack = nbt.getCompoundTag("stack"); + this.slot = ItemStack.loadItemStackFromNBT(stack); + } else { + this.slot = null; + } + } + /* BS inventory stuff */ @Override public int getSizeInventory() { return 1; } 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 909620e26..8e45d7aec 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java @@ -5,9 +5,11 @@ import java.util.Random; import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockFlammable; +import com.hbm.inventory.RecipesCommon.MetaBlock; import com.hbm.items.ModItems; import com.hbm.lib.RefStrings; +import api.hbm.block.IInsertable; import api.hbm.block.IToolable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -17,11 +19,13 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements IToolable { +public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements IToolable, IInsertable { @SideOnly(Side.CLIENT) protected IIcon sideIcon; @@ -89,7 +93,7 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements if(side == cfg * 2 || side == cfg * 2 + 1) { world.setBlock(x, y, z, ModBlocks.block_graphite_drilled, meta & 7, 3); - this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(getInsertedItem())); + this.ejectItem(world, x, y, z, ForgeDirection.getOrientation(side), new ItemStack(getInsertedItem(meta))); } } @@ -115,4 +119,107 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements drops.add(new ItemStack(getInsertedItem(meta), 1)); return drops; } + + //Checks the relationship between specific items and placement. + //kinda cringe but anything other than hardcoding would be overengineering this for no reason so + //all of this is destined to be changed most likely anyway + protected MetaBlock checkInteractions(ItemStack stack) { + Item item = stack.getItem(); //temp + if(item == ModItems.pile_rod_uranium) return new MetaBlock(ModBlocks.block_graphite_fuel); + if(item == ModItems.pile_rod_pu239) return new MetaBlock(ModBlocks.block_graphite_fuel, 0b1000); + if(item == ModItems.pile_rod_plutonium) return new MetaBlock(ModBlocks.block_graphite_plutonium); + if(item == ModItems.pile_rod_source) return new MetaBlock(ModBlocks.block_graphite_source); + if(item == ModItems.pile_rod_boron) return new MetaBlock(ModBlocks.block_graphite_rod); + if(item == ModItems.pile_rod_lithium) return new MetaBlock(ModBlocks.block_graphite_lithium); + if(item == ModItems.cell_tritium) return new MetaBlock(ModBlocks.block_graphite_tritium); + if(item == ModItems.pile_rod_detector) return new MetaBlock(ModBlocks.block_graphite_detector); + return null; + } + + @Override + public boolean insertItem(World world, int x, int y, int z, ForgeDirection dir, ItemStack stack) { + + if(stack == null) return false; + + MetaBlock baseBlock = checkInteractions(stack); + 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 + + if(side == pureMeta * 2 || side == pureMeta * 2 + 1) { + //first, make sure we can even push rods out + for(int i = 0; i <= 3; i++) { //limited to 3 boyos + int ix = x + dir.offsetX * i; + int iy = y + dir.offsetY * i; + int iz = z + dir.offsetZ * i; + + Block b = world.getBlock(ix, iy, iz); + + if(b instanceof BlockGraphiteDrilledBase) { + if((world.getBlockMetadata(ix, iy, iz) & 3) != pureMeta) //wrong orientation + return false; + + if(((BlockGraphiteDrilledBase)b).getInsertedItem() == null) //if there's nothing to push + break; + else if(i >= 4) //if there is stuff to push and we reach our limit + return false; + } else { + if(b.isNormalCube()) //obstructions + return false; + else //empty space? no need to search + break; + } + } + + //TODO convert old methods to use itemstack for flexibility + int oldMeta = baseMeta | baseBlock.meta; //metablocks are kinda inconvenient to work with so + Block oldBlock = baseBlock.block; + NBTTagCompound oldTag = new NBTTagCompound(); //In case of TEs + + //now actually make the change + for(int i = 0; i <= 3; i++) { //yeah yeah we know it's safe but let's be *extra cautious* of infinite loops + int ix = x + dir.offsetX * i; + int iy = y + dir.offsetY * i; + int iz = z + dir.offsetZ * i; + + Block newBlock = world.getBlock(ix, iy, iz); + + if(newBlock instanceof BlockGraphiteDrilledBase) { + int newMeta = world.getBlockMetadata(ix, iy, iz); + NBTTagCompound newTag = new NBTTagCompound(); + + if(newBlock instanceof BlockGraphiteDrilledTE) { + TileEntity te = world.getTileEntity(ix, iy, iz); + te.writeToNBT(newTag); + } + + world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 2); + + if(oldBlock instanceof BlockGraphiteDrilledTE && !oldTag.hasNoTags()) { //safety first + TileEntity te = world.getTileEntity(ix, iy, iz); + te.readFromNBT(oldTag); + } + + oldMeta = newMeta; + oldBlock = newBlock; + oldTag = newTag; + + if(oldBlock instanceof BlockGraphiteDrilled) //if there's no need to eject an item + break; + } 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); + + break; + } + } + + return true; + } + + return false; + } } diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 3e3fecd69..713923269 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -48,6 +48,7 @@ import com.hbm.blocks.generic.BlockEmitter.TileEntityEmitter; import com.hbm.blocks.generic.BlockLoot.TileEntityLoot; import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe; import com.hbm.blocks.machine.MachineFan.TileEntityFan; +import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter; import com.hbm.blocks.machine.WatzPump.TileEntityWatzPump; import com.hbm.entity.cart.*; import com.hbm.entity.effect.*; @@ -278,6 +279,7 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineCatalyticReformer.class, new RenderCatalyticReformer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineCoker.class, new RenderCoker()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFan.class, new RenderFan()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPistonInserter.class, new RenderPistonInserter()); //Foundry ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFoundryBasin.class, new RenderFoundry()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFoundryMold.class, new RenderFoundry()); diff --git a/src/main/java/com/hbm/main/ResourceManager.java b/src/main/java/com/hbm/main/ResourceManager.java index 64c2e280d..83c518d86 100644 --- a/src/main/java/com/hbm/main/ResourceManager.java +++ b/src/main/java/com/hbm/main/ResourceManager.java @@ -191,6 +191,9 @@ public class ResourceManager { //Fan public static final IModelCustom fan = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/fan.obj")); + //Piston Inserter + public static final IModelCustom piston_inserter = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/piston_inserter.obj")); + //Sphere public static final IModelCustom sphere_ruv = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/sphere_ruv.obj")); public static final IModelCustom sphere_iuv = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/sphere_iuv.obj")); @@ -538,6 +541,9 @@ public class ResourceManager { //Fan public static final ResourceLocation fan_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/fan.png"); + //Piston_Inserter + public static final ResourceLocation piston_inserter_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/piston_inserter.png"); + //Radgen public static final ResourceLocation radgen_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/radgen.png"); diff --git a/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java b/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java new file mode 100644 index 000000000..f75aa3857 --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java @@ -0,0 +1,65 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter; +import com.hbm.main.ResourceManager; +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.minecraftforge.client.IItemRenderer; + +public class RenderPistonInserter extends TileEntitySpecialRenderer implements IItemRendererProvider { + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + + switch(tile.getBlockMetadata()) { + case 0: GL11.glRotatef(180, 1F, 0F, 0F); break; + case 1: break; + case 2: GL11.glRotatef(-90, 1F, 0F, 0F); break; + case 4: GL11.glRotatef(90, 0F, 0F, 1F); break; + case 3: GL11.glRotatef(90, 1F, 0F, 0F); break; + case 5: GL11.glRotatef(-90, 0F, 0F, 1F); break; + } + + GL11.glTranslated(0D, -0.5, 0D); + + bindTexture(ResourceManager.piston_inserter_tex); + ResourceManager.piston_inserter.renderPart("Frame"); + + TileEntityPistonInserter piston = (TileEntityPistonInserter)tile; + double e = piston.extend / (double)piston.maxExtend; + GL11.glTranslated(0, -e, 0); + ResourceManager.piston_inserter.renderPart("Piston"); + + GL11.glPopMatrix(); + } + + @Override + public Item getItemForRenderer() { + return Item.getItemFromBlock(ModBlocks.piston_inserter); + } + + @Override + public IItemRenderer getRenderer() { + return new ItemRenderBase() { + public void renderInventory() { + GL11.glTranslated(0, -2.5, 0); + double scale = 5; + GL11.glScaled(scale, scale, scale); + } + public void renderCommon() { + GL11.glScaled(2, 2, 2); + bindTexture(ResourceManager.piston_inserter_tex); + ResourceManager.piston_inserter.renderAll(); + }}; + } +} diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 4426db9ed..9f1b24737 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -13,6 +13,7 @@ import com.hbm.blocks.generic.BlockMotherOfAllOres.TileEntityRandomOre; import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe; import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter; import com.hbm.blocks.machine.MachineFan.TileEntityFan; +import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter; import com.hbm.blocks.machine.WatzPump.TileEntityWatzPump; import com.hbm.blocks.network.BlockCablePaintable.TileEntityCablePaintable; import com.hbm.blocks.network.CableDiode.TileEntityDiode; @@ -360,6 +361,7 @@ public class TileMappings { put(TileEntityCraneRouter.class, "tileentity_router"); put(TileEntityCraneSplitter.class, "tileentity_splitter"); put(TileEntityFan.class, "tileentity_fan"); + put(TileEntityPistonInserter.class, "tileentity_piston_inserter"); put(TileEntityRadioTorchSender.class, "tileentity_rtty_sender"); put(TileEntityRadioTorchReceiver.class, "tileentity_rtty_rec"); diff --git a/src/main/resources/assets/hbm/models/machines/piston_inserter.obj b/src/main/resources/assets/hbm/models/machines/piston_inserter.obj new file mode 100644 index 000000000..8d78694b6 --- /dev/null +++ b/src/main/resources/assets/hbm/models/machines/piston_inserter.obj @@ -0,0 +1,379 @@ +# Blender v3.2.0 OBJ File: 'piston_inserter.blend' +# www.blender.org +mtllib piston_inserter.mtl +o Frame +v -0.125000 0.000000 0.125000 +v -0.125000 1.000000 0.125000 +v -0.125000 0.000000 -0.125000 +v -0.125000 1.000000 -0.125000 +v 0.125000 0.000000 0.125000 +v 0.125000 1.000000 0.125000 +v 0.125000 0.000000 -0.125000 +v 0.125000 1.000000 -0.125000 +v -0.500000 1.000000 0.500000 +v -0.500000 1.000000 -0.500000 +v 0.500000 1.000000 -0.500000 +v 0.500000 1.000000 0.500000 +v -0.500000 0.000000 -0.500000 +v -0.500000 0.000000 0.500000 +v 0.500000 0.000000 -0.500000 +v 0.500000 0.000000 0.500000 +v -0.375000 1.000000 0.375000 +v -0.375000 1.000000 -0.375000 +v 0.375000 1.000000 -0.375000 +v 0.375000 1.000000 0.375000 +v -0.375000 0.000000 -0.375000 +v -0.375000 0.000000 0.375000 +v 0.375000 0.000000 -0.375000 +v 0.375000 0.000000 0.375000 +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.004327 0.858644 -0.020544 +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 +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 +vt 0.571429 0.666667 +vt 0.000000 0.333333 +vt 0.571429 0.333333 +vt 0.571429 0.666667 +vt -0.000000 0.333333 +vt 0.571429 0.333333 +vt 0.571429 0.666667 +vt -0.000000 0.333333 +vt 0.571429 0.333333 +vt 0.571429 0.666667 +vt -0.000000 0.333333 +vt 0.571429 0.333333 +vt 0.714286 0.416667 +vt 0.571429 0.333333 +vt 0.714286 0.333333 +vt 0.714286 0.750000 +vt 0.571429 0.833333 +vt 0.571429 0.750000 +vt 0.071429 0.708333 +vt 0.500000 0.708333 +vt 0.071429 0.958333 +vt 0.000000 0.666667 +vt 0.500000 0.958333 +vt 0.000000 1.000000 +vt 0.571429 1.000000 +vt 0.500000 0.041667 +vt 0.500000 0.291667 +vt 0.071429 0.291667 +vt 0.000000 0.000000 +vt 0.071429 0.041667 +vt 0.571429 0.000000 +vt 0.714286 0.416667 +vt 0.571429 0.750000 +vt 0.571429 0.416667 +vt 0.714286 0.416667 +vt 0.571429 0.750000 +vt 0.571429 0.416667 +vt 0.714286 0.416667 +vt 0.571429 0.750000 +vt 0.571429 0.416667 +vt 0.714286 0.416667 +vt 0.571429 0.750000 +vt 0.571429 0.416667 +vt 0.571429 -0.000000 +vt 1.000000 0.333333 +vt 0.571429 0.333333 +vt 0.571429 0.000000 +vt 1.000000 0.333333 +vt 0.571429 0.333333 +vt 0.571429 0.000000 +vt 1.000000 0.333333 +vt 0.571429 0.333333 +vt 0.571429 0.000000 +vt 1.000000 0.333333 +vt 0.571429 0.333333 +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 +vt 0.571429 0.416667 +vt 0.714286 0.833333 +vt 0.714286 0.750000 +vt 0.714286 0.750000 +vt 0.714286 0.750000 +vt 0.714286 0.750000 +vt 1.000000 -0.000000 +vt 1.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 -0.000000 +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 +vn 0.0000 0.0000 1.0000 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 1.0000 0.0000 +usemtl None +s off +f 9/1/1 13/2/1 14/3/1 +f 10/4/2 15/5/2 13/6/2 +f 11/7/3 16/8/3 15/9/3 +f 12/10/4 14/11/4 16/12/4 +f 7/13/5 1/14/5 3/15/5 +f 4/16/6 6/17/6 8/18/6 +f 18/19/6 9/1/6 17/20/6 +f 19/21/6 10/22/6 18/19/6 +f 20/23/6 11/24/6 19/21/6 +f 17/20/6 12/25/6 20/23/6 +f 22/26/5 13/6/5 21/27/5 +f 21/27/5 15/5/5 23/28/5 +f 23/28/5 16/29/5 24/30/5 +f 24/30/5 14/31/5 22/26/5 +f 8/32/2 3/33/2 4/34/2 +f 6/35/3 7/36/3 8/37/3 +f 2/38/4 5/39/4 6/40/4 +f 4/41/1 1/42/1 2/43/1 +f 23/44/1 20/45/1 19/46/1 +f 24/47/2 17/48/2 20/49/2 +f 22/50/3 18/51/3 17/52/3 +f 21/53/4 19/54/4 18/55/4 +f 27/56/5 28/57/5 25/58/5 +f 34/59/5 35/60/5 32/61/5 +f 40/62/5 41/63/5 38/64/5 +f 46/65/5 47/66/5 44/67/5 +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 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 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 +f 17/20/6 9/1/6 12/25/6 +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 +l 27 29 +o Piston +v -0.062500 1.000000 0.062500 +v -0.125000 1.062500 0.125000 +v -0.062500 1.000000 -0.062500 +v -0.125000 1.062500 -0.125000 +v 0.062500 1.000000 0.062500 +v 0.125000 1.062500 0.125000 +v 0.062500 1.000000 -0.062500 +v 0.125000 1.062500 -0.125000 +v -0.125000 1.000000 -0.125000 +v -0.125000 1.000000 0.125000 +v 0.125000 1.000000 -0.125000 +v 0.125000 1.000000 0.125000 +v -0.062500 0.062500 -0.062500 +v -0.062500 0.062500 0.062500 +v 0.062500 0.062500 -0.062500 +v 0.062500 0.062500 0.062500 +vt 0.857143 0.708333 +vt 0.714286 0.687500 +vt 0.857143 0.687500 +vt 0.857143 0.708333 +vt 0.714286 0.687500 +vt 0.857143 0.687500 +vt 0.857143 0.708333 +vt 0.714286 0.687500 +vt 0.857143 0.687500 +vt 0.857143 0.708333 +vt 0.714286 0.687500 +vt 0.857143 0.687500 +vt 0.821429 0.375000 +vt 0.750000 0.687500 +vt 0.750000 0.375000 +vt 0.857143 0.791667 +vt 0.714286 0.875000 +vt 0.714286 0.791667 +vt 0.821429 0.770833 +vt 0.714286 0.791667 +vt 0.750000 0.770833 +vt 0.714286 0.708333 +vt 0.750000 0.729167 +vt 0.857143 0.708333 +vt 0.821429 0.729167 +vt 0.857143 0.791667 +vt 0.821429 0.333333 +vt 0.750000 0.375000 +vt 0.750000 0.333333 +vt 0.821429 0.375000 +vt 0.750000 0.687500 +vt 0.750000 0.375000 +vt 0.821429 0.375000 +vt 0.750000 0.687500 +vt 0.750000 0.375000 +vt 0.821429 0.375000 +vt 0.750000 0.687500 +vt 0.750000 0.375000 +vt 0.714286 0.708333 +vt 0.714286 0.708333 +vt 0.714286 0.708333 +vt 0.714286 0.708333 +vt 0.821429 0.687500 +vt 0.857143 0.875000 +vt 0.821429 0.375000 +vt 0.821429 0.687500 +vt 0.821429 0.687500 +vt 0.821429 0.687500 +vn -1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 1.0000 +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 diff --git a/src/main/resources/assets/hbm/textures/models/machines/piston_inserter.png b/src/main/resources/assets/hbm/textures/models/machines/piston_inserter.png new file mode 100644 index 0000000000000000000000000000000000000000..86e8b0b8a4b3f7018233bfba22f9e72e432f55c8 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^GC*v=!3-o#_r7`!q!^2X+?^QKos)S9y9W4#xEdH3I5;?Xcz8raMELmlXlQ6GSg>I8=FL~HUOjf~*tKid8kLk5 zXlWfYF}Z4PejzGqv%daOW8;HiVMmW1m6MZ`l#~RT#J+tpJCG7D3Gxg6j}q~1x*3Op^0tseF3zPwjqRs#5ky=^x9Ui~SJ? zBH3$u9-650N*5%avl136;bOg2oD?wUxQF7Zt#f)gu1`7P_h1U|yX9H-(iJ5%(d zpk=QmAG~%y-|*=4?p?bZHU{wQN#0N*KEW~h$BMUpT23vY5t}SST5j#^wBBiJkZve! zDZL^vn1AamR{v)?3$88-`mu7s_SIMJ+L|mZ*}nPwrIif#e@C8QW9nY?PCPEp;%27W S1wCL0GkCiCxvX Date: Mon, 15 May 2023 19:46:19 -0700 Subject: [PATCH 3/8] Piston inserter fixed, some crucial bug fixes in the pile insertion --- .../hbm/blocks/machine/PistonInserter.java | 55 ++-- .../pile/BlockGraphiteDrilledBase.java | 21 +- .../tileentity/RenderPistonInserter.java | 5 +- .../hbm/models/machines/piston_inserter.obj | 258 +++++++++++++----- 4 files changed, 247 insertions(+), 92 deletions(-) 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 From 2ea60eae1374818c5e6fb2c719c7fc3cd0e722a4 Mon Sep 17 00:00:00 2001 From: Vaern Date: Mon, 15 May 2023 22:52:32 -0700 Subject: [PATCH 4/8] Fixes! --- .../java/com/hbm/blocks/machine/PistonInserter.java | 5 ++++- .../blocks/machine/pile/BlockGraphiteDrilledBase.java | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index b42828c0b..d0725186f 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -109,7 +109,8 @@ public class PistonInserter extends BlockContainerBase { @Override public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return world.getBlockMetadata(x, y, z) != side.ordinal(); + int meta = world.getBlockMetadata(x, y, z); + return meta != side.ordinal() && meta != side.getOpposite().ordinal(); } @Override @@ -274,6 +275,8 @@ public class PistonInserter extends BlockContainerBase { } } + //TODO: render AABB that extends out in direction of piston so it will render + /* BS inventory stuff */ @Override public int getSizeInventory() { return 1; } 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 9d8b2fc8f..19adfb63e 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java @@ -177,6 +177,9 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements 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 + oldTag.setInteger("x", x); //giving tags prevents issues and resets any lingering tes. + oldTag.setInteger("y", y); + oldTag.setInteger("z", z); //now actually make the change for(int i = 0; i <= 3; i++) { //yeah yeah we know it's safe but let's be *extra cautious* of infinite loops @@ -193,15 +196,13 @@ 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); + newTag.setInteger("x", te.xCoord + dir.offsetX); //malformed positions is very very bad and prevents the pile TEs from ticking + newTag.setInteger("y", te.yCoord + dir.offsetY); + newTag.setInteger("z", te.zCoord + 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); From 5f27a78bcb844ebf4bce6f9876ce3ece951c0d5e Mon Sep 17 00:00:00 2001 From: Vaern Date: Tue, 16 May 2023 15:09:11 -0700 Subject: [PATCH 5/8] Fixed piston display, fixed critical issue, added comparator output still need fixes --- .../hbm/blocks/machine/PistonInserter.java | 8 +++- .../machine/pile/BlockGraphiteFuel.java | 12 ++++++ .../tileentity/RenderPistonInserter.java | 42 +++++++++++++++++-- .../machine/pile/TileEntityPileFuel.java | 20 +++++++-- 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index d0725186f..70defcb86 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -71,7 +71,7 @@ public class PistonInserter extends BlockContainerBase { if(!world.isRemote) { TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z); - if(piston.slot != null) { + if(piston.slot != null && piston.isRetracting) { ForgeDirection dir = ForgeDirection.getOrientation(piston.getBlockMetadata()); EntityItem dust = new EntityItem(world, x + 0.5D + dir.offsetX * 0.75D, y + 0.5D + dir.offsetY * 0.75D, z + 0.5D + dir.offsetZ * 0.75D, piston.slot); @@ -113,6 +113,8 @@ public class PistonInserter extends BlockContainerBase { return meta != side.ordinal() && meta != side.getOpposite().ordinal(); } + //TODO make item drop when block is broken + @Override public int getRenderType(){ return -1; @@ -252,6 +254,7 @@ public class PistonInserter extends BlockContainerBase { @Override public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); nbt.setInteger("extend", extend); nbt.setBoolean("retract", isRetracting); nbt.setBoolean("state", lastState); //saved so loading into a world doesn't cause issues @@ -264,10 +267,11 @@ public class PistonInserter extends BlockContainerBase { @Override public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); this.extend = nbt.getInteger("extend"); this.isRetracting = nbt.getBoolean("retract"); this.lastState = nbt.getBoolean("state"); - if(nbt.hasKey("stack")) { + if(nbt.hasKey("stack")) { //TODO double check that these work NBTTagCompound stack = nbt.getCompoundTag("stack"); this.slot = ItemStack.loadItemStackFromNBT(stack); } else { diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java index 3a315e2cf..74281a5e3 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java @@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -34,6 +35,17 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_fuel_aluminum"); } + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { //serverside? maybe + TileEntityPileFuel pile = (TileEntityPileFuel)world.getTileEntity(x, y, z); + return MathHelper.clamp_int((pile.progress * 16) / pile.maxProgress, 0, 15); //potentially wip + } + @Override public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { diff --git a/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java b/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java index dc15763fe..e09129898 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java +++ b/src/main/java/com/hbm/render/tileentity/RenderPistonInserter.java @@ -6,11 +6,16 @@ import com.hbm.blocks.ModBlocks; import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter; import com.hbm.main.ResourceManager; import com.hbm.render.item.ItemRenderBase; +import com.hbm.render.util.RenderDecoItem; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraftforge.client.IItemRenderer; public class RenderPistonInserter extends TileEntitySpecialRenderer implements IItemRendererProvider { @@ -25,10 +30,13 @@ public class RenderPistonInserter extends TileEntitySpecialRenderer implements I switch(tile.getBlockMetadata()) { case 0: GL11.glRotatef(180, 1F, 0F, 0F); break; case 1: break; - case 2: GL11.glRotatef(-90, 1F, 0F, 0F); break; - case 4: GL11.glRotatef(90, 0F, 0F, 1F); break; + case 2: GL11.glRotatef(-90, 1F, 0F, 0F); + GL11.glRotatef(180, 0F, 1F, 0F); break; + case 4: GL11.glRotatef(90, 0F, 0F, 1F); + GL11.glRotatef(-90, 0F, 1F, 0F); break; case 3: GL11.glRotatef(90, 1F, 0F, 0F); break; - case 5: GL11.glRotatef(-90, 0F, 0F, 1F); break; + case 5: GL11.glRotatef(-90, 0F, 0F, 1F); + GL11.glRotatef(90, 0F, 1F, 0F); break; } GL11.glTranslated(0D, -0.5, 0D); @@ -40,6 +48,32 @@ public class RenderPistonInserter extends TileEntitySpecialRenderer implements I double e = (piston.lastExtend + (piston.renderExtend - piston.lastExtend) * interp) / (double) piston.maxExtend; GL11.glTranslated(0, e * 0.9375D, 0); ResourceManager.piston_inserter.renderPart("Piston"); + + RenderItem itemRenderer = new RenderDecoItem(this); + itemRenderer.setRenderManager(RenderManager.instance); + + if(piston.slot != null) { + ItemStack stack = piston.slot.copy(); + + EntityItem item = new EntityItem(null, 0.0D, 0.0D, 0.0D, stack); + item.getEntityItem().stackSize = 1; + item.hoverStart = 0.0F; + + if(stack.getItem() instanceof ItemBlock) { + GL11.glTranslated(0.0D, 1.125D, 0.0D); + } else { + GL11.glTranslated(0.0D, 1.0625D, 0.1D); + if(!RenderManager.instance.options.fancyGraphics) + GL11.glTranslated(0.0D, 0.01D, 0.0D); + + GL11.glRotated(90, -1, 0, 0); + } + + RenderItem.renderInFrame = true; + itemRenderer.doRender(item, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + } + GL11.glPopMatrix(); } diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java index 869971e6f..7b00d14e2 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java @@ -9,6 +9,7 @@ import com.hbm.packet.PacketDispatcher; import api.hbm.block.IPileNeutronReceiver; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutronReceiver { @@ -24,7 +25,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr if(!worldObj.isRemote) { dissipateHeat(); - react(); + checkRedstone(react()); transmute(); if(this.heat >= this.maxHeat) { @@ -53,22 +54,35 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr this.heat -= (this.getBlockMetadata() & 4) == 4 ? heat * 0.065 : heat * 0.05; //remove 5% of the stored heat per tick; 6.5% for windscale } - private void react() { + private int react() { int reaction = (int) (this.neutrons * (1D - ((double)this.heat / (double)this.maxHeat) * 0.5D)); //max heat reduces reaction by 50% due to thermal expansion this.lastNeutrons = this.neutrons; this.neutrons = 0; + int lastProgress = this.progress; + this.progress += reaction; if(reaction <= 0) - return; + return lastProgress; this.heat += reaction; for(int i = 0; i < 12; i++) this.castRay((int) Math.max(reaction * 0.25, 1), 5); + + return lastProgress; + } + + private void checkRedstone(int lastProgress) { + int lastLevel = MathHelper.clamp_int((lastProgress * 16) / maxProgress, 0, 15); + int newLevel = MathHelper.clamp_int((progress * 16) / maxProgress, 0, 15); + if(lastLevel != newLevel) //TODO TEST + System.out.println(lastLevel + ", " + newLevel + "; " + lastProgress + ", " + progress); + if(lastLevel != newLevel) //the block update doesn't seem to update the comparators... need to troubleshoot and fix + worldObj.scheduleBlockUpdate(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1); //TODO test } private void transmute() { From d871e46b9f689970021d1414b6809f15751f7d05 Mon Sep 17 00:00:00 2001 From: Vaern Date: Tue, 16 May 2023 19:58:15 -0700 Subject: [PATCH 6/8] Fixes o'plenty, nearing completion --- .../hbm/blocks/machine/PistonInserter.java | 19 ++++++++++++++++--- .../pile/BlockGraphiteDrilledBase.java | 4 +++- .../machine/pile/BlockGraphiteFuel.java | 10 +++++++--- .../machine/pile/TileEntityPileFuel.java | 8 +++----- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index 70defcb86..8dd6114df 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -16,6 +16,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -179,7 +180,7 @@ public class PistonInserter extends BlockContainerBase { @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 + @SideOnly(Side.CLIENT) private int turnProgress; public TileEntityPistonInserter() { } @@ -271,7 +272,7 @@ public class PistonInserter extends BlockContainerBase { this.extend = nbt.getInteger("extend"); this.isRetracting = nbt.getBoolean("retract"); this.lastState = nbt.getBoolean("state"); - if(nbt.hasKey("stack")) { //TODO double check that these work + if(nbt.hasKey("stack")) { NBTTagCompound stack = nbt.getCompoundTag("stack"); this.slot = ItemStack.loadItemStackFromNBT(stack); } else { @@ -279,7 +280,19 @@ public class PistonInserter extends BlockContainerBase { } } - //TODO: render AABB that extends out in direction of piston so it will render + @SideOnly(Side.CLIENT) + private AxisAlignedBB aabb; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + + if(aabb != null) + return aabb; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); + aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).addCoord(dir.offsetX, dir.offsetY, dir.offsetZ); + return aabb; + } /* BS inventory 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 19adfb63e..58ec7bce2 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteDrilledBase.java @@ -201,13 +201,15 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements newTag.setInteger("z", te.zCoord + dir.offsetZ); } - world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 2); + world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 0); if(oldBlock instanceof BlockGraphiteDrilledTE && !oldTag.hasNoTags()) { //safety first TileEntity te = world.getTileEntity(ix, iy, iz); te.readFromNBT(oldTag); } + world.markAndNotifyBlock(ix, iy, iz, world.getChunkFromBlockCoords(ix, iz), newBlock, oldBlock, 3); //in case setBlock returns false due to = meta / block + oldMeta = newMeta; oldBlock = newBlock; oldTag = newTag; diff --git a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java index 74281a5e3..cc98534da 100644 --- a/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java +++ b/src/main/java/com/hbm/blocks/machine/pile/BlockGraphiteFuel.java @@ -24,8 +24,12 @@ import net.minecraftforge.common.util.ForgeDirection; public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolable, IBlowable { @Override - public TileEntity createNewTileEntity(World world, int mets) { - return new TileEntityPileFuel(); + public TileEntity createNewTileEntity(World world, int meta) { + TileEntityPileFuel pile = new TileEntityPileFuel(); + if((meta & 8) != 0) + pile.progress = pile.maxProgress - 1000; // pu239 rods cringe :( + + return pile; } @Override @@ -41,7 +45,7 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab } @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int side) { //serverside? maybe + public int getComparatorInputOverride(World world, int x, int y, int z, int side) { TileEntityPileFuel pile = (TileEntityPileFuel)world.getTileEntity(x, y, z); return MathHelper.clamp_int((pile.progress * 16) / pile.maxProgress, 0, 15); //potentially wip } diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java index 7b00d14e2..15233ad0c 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileFuel.java @@ -18,7 +18,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr public int neutrons; public int lastNeutrons; public int progress; - public static final int maxProgress = GeneralConfig.enable528 ? 75000 : 50000; + public static final int maxProgress = GeneralConfig.enable528 ? 75000 : 50000; //might double to reduce compact setup's effectiveness @Override public void updateEntity() { @@ -79,10 +79,8 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr private void checkRedstone(int lastProgress) { int lastLevel = MathHelper.clamp_int((lastProgress * 16) / maxProgress, 0, 15); int newLevel = MathHelper.clamp_int((progress * 16) / maxProgress, 0, 15); - if(lastLevel != newLevel) //TODO TEST - System.out.println(lastLevel + ", " + newLevel + "; " + lastProgress + ", " + progress); - if(lastLevel != newLevel) //the block update doesn't seem to update the comparators... need to troubleshoot and fix - worldObj.scheduleBlockUpdate(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1); //TODO test + if(lastLevel != newLevel) + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType()); } private void transmute() { From b68b83e2e28a21ed0c99a97e621e97030da806e9 Mon Sep 17 00:00:00 2001 From: Vaern Date: Wed, 17 May 2023 07:47:32 -0700 Subject: [PATCH 7/8] Finishing touches i mean i think that's everything? --- .../hbm/blocks/machine/PistonInserter.java | 41 ++++++++++++++++++- .../java/com/hbm/main/CraftingManager.java | 3 +- src/main/resources/assets/hbm/lang/en_US.lang | 1 + 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/PistonInserter.java b/src/main/java/com/hbm/blocks/machine/PistonInserter.java index 8dd6114df..91e3e25b1 100644 --- a/src/main/java/com/hbm/blocks/machine/PistonInserter.java +++ b/src/main/java/com/hbm/blocks/machine/PistonInserter.java @@ -114,7 +114,46 @@ public class PistonInserter extends BlockContainerBase { return meta != side.ordinal() && meta != side.getOpposite().ordinal(); } - //TODO make item drop when block is broken + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + IInventory tileentityfurnace = (IInventory) world.getTileEntity(x, y, z); + + if(tileentityfurnace != null) { + + ItemStack itemstack = tileentityfurnace.getStackInSlot(0); + + if(itemstack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + + while(itemstack.stackSize > 0) { + int j1 = world.rand.nextInt(21) + 10; + + if(j1 > itemstack.stackSize) { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if(itemstack.hasTagCompound()) { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (float) world.rand.nextGaussian() * f3; + entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) world.rand.nextGaussian() * f3; + world.spawnEntityInWorld(entityitem); + } + } + + world.func_147453_f(x, y, z, block); + } + + super.breakBlock(world, x, y, z, block, meta); + } @Override public int getRenderType(){ diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index baadb5428..77f0c09fa 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -308,7 +308,8 @@ public class CraftingManager { addRecipeAuto(new ItemStack(ModBlocks.furnace_iron), new Object[] { "III", "IFI", "BBB", 'I', IRON.ingot(), 'F', Blocks.furnace, 'B', Blocks.stonebrick }); addRecipeAuto(new ItemStack(ModBlocks.machine_mixer), new Object[] { "PIP", "GCG", "PMP", 'P', STEEL.plate(), 'I', DURA.ingot(), 'G', KEY_ANYPANE, 'C', ModItems.circuit_copper, 'M', ModItems.motor }); addRecipeAuto(new ItemStack(ModBlocks.fan), new Object[] { "BPB", "PRP", "BPB", 'B', ModItems.bolt_tungsten, 'P', IRON.plate(), 'R', REDSTONE.dust() }); - + addRecipeAuto(new ItemStack(ModBlocks.piston_inserter), new Object[] { "ITI", "TPT", "ITI", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', IRON.plate(), 'T', ModItems.bolt_tungsten }); + addRecipeAuto(new ItemStack(ModBlocks.muffler, 1), new Object[] { "III", "IWI", "III", 'I', ModItems.plate_polymer, 'W', Blocks.wool }); addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.factory_titanium_hull), 8), new Object[] { "PIP", "I I", "PIP", 'P', TI.plate(), 'I', TI.ingot() }); diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index e2b518d48..5af3a39a9 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -4462,6 +4462,7 @@ tile.deco_beryllium.name=Beryllium Deco Block tile.deco_computer.ibm_300pl.name=IBM Personal Computer 300PL tile.deco_emitter.name=Deco Light Emitter tile.part_emitter.name=Deco Particle Emitter +tile.piston_inserter.name=Inserter tile.deco_lead.name=Lead Deco Block tile.deco_rbmk.name=RBMK Deco Block tile.deco_rbmk_smooth.name=Smooth RBMK Deco Block From 9ce84ac921f9a7b8e3c60cee210712b7bb81b742 Mon Sep 17 00:00:00 2001 From: Vaern Date: Wed, 17 May 2023 07:58:43 -0700 Subject: [PATCH 8/8] whooooops --- .../com/hbm/tileentity/machine/pile/TileEntityPileSource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java index 0c164657f..c297f9dfb 100644 --- a/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java +++ b/src/main/java/com/hbm/tileentity/machine/pile/TileEntityPileSource.java @@ -11,7 +11,7 @@ public class TileEntityPileSource extends TileEntityPileBase { int n = this.getBlockType() == ModBlocks.block_graphite_source ? 1 : 2; - for(int i = 0; i < 12 * 5; i++) { + for(int i = 0; i < 12; i++) { this.castRay(n, 5); } }