From 801fdc146cfc998f1e135f5feb3d4e3977af7c1d Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 7 Oct 2025 16:30:15 +0200 Subject: [PATCH] scrungus --- changelog | 5 +- .../java/api/hbm/energymk2/Nodespace.java | 1 + src/main/java/com/hbm/blocks/ModBlocks.java | 4 + .../hbm/blocks/network/FluidPipeAnchor.java | 74 +++++++ .../com/hbm/blocks/network/PylonBase.java | 2 +- .../hbm/explosion/vanillant/ExplosionVNT.java | 7 +- .../standard/BlockAllocatorBulkie.java | 2 - .../standard/BlockAllocatorGlyphidDig.java | 2 - .../standard/BlockAllocatorStandard.java | 2 - .../standard/BlockAllocatorWater.java | 2 - .../java/com/hbm/itempool/ItemPoolsPile.java | 3 +- src/main/java/com/hbm/items/ModItems.java | 7 +- .../java/com/hbm/items/tool/ItemWiring.java | 2 +- .../java/com/hbm/items/tool/ItemWrench.java | 141 ++++++++++++++ .../com/hbm/items/tool/WeaponSpecial.java | 5 +- src/main/java/com/hbm/main/ServerProxy.java | 1 + .../com/hbm/render/util/RenderInfoSystem.java | 4 +- .../java/com/hbm/tileentity/TileMappings.java | 2 + .../network/TileEntityPipeAnchor.java | 44 +++++ .../network/TileEntityPipelineBase.java | 182 ++++++++++++++++++ 20 files changed, 465 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/hbm/blocks/network/FluidPipeAnchor.java create mode 100644 src/main/java/com/hbm/items/tool/ItemWrench.java create mode 100644 src/main/java/com/hbm/tileentity/network/TileEntityPipeAnchor.java create mode 100644 src/main/java/com/hbm/tileentity/network/TileEntityPipelineBase.java diff --git a/changelog b/changelog index 91998e222..868af6d84 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,5 @@ ## Changed -* Updated russian and chinese localiazation +* Updated russian and chinese localization * VNT type explosions now track affected block positions when the explosion events fire, this should ensure compatibility with mods that rely on that * For example, this should make ForgeCreeperHeal work with most of NTM's explosions * Obliterated standard fluid IDs @@ -13,4 +13,5 @@ * Fixed the T-51b set not having radiation resistance * Potentially fixed a crash on thermos-derived servers involving the flow control pumps * Fixed crash caused when another tile entity replaces an RBMK component due to an unchecked cast -* Fixed constant cascading chunk gen caused by meteorites and flower patches \ No newline at end of file +* Fixed constant cascading chunk gen caused by meteorites and flower patches +* Fixed garbage loot pool sometimes producing "stone wires" \ No newline at end of file diff --git a/src/main/java/api/hbm/energymk2/Nodespace.java b/src/main/java/api/hbm/energymk2/Nodespace.java index 114c4dd75..9472263e2 100644 --- a/src/main/java/api/hbm/energymk2/Nodespace.java +++ b/src/main/java/api/hbm/energymk2/Nodespace.java @@ -16,6 +16,7 @@ import net.minecraft.world.World; * * @author hbm */ +@NotableComments public class Nodespace { public static final PowerNetProvider THE_POWER_PROVIDER = new PowerNetProvider(); diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index bd6c16ccd..a10975b9c 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -792,6 +792,7 @@ public class ModBlocks { public static Block fluid_duct_gauge; public static Block fluid_duct_exhaust; public static Block fluid_duct_paintable_block_exhaust; + public static Block pipe_anchor; public static Block fluid_valve; public static Block fluid_switch; public static Block fluid_pump; @@ -1933,6 +1934,7 @@ public class ModBlocks { fluid_duct_box = new FluidDuctBox(Material.iron).setBlockName("fluid_duct_box").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fluid_duct_box"); fluid_duct_exhaust = new FluidDuctBoxExhaust(Material.iron).setBlockName("fluid_duct_exhaust").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fluid_duct_box"); fluid_duct_paintable_block_exhaust = new FluidDuctPaintableBlockExhaust().setBlockName("fluid_duct_paintable_block_exhaust").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); + pipe_anchor = new FluidPipeAnchor().setBlockName("pipe_anchor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); fluid_duct_paintable = new FluidDuctPaintable().setBlockName("fluid_duct_paintable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); fluid_duct_gauge = new FluidDuctGauge().setBlockName("fluid_duct_gauge").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); fluid_valve = new FluidValve(Material.iron).setBlockName("fluid_valve").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); @@ -3216,11 +3218,13 @@ public class ModBlocks { GameRegistry.registerBlock(cable_detector, cable_detector.getUnlocalizedName()); GameRegistry.registerBlock(cable_diode, ItemBlockBase.class, cable_diode.getUnlocalizedName()); GameRegistry.registerBlock(machine_detector, machine_detector.getUnlocalizedName()); + register(fluid_duct_neo); register(fluid_duct_box); register(fluid_duct_exhaust); register(fluid_duct_paintable_block_exhaust); register(fluid_duct_paintable); + register(pipe_anchor); register(fluid_duct_gauge); register(fluid_valve); register(fluid_switch); diff --git a/src/main/java/com/hbm/blocks/network/FluidPipeAnchor.java b/src/main/java/com/hbm/blocks/network/FluidPipeAnchor.java new file mode 100644 index 000000000..d99a57e8b --- /dev/null +++ b/src/main/java/com/hbm/blocks/network/FluidPipeAnchor.java @@ -0,0 +1,74 @@ +package com.hbm.blocks.network; + +import java.util.List; + +import com.hbm.blocks.ITooltipProvider; +import com.hbm.lib.Library; +import com.hbm.tileentity.network.TileEntityPipeAnchor; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class FluidPipeAnchor extends BlockContainer implements ITooltipProvider { + + public FluidPipeAnchor() { + super(Material.iron); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityPipeAnchor(); + } + + @Override public int getRenderType() { return -1; } + @Override public boolean isOpaqueCube() { return false; } + @Override public boolean renderAsNormalBlock() { return false; } + + @Override + public int onBlockPlaced(World world, int x, int y, int z, int side, float fX, float fY, float fZ, int meta) { + return side; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBounds(world.getBlockMetadata(x, y, z)); + return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + setBlockBounds(world.getBlockMetadata(x, y, z)); + } + + private void setBlockBounds(int meta) { + + float pixel = 0.0625F; + float min = pixel * 5F; + float max = pixel * 11F; + + ForgeDirection dir = ForgeDirection.getOrientation(meta).getOpposite(); + + float minX = dir == Library.NEG_X ? 0F : min; + float maxX = dir == Library.POS_X ? 1F : max; + float minY = dir == Library.NEG_Y ? 0F : min; + float maxY = dir == Library.POS_Y ? 1F : max; + float minZ = dir == Library.NEG_Z ? 0F : min; + float maxZ = dir == Library.POS_Z ? 1F : max; + + this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { + list.add(EnumChatFormatting.GOLD + "Connection Type: " + EnumChatFormatting.YELLOW + "Single"); + list.add(EnumChatFormatting.GOLD + "Connection Range: " + EnumChatFormatting.YELLOW + "10m"); + } +} diff --git a/src/main/java/com/hbm/blocks/network/PylonBase.java b/src/main/java/com/hbm/blocks/network/PylonBase.java index 95a2476f7..e1922c876 100644 --- a/src/main/java/com/hbm/blocks/network/PylonBase.java +++ b/src/main/java/com/hbm/blocks/network/PylonBase.java @@ -28,7 +28,7 @@ public abstract class PylonBase extends BlockContainer implements ITooltipProvid } @Override - public int getRenderType(){ + public int getRenderType() { return -1; } diff --git a/src/main/java/com/hbm/explosion/vanillant/ExplosionVNT.java b/src/main/java/com/hbm/explosion/vanillant/ExplosionVNT.java index e1c217617..8529cdc38 100644 --- a/src/main/java/com/hbm/explosion/vanillant/ExplosionVNT.java +++ b/src/main/java/com/hbm/explosion/vanillant/ExplosionVNT.java @@ -83,16 +83,15 @@ public class ExplosionVNT { //allocation if(processBlocks) affectedBlocks = blockAllocator.allocate(this, world, posX, posY, posZ, size); + if(processBlocks) this.compat.affectedBlockPositions.addAll(affectedBlocks); if(processEntities) affectedPlayers = entityProcessor.process(this, world, posX, posY, posZ, size); + // technically not necessary, as the affected entity list is a separate parameter during the Detonate event + if(processEntities) this.compatPlayers.putAll(affectedPlayers); //serverside processing if(processBlocks) blockProcessor.process(this, world, posX, posY, posZ, affectedBlocks); if(processEntities) playerProcessor.process(this, world, posX, posY, posZ, affectedPlayers); - //compat - if(processBlocks) this.compat.affectedBlockPositions.addAll(affectedBlocks); - if(processEntities) this.compatPlayers.putAll(affectedPlayers); - if(sfx != null) { for(IExplosionSFX fx : sfx) { fx.doEffect(this, world, posX, posY, posZ, size); diff --git a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorBulkie.java b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorBulkie.java index 64c893f0c..863916f19 100644 --- a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorBulkie.java +++ b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorBulkie.java @@ -84,8 +84,6 @@ public class BlockAllocatorBulkie implements IBlockAllocator { } } - explosion.compat.affectedBlockPositions.addAll(affectedBlocks); - return affectedBlocks; } } diff --git a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorGlyphidDig.java b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorGlyphidDig.java index 35dafc67e..98adec4a4 100644 --- a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorGlyphidDig.java +++ b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorGlyphidDig.java @@ -84,8 +84,6 @@ public class BlockAllocatorGlyphidDig implements IBlockAllocator { } } - explosion.compat.affectedBlockPositions.addAll(affectedBlocks); - return affectedBlocks; } } diff --git a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorStandard.java b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorStandard.java index 376c9beb8..f84cc5728 100644 --- a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorStandard.java +++ b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorStandard.java @@ -74,8 +74,6 @@ public class BlockAllocatorStandard implements IBlockAllocator { } } - explosion.compat.affectedBlockPositions.addAll(affectedBlocks); - return affectedBlocks; } } diff --git a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorWater.java b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorWater.java index 76691ac45..99d7f29c4 100644 --- a/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorWater.java +++ b/src/main/java/com/hbm/explosion/vanillant/standard/BlockAllocatorWater.java @@ -72,8 +72,6 @@ public class BlockAllocatorWater implements IBlockAllocator { } } } - - explosion.compat.affectedBlockPositions.addAll(affectedBlocks); return affectedBlocks; } diff --git a/src/main/java/com/hbm/itempool/ItemPoolsPile.java b/src/main/java/com/hbm/itempool/ItemPoolsPile.java index 0a4378211..68e9d6d4a 100644 --- a/src/main/java/com/hbm/itempool/ItemPoolsPile.java +++ b/src/main/java/com/hbm/itempool/ItemPoolsPile.java @@ -112,12 +112,11 @@ public class ItemPoolsPile { this.pool = new WeightedRandomChestContent[] { weighted(ModItems.pipe, 2600, 0, 2, 20), weighted(ModItems.scrap, 0, 1, 5, 20), - weighted(ModItems.wire_fine, 8200, 1, 2, 20), weighted(ModItems.dust, 0, 1, 3, 40), weighted(ModItems.dust_tiny, 0, 1, 7, 40), weighted(ModItems.powder_cement, 0, 1, 6, 40), weighted(ModItems.nugget_lead, 0, 0, 3, 20), - weighted(ModItems.wire_fine, 0, 0, 3, 20), + weighted(ModItems.wire_fine, Mats.MAT_LEAD.id, 1, 2, 20), weighted(ModItems.powder_ash, 0, 0, 1, 15), weighted(ModItems.plate_lead, 0, 0, 1, 15), weighted(Items.string, 0, 0, 1, 15), diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index cfe659e85..6d8d05db8 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -588,6 +588,8 @@ public class ModItems { public static Item casing; public static Item wiring_red_copper; + public static Item wrench; + public static Item shell; public static Item pipe; public static Item fins_flat; @@ -1958,7 +1960,6 @@ public class ModItems { public static Item crowbar; - public static Item wrench; public static Item wrench_flipped; public static Item memespoon; @@ -2798,7 +2799,8 @@ public class ModItems { casing = new ItemEnumMulti(ItemEnums.EnumCasingType.class, true, true).setUnlocalizedName("casing").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":casing"); wiring_red_copper = new ItemWiring().setUnlocalizedName("wiring_red_copper").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":wiring_red_copper"); - + wrench = new ItemWrench(MainRegistry.tMatSteel).setUnlocalizedName("wrench").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":wrench"); + pellet_rtg_depleted = new ItemRTGPelletDepleted().setContainerItem(plate_iron).setUnlocalizedName("pellet_rtg_depleted").setCreativeTab(MainRegistry.controlTab); pellet_rtg_radium = new ItemRTGPellet(3).setDecays(DepletedRTGMaterial.LEAD, (long) (RTGUtil.getLifespan(16.0F, HalfLifeType.LONG, false) * 1.5)).setUnlocalizedName("pellet_rtg_radium").setCreativeTab(MainRegistry.controlTab).setMaxStackSize(1).setTextureName(RefStrings.MODID + ":pellet_rtg_radium"); @@ -4858,7 +4860,6 @@ public class ModItems { matchstick = new ItemMatch().setUnlocalizedName("matchstick").setCreativeTab(CreativeTabs.tabTools).setFull3D().setTextureName(RefStrings.MODID + ":matchstick"); balefire_and_steel = new ItemBalefireMatch().setUnlocalizedName("balefire_and_steel").setCreativeTab(CreativeTabs.tabTools).setFull3D().setTextureName(RefStrings.MODID + ":balefire_and_steel"); crowbar = new ModSword(MainRegistry.tMatSteel).setUnlocalizedName("crowbar").setFull3D().setTextureName(RefStrings.MODID + ":crowbar"); - wrench = new WeaponSpecial(MainRegistry.tMatSteel).setUnlocalizedName("wrench").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":wrench"); wrench_flipped = new WeaponSpecial(MainRegistry.tMatElec).setUnlocalizedName("wrench_flipped").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":wrench_flipped"); memespoon = new WeaponSpecial(MainRegistry.tMatSteel).setUnlocalizedName("memespoon").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":memespoon"); wood_gavel = new WeaponSpecial(ToolMaterial.WOOD).setUnlocalizedName("wood_gavel").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":wood_gavel"); diff --git a/src/main/java/com/hbm/items/tool/ItemWiring.java b/src/main/java/com/hbm/items/tool/ItemWiring.java index cd6b5d787..4f979eaad 100644 --- a/src/main/java/com/hbm/items/tool/ItemWiring.java +++ b/src/main/java/com/hbm/items/tool/ItemWiring.java @@ -118,7 +118,7 @@ public class ItemWiring extends Item { entity.posY - stack.stackTagCompound.getInteger("y"), entity.posZ - stack.stackTagCompound.getInteger("z")); - MainRegistry.proxy.displayTooltip(((int) vec.lengthVector()) + "m", MainRegistry.proxy.ID_CABLE); + MainRegistry.proxy.displayTooltip(stack.getDisplayName() + ": " + ((int) vec.lengthVector()) + "m", MainRegistry.proxy.ID_CABLE); } } } diff --git a/src/main/java/com/hbm/items/tool/ItemWrench.java b/src/main/java/com/hbm/items/tool/ItemWrench.java new file mode 100644 index 000000000..c7dbe6f5c --- /dev/null +++ b/src/main/java/com/hbm/items/tool/ItemWrench.java @@ -0,0 +1,141 @@ +package com.hbm.items.tool; + +import java.util.List; + +import com.hbm.blocks.BlockDummyable; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.network.TileEntityPipelineBase; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class ItemWrench extends ItemSword { + + public ItemWrench(ToolMaterial mat) { + super(mat); + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + + if(!player.isSneaking()) { + + Block b = world.getBlock(x, y, z); + + if(b instanceof BlockDummyable) { + int[] core = ((BlockDummyable)b).findCore(world, x, y, z); + + if(core != null) { + x = core[0]; + y = core[1]; + z = core[2]; + } + } + + TileEntity te = world.getTileEntity(x, y, z); + + if(te != null && te instanceof TileEntityPipelineBase) { + + if(stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + + stack.stackTagCompound.setInteger("x", x); + stack.stackTagCompound.setInteger("y", y); + stack.stackTagCompound.setInteger("z", z); + + if(!world.isRemote) { + player.addChatMessage(new ChatComponentText("Pipe start")); + } + } else if(!world.isRemote) { + + int x1 = stack.stackTagCompound.getInteger("x"); + int y1 = stack.stackTagCompound.getInteger("y"); + int z1 = stack.stackTagCompound.getInteger("z"); + + if(world.getTileEntity(x1, y1, z1) instanceof TileEntityPipelineBase) { + + TileEntityPipelineBase first = (TileEntityPipelineBase) world.getTileEntity(x1, y1, z1); + TileEntityPipelineBase second = ((TileEntityPipelineBase) te); + + switch (TileEntityPipelineBase.canConnect(first, second)) { + case 0: + first.addConnection(x, y, z); + second.addConnection(x1, y1, z1); + player.addChatMessage(new ChatComponentText("Pipe end")); + break; + case 1: player.addChatMessage(new ChatComponentText("Pipe error - Pipes are not the same type")); break; + case 2: player.addChatMessage(new ChatComponentText("Pipe error - Cannot connect to the same pipe anchor")); break; + case 3: player.addChatMessage(new ChatComponentText("Pipe error - Pipe anchor is too far away")); break; + case 4: player.addChatMessage(new ChatComponentText("Pipe error - Pipe anchor fluid types do not match")); break; + } + + stack.stackTagCompound = null; + + } else { + + player.addChatMessage(new ChatComponentText("Pipe error")); + stack.stackTagCompound = null; + } + } + + player.swingItem(); + return true; + } + } + + return false; + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase entityPlayer) { + World world = entity.worldObj; + + Vec3 vec = entityPlayer.getLookVec(); + + double dX = vec.xCoord * 0.5; + double dY = vec.yCoord * 0.5; + double dZ = vec.zCoord * 0.5; + + entity.motionX += dX; + entity.motionY += dY; + entity.motionZ += dZ; + world.playSoundAtEntity(entity, "random.anvil_land", 3.0F, 0.75F); + + return false; + } + + @Override + public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { + if(itemstack.stackTagCompound != null) { + list.add("Pipe start x: " + itemstack.stackTagCompound.getInteger("x")); + list.add("Pipe start y: " + itemstack.stackTagCompound.getInteger("y")); + list.add("Pipe start z: " + itemstack.stackTagCompound.getInteger("z")); + } else { + list.add("Right-click anchor to connect"); + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean inhand) { + + if(world.isRemote) { + if(stack.stackTagCompound != null) { + Vec3 vec = Vec3.createVectorHelper( + entity.posX - stack.stackTagCompound.getInteger("x"), + entity.posY - stack.stackTagCompound.getInteger("y"), + entity.posZ - stack.stackTagCompound.getInteger("z")); + + MainRegistry.proxy.displayTooltip(stack.getDisplayName() + ": " + ((int) vec.lengthVector()) + "m", MainRegistry.proxy.ID_WRENCH); + } + } + } +} diff --git a/src/main/java/com/hbm/items/tool/WeaponSpecial.java b/src/main/java/com/hbm/items/tool/WeaponSpecial.java index faba31497..2b023cb1e 100644 --- a/src/main/java/com/hbm/items/tool/WeaponSpecial.java +++ b/src/main/java/com/hbm/items/tool/WeaponSpecial.java @@ -224,7 +224,7 @@ public class WeaponSpecial extends ItemSword { if(this == ModItems.shimmer_sledge || this == ModItems.shimmer_axe) { multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", -0.2, 1)); } - if(this == ModItems.wrench || this == ModItems.wrench_flipped) { + if(this == ModItems.wrench_flipped) { multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", -0.1, 1)); } return multimap; @@ -274,9 +274,6 @@ public class WeaponSpecial extends ItemSword { list.add("Timber!"); } } - if(this == ModItems.wrench) { - list.add("Mechanic Richard"); - } if(this == ModItems.wrench_flipped) { list.add("Wrench 2: The Wrenchening"); } diff --git a/src/main/java/com/hbm/main/ServerProxy.java b/src/main/java/com/hbm/main/ServerProxy.java index 271a21759..1bcd00d1c 100644 --- a/src/main/java/com/hbm/main/ServerProxy.java +++ b/src/main/java/com/hbm/main/ServerProxy.java @@ -33,6 +33,7 @@ public class ServerProxy { public static final int ID_FAN_MODE = 10; public static final int ID_TOOLABILITY = 11; public static final int ID_GAS_HAZARD = 12; + public static final int ID_WRENCH = 13; public ITranslate getI18n() { return I18N; } diff --git a/src/main/java/com/hbm/render/util/RenderInfoSystem.java b/src/main/java/com/hbm/render/util/RenderInfoSystem.java index 773c5e618..b5e2e136f 100644 --- a/src/main/java/com/hbm/render/util/RenderInfoSystem.java +++ b/src/main/java/com/hbm/render/util/RenderInfoSystem.java @@ -68,7 +68,7 @@ public class RenderInfoSystem { int longest = 0; - for(InfoEntry entry : messages.values()) { + for(InfoEntry entry : entries) { int length = mc.fontRenderer.getStringWidth(entry.text); if(length > longest) @@ -101,7 +101,7 @@ public class RenderInfoSystem { int off = 0; long now = System.currentTimeMillis(); - for(InfoEntry entry : messages.values()) { + for(InfoEntry entry : entries) { int elapsed = (int) (now - entry.start); diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 500069e74..313b1057c 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -430,6 +430,8 @@ public class TileMappings { put(TileEntityPipeExhaustPaintable.class, "tileentity_pipe_exhaust_paintable"); put(TileEntityFluidValve.class, "tileentity_pipe_valve"); put(TileEntityFluidPump.class, "tileentity_pipe_pump"); + + put(TileEntityPipeAnchor.class, "tileentity_pioe_anchor"); put(TileEntityCraneInserter.class, "tileentity_inserter"); put(TileEntityCraneExtractor.class, "tileentity_extractor"); diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityPipeAnchor.java b/src/main/java/com/hbm/tileentity/network/TileEntityPipeAnchor.java new file mode 100644 index 000000000..dc7eb5e00 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/TileEntityPipeAnchor.java @@ -0,0 +1,44 @@ +package com.hbm.tileentity.network; + +import com.hbm.inventory.fluid.FluidType; +import com.hbm.util.fauxpointtwelve.BlockPos; +import com.hbm.util.fauxpointtwelve.DirPos; + +import api.hbm.fluidmk2.FluidNode; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Vec3; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityPipeAnchor extends TileEntityPipelineBase { + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.SMALL; + } + + @Override + public Vec3 getMountPos() { + return Vec3.createVectorHelper(0.5, 0.5, 0.5); + } + + @Override + public double getMaxPipeLength() { + return 10; + } + + @Override + public FluidNode createNode(FluidType type) { + TileEntity tile = (TileEntity) this; + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite(); + FluidNode node = new FluidNode(type.getNetworkProvider(), new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections( + new DirPos(xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN), + new DirPos(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir)); + for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN)); + return node; + } + + @Override + public boolean canConnect(FluidType type, ForgeDirection dir) { + return ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite() == dir && type == this.type; + } +} diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityPipelineBase.java b/src/main/java/com/hbm/tileentity/network/TileEntityPipelineBase.java new file mode 100644 index 000000000..ad64da847 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/TileEntityPipelineBase.java @@ -0,0 +1,182 @@ +package com.hbm.tileentity.network; + +import java.util.ArrayList; +import java.util.List; + +import com.hbm.inventory.fluid.FluidType; +import com.hbm.uninos.UniNodespace; +import com.hbm.util.fauxpointtwelve.BlockPos; +import com.hbm.util.fauxpointtwelve.DirPos; + +import api.hbm.fluidmk2.FluidNode; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.ForgeDirection; + +// copy pasted crap class +public abstract class TileEntityPipelineBase extends TileEntityPipeBaseNT { + + protected List connected = new ArrayList<>(); + + @Override + public FluidNode createNode(FluidType type) { + TileEntity tile = (TileEntity) this; + FluidNode node = new FluidNode(type.getNetworkProvider(), new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(new DirPos(xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN)); + for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN)); + return node; + } + + public void addConnection(int x, int y, int z) { + + connected.add(new int[] {x, y, z}); + + FluidNode node = (FluidNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, this.type.getNetworkProvider()); + node.recentlyChanged = true; + node.addConnection(new DirPos(x, y, z, ForgeDirection.UNKNOWN)); + + this.markDirty(); + + if(worldObj instanceof WorldServer) { + WorldServer world = (WorldServer) worldObj; + world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + public void disconnectAll() { + + for(int[] pos : connected) { + TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]); + if(te == this) continue; + + if(te instanceof TileEntityPipelineBase) { + TileEntityPipelineBase pipeline = (TileEntityPipelineBase) te; + UniNodespace.destroyNode(worldObj, pos[0], pos[1], pos[2], this.type.getNetworkProvider()); + + for(int i = 0; i < pipeline.connected.size(); i++) { + int[] conPos = pipeline.connected.get(i); + + if(conPos[0] == xCoord && conPos[1] == yCoord && conPos[2] == zCoord) { + pipeline.connected.remove(i); + i--; + } + } + + pipeline.markDirty(); + + if(worldObj instanceof WorldServer) { + WorldServer world = (WorldServer) worldObj; + world.getPlayerManager().markBlockForUpdate(pipeline.xCoord, pipeline.yCoord, pipeline.zCoord); + } + } + } + + UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, this.type.getNetworkProvider()); + } + + @Override + public void invalidate() { + super.invalidate(); + disconnectAll(); + } + + /** + * Returns a status code based on the operation.
+ * 0: Connected
+ * 1: Connections are incompatible
+ * 2: Both parties are the same block
+ * 3: Connection length exceeds maximum + * 4: Pipeline fluid types do not match + */ + public static int canConnect(TileEntityPipelineBase first, TileEntityPipelineBase second) { + + if(first.getConnectionType() != second.getConnectionType()) return 1; + if(first == second) return 2; + if(first.type != second.type) return 4; + + double len = Math.min(first.getMaxPipeLength(), second.getMaxPipeLength()); + + Vec3 firstPos = first.getConnectionPoint(); + Vec3 secondPos = second.getConnectionPoint(); + + Vec3 delta = Vec3.createVectorHelper( + (secondPos.xCoord) - (firstPos.xCoord), + (secondPos.yCoord) - (firstPos.yCoord), + (secondPos.zCoord) - (firstPos.zCoord) + ); + + return len >= delta.lengthVector() ? 0 : 3; + } + + public abstract ConnectionType getConnectionType(); + public abstract Vec3 getMountPos(); + public abstract double getMaxPipeLength(); + + public Vec3 getConnectionPoint() { + Vec3 mount = this.getMountPos(); + return mount.addVector(xCoord, yCoord, zCoord); + } + + public List getConnected() { + return connected; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setInteger("conCount", connected.size()); + + for(int i = 0; i < connected.size(); i++) { + nbt.setIntArray("con" + i, connected.get(i)); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + int count = nbt.getInteger("conCount"); + + this.connected.clear(); + + for(int i = 0; i < count; i++) { + connected.add(nbt.getIntArray("con" + i)); + } + } + + @Override + public Packet getDescriptionPacket() { + + NBTTagCompound nbt = new NBTTagCompound(); + this.writeToNBT(nbt); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + this.readFromNBT(pkt.func_148857_g()); + } + + public enum ConnectionType { + SMALL + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return TileEntity.INFINITE_EXTENT_AABB; // not great! + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } +}