From b76af3cffa3dec53a08f802863439fe9af1625b1 Mon Sep 17 00:00:00 2001 From: Boblet Date: Mon, 15 Jan 2024 10:19:39 +0100 Subject: [PATCH] cleaned up pipettes, chemplant loading change delay --- changelog | 10 +- .../java/com/hbm/crafting/ToolRecipes.java | 1 + .../inventory/recipes/anvil/AnvilRecipes.java | 7 - .../java/com/hbm/items/tool/ItemPipette.java | 296 +++++++++--------- .../machine/TileEntityMachineChemplant.java | 20 +- .../assets/hbm/textures/items/pipette.png | Bin 250 -> 205 bytes .../hbm/textures/items/pipette_boron.png | Bin 280 -> 213 bytes .../hbm/textures/items/pipette_empty.png | Bin 0 -> 91 bytes .../items/pipette_laboratory_overlay.png | Bin 141 -> 104 bytes .../hbm/textures/items/pipette_overlay.png | Bin 222 -> 151 bytes 10 files changed, 173 insertions(+), 161 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/items/pipette_empty.png diff --git a/changelog b/changelog index 11d3c4adf..bec2826a5 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,13 @@ +## Added +* Pipettes + * Precision tools for carrying small amounts of liquids + * Come in three variants, normal, boron (corrosion-resistant) and laboratory (smaller capacity, more precision) + * Unlike most fluid containers, can be partially filled + * Capacity can be changed by right-clicking if the pipette is empty + ## Changed -* there is now a config option to disable the biome change caused by fallout. The config will also determine whether the biomes are registered at all, which prevents them from conflicting with other mods' biomes when disabled. +* There is now a config option to disable the biome change caused by fallout. The config will also determine whether the biomes are registered at all, which prevents them from conflicting with other mods' biomes when disabled. +* Chemical plants now have a timer that starts after loading/unloading fluids using item fluid containers from the input buffers, this creates a delay between switching from loading and unloading, making it possible to retrieve fluids using pipettes. ## Fixed * Fixed trenchmaster armor not doing most of the armor calculation, making it the worst armor diff --git a/src/main/java/com/hbm/crafting/ToolRecipes.java b/src/main/java/com/hbm/crafting/ToolRecipes.java index bc5cdd935..5d1edf7e4 100644 --- a/src/main/java/com/hbm/crafting/ToolRecipes.java +++ b/src/main/java/com/hbm/crafting/ToolRecipes.java @@ -131,6 +131,7 @@ public class ToolRecipes { CraftingManager.addRecipeAuto(new ItemStack(ModItems.pipette, 1), new Object[] { " L", " G ", "G ", 'L', ANY_RUBBER.ingot(), 'G', KEY_CLEARGLASS}); CraftingManager.addRecipeAuto(new ItemStack(ModItems.pipette_boron, 1), new Object[] { " P", " B ", "B ", 'P', RUBBER.ingot(), 'B', ModBlocks.glass_boron}); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.pipette_laboratory, 1), new Object[] { " C", " R ", "P ", 'C', ModItems.circuit_aluminium, 'R', RUBBER.ingot(), 'P', ModItems.pipette_boron }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.mirror_tool), new Object[] { " A ", " IA", "I ", 'A', AL.ingot(), 'I', IRON.ingot() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.rbmk_tool), new Object[] { " A ", " IA", "I ", 'A', PB.ingot(), 'I', IRON.ingot() }); diff --git a/src/main/java/com/hbm/inventory/recipes/anvil/AnvilRecipes.java b/src/main/java/com/hbm/inventory/recipes/anvil/AnvilRecipes.java index a5dd5e1ba..86921434e 100644 --- a/src/main/java/com/hbm/inventory/recipes/anvil/AnvilRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/anvil/AnvilRecipes.java @@ -422,13 +422,6 @@ public class AnvilRecipes { new ComparableStack(Items.leather, 4), new ComparableStack(Items.feather, 24) }, new AnvilOutput(new ItemStack(ModItems.wings_limp))).setTier(2)); - - constructionRecipes.add(new AnvilConstructionRecipe( - new AStack[] { - new ComparableStack(ModBlocks.glass_boron, 2), - new OreDictStack(ANY_HARDPLASTIC.ingot(), 1), - new ComparableStack(ModItems.circuit_aluminium, 2) - }, new AnvilOutput(new ItemStack(ModItems.pipette_laboratory))).setTier(3)); constructionRecipes.add(new AnvilConstructionRecipe( new AStack[] { diff --git a/src/main/java/com/hbm/items/tool/ItemPipette.java b/src/main/java/com/hbm/items/tool/ItemPipette.java index a09ff9809..b7829ae2c 100644 --- a/src/main/java/com/hbm/items/tool/ItemPipette.java +++ b/src/main/java/com/hbm/items/tool/ItemPipette.java @@ -23,186 +23,180 @@ import java.util.List; public class ItemPipette extends Item implements IFillableItem { - public ItemPipette() { - this.canRepair = false; - this.setMaxDamage(1); - } + public ItemPipette() { + this.canRepair = false; + this.setMaxDamage(1); + } - @SideOnly(Side.CLIENT) protected IIcon overlayIcon; + @SideOnly(Side.CLIENT) protected IIcon overlayIcon; + @SideOnly(Side.CLIENT) protected IIcon emptyIcon; - public short getMaxFill() { - if(this == ModItems.pipette_laboratory) - return 50; - else - return 1_000; - } + public short getMaxFill() { + if(this == ModItems.pipette_laboratory) return 50; + else return 1_000; + } - public void initNBT(ItemStack stack) { + public void initNBT(ItemStack stack) { + stack.stackTagCompound = new NBTTagCompound(); + this.setFill(stack, Fluids.NONE, (short) 0); // sets "type" and "fill" NBT + stack.stackTagCompound.setShort("capacity", this.getMaxFill()); // set "capacity" + } - stack.stackTagCompound = new NBTTagCompound(); + public FluidType getType(ItemStack stack) { + if(!stack.hasTagCompound()) { + initNBT(stack); + } - this.setFill(stack, Fluids.NONE, (short) 0); //sets "type" and "fill" NBT - stack.stackTagCompound.setShort("capacity", this.getMaxFill()); //set "capacity" - } + return Fluids.fromID(stack.stackTagCompound.getShort("type")); + } - public FluidType getType(ItemStack stack) { - if(!stack.hasTagCompound()) { - initNBT(stack); - } + public short getCapacity(ItemStack stack) { + if(!stack.hasTagCompound()) { + initNBT(stack); + } - return Fluids.fromID(stack.stackTagCompound.getShort("type")); - } + return stack.stackTagCompound.getShort("capacity"); + } - public short getCapacity(ItemStack stack) { - if(!stack.hasTagCompound()) { - initNBT(stack); - } + public void setFill(ItemStack stack, FluidType type, short fill) { + if(!stack.hasTagCompound()) { + initNBT(stack); + } - return stack.stackTagCompound.getShort("capacity"); - } + stack.stackTagCompound.setShort("type", (short) type.getID()); + stack.stackTagCompound.setShort("fill", fill); + } - public void setFill(ItemStack stack, FluidType type, short fill) { - if(!stack.hasTagCompound()) { - initNBT(stack); - } + public short getFill(ItemStack stack) { + if(!stack.hasTagCompound()) { + initNBT(stack); + } - stack.stackTagCompound.setShort("type", (short) type.getID()); - stack.stackTagCompound.setShort("fill", fill); - } + return stack.stackTagCompound.getShort("fill"); + } - public short getFill(ItemStack stack) { - if(!stack.hasTagCompound()) { - initNBT(stack); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - return stack.stackTagCompound.getShort("fill"); - } + if(!stack.hasTagCompound()) { + initNBT(stack); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if(!world.isRemote) { + if(this.getFill(stack) == 0) { + int a; + if(this == ModItems.pipette_laboratory) + a = !player.isSneaking() ? Math.min(this.getCapacity(stack) + 1, 50) : Math.max(this.getCapacity(stack) - 1, 1); + else + a = !player.isSneaking() ? Math.min(this.getCapacity(stack) + 50, 1_000) : Math.max(this.getCapacity(stack) - 50, 50); + stack.stackTagCompound.setShort("capacity", (short) a); + player.addChatMessage(new ChatComponentText(a + "/" + this.getMaxFill() + "mB")); + } else { + player.addChatMessage(new ChatComponentText(I18nUtil.resolveKey("desc.item.pipette.noEmpty"))); + } + } + return stack; + } - if(!stack.hasTagCompound()) { - initNBT(stack); - } + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + if(this == ModItems.pipette_laboratory) { + list.add(I18nUtil.resolveKey("desc.item.pipette.corrosive")); + list.add(I18nUtil.resolveKey("desc.item.pipette.laboratory")); + } + if(this == ModItems.pipette_boron) + list.add(I18nUtil.resolveKey("desc.item.pipette.corrosive")); + if(this == ModItems.pipette) + list.add(I18nUtil.resolveKey("desc.item.pipette.noCorrosive")); + list.add("Fluid: " + this.getType(stack).getLocalizedName()); + list.add("Amount: " + this.getFill(stack) + "/" + this.getCapacity(stack) + "mB (" + this.getMaxFill() + "mB)"); + } - if(!world.isRemote) { - // ok i need to add some explanation - if (this.getFill(stack) == 0) { //if the pipette is empty - int a; - if(this == ModItems.pipette_laboratory) //if the pipette is a laboratory pipette - //if the player is sneaking then the capacity should increase, else it should decrease (Math.min and Math.max for negative numbers/going over capacity) - a = !player.isSneaking() ? Math.min(this.getCapacity(stack) + 1, 50) : Math.max(this.getCapacity(stack) - 1, 1); - else //if its not a laboratory pipette - //if the player is sneaking then the capacity should increase, else it should decrease - a = !player.isSneaking() ? Math.min(this.getCapacity(stack) + 50, 1_000) : Math.max(this.getCapacity(stack) - 50, 50); - stack.stackTagCompound.setShort("capacity", (short) a); // set the capacity to the new value - player.addChatMessage(new ChatComponentText(a + "/" + this.getMaxFill() + "mB")); // send new value in chat for player to see - } else { - player.addChatMessage(new ChatComponentText(I18nUtil.resolveKey("desc.item.pipette.noEmpty"))); // if pipette is not empty, no chance in capacity and tell player - } - } - return stack; - } + @Override + public boolean acceptsFluid(FluidType type, ItemStack stack) { + return (type == this.getType(stack) || this.getFill(stack) == 0) && (!type.isAntimatter()); + } - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - if(this == ModItems.pipette_laboratory) { - list.add(I18nUtil.resolveKey("desc.item.pipette.corrosive")); - list.add(I18nUtil.resolveKey("desc.item.pipette.laboratory")); - } - if(this == ModItems.pipette_boron) - list.add(I18nUtil.resolveKey("desc.item.pipette.corrosive")); - if(this == ModItems.pipette) - list.add(I18nUtil.resolveKey("desc.item.pipette.noCorrosive")); - list.add("Fluid: " + this.getType(stack).getLocalizedName()); - list.add("Amount: " + this.getFill(stack) + "/" + this.getCapacity(stack) + "mB (" + this.getMaxFill() + "mB)"); - } + @Override + public int tryFill(FluidType type, int amount, ItemStack stack) { - @Override - public boolean acceptsFluid(FluidType type, ItemStack stack) { - return (type == this.getType(stack) || this.getFill(stack) == 0) && (!type.isAntimatter()); - } + if(!acceptsFluid(type, stack)) + return amount; - @Override - public int tryFill(FluidType type, int amount, ItemStack stack) { + if(this.getFill(stack) == 0) + this.setFill(stack, type, (short) 0); - if(!acceptsFluid(type, stack)) - return amount; + int req = this.getCapacity(stack) - this.getFill(stack); + int toFill = Math.min(req, amount); - if(this.getFill(stack) == 0) - this.setFill(stack, type, (short) 0); + this.setFill(stack, type, (short) (this.getFill(stack) + toFill)); - int req = this.getCapacity(stack) - this.getFill(stack); - int toFill = Math.min(req, amount); + // fizzling checks + if(this.getFill(stack) > 0 && (this.getType(stack).isCorrosive() && type != Fluids.ACID)) { + if(this == ModItems.pipette) { + stack.stackSize = 0; + } + } - this.setFill(stack, type, (short) (this.getFill(stack) + toFill)); + return amount - toFill; + } - //fizzling checks - if(this.getFill(stack) > 0 && (this.getType(stack).isCorrosive() && type != Fluids.ACID)) /*hydrogen peroxide corroding glass? unheard of! */ { - if(this == ModItems.pipette) { - //fizzle it! - stack.stackSize = 0; - } - } + @Override + public boolean providesFluid(FluidType type, ItemStack stack) { + return this.getType(stack) == type; + } - return amount - toFill; - } + @Override + public int tryEmpty(FluidType type, int amount, ItemStack stack) { + if(providesFluid(type, stack)) { + int toUnload = Math.min(amount, this.getFill(stack)); + this.setFill(stack, type, (short) (this.getFill(stack) - toUnload)); + if(this.getFill(stack) == 0) + this.setFill(stack, Fluids.NONE, (short) 0); + return toUnload; + } + return amount; + } - @Override - public boolean providesFluid(FluidType type, ItemStack stack) { - return this.getType(stack) == type; - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister icon) { + super.registerIcons(icon); + if(this == ModItems.pipette_laboratory) + this.overlayIcon = icon.registerIcon("hbm:pipette_laboratory_overlay"); + else + this.overlayIcon = icon.registerIcon("hbm:pipette_overlay"); + + this.emptyIcon = icon.registerIcon("hbm:pipette_empty"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + if(getFill(stack) == 0 && pass == 1) return this.emptyIcon; + return pass == 1 ? this.overlayIcon : getIconFromDamageForRenderPass(stack.getItemDamage(), pass); + } - @Override - public int tryEmpty(FluidType type, int amount, ItemStack stack) { - if(providesFluid(type, stack)) { - int toUnload = Math.min(amount, this.getFill(stack)); - this.setFill(stack, type,(short) (this.getFill(stack) - toUnload)); - if(this.getFill(stack) == 0) - this.setFill(stack, Fluids.NONE, (short) 0); - return toUnload; - } - return amount; - } + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } - //this took me way too long to figure out + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) { + if(pass == 0) { + return 0xffffff; + } else { + int j = this.getType(stack).getColor(); - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister icon) { - super.registerIcons(icon); - if (this == ModItems.pipette_laboratory) - this.overlayIcon = icon.registerIcon("hbm:pipette_laboratory_overlay"); - else - this.overlayIcon = icon.registerIcon("hbm:pipette_overlay"); - } + if(j < 0) { + j = 0xffffff; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamageForRenderPass(int p_77618_1_, int p_77618_2_) { - return p_77618_2_ == 1 ? this.overlayIcon : super.getIconFromDamageForRenderPass(p_77618_1_, p_77618_2_); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) { - if(pass == 0) { - return 0xffffff; - } else { - int j = this.getType(stack).getColor(); - - if(j < 0) { - j = 0xffffff; - } - - return j; - } - } + return j; + } + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java index 3c421facd..110e79c9a 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java @@ -86,6 +86,12 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements public String getName() { return "container.chemplant"; } + + // last successful load + int lsl0 = 0; + int lsl1 = 0; + int lsu0 = 0; + int lsu1 = 0; @Override public void updateEntity() { @@ -98,11 +104,21 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements this.isProgressing = false; this.power = Library.chargeTEFromItems(slots, 0, power, maxPower); - if(!tanks[0].loadTank(17, 19, slots) && (slots[17] == null || slots[17].getItem() != ModItems.fluid_barrel_infinite)) tanks[0].unloadTank(17, 19, slots); - if(!tanks[1].loadTank(18, 20, slots) && (slots[18] == null || slots[18].getItem() != ModItems.fluid_barrel_infinite)) tanks[1].unloadTank(18, 20, slots); + int fluidDelay = 40; + + if(lsu0 >= fluidDelay && tanks[0].loadTank(17, 19, slots)) lsl0 = 0; + if(lsu1 >= fluidDelay && tanks[1].loadTank(18, 20, slots)) lsl1 = 0; + + if(lsl0 >= fluidDelay && slots[17] != null && slots[17].getItem() != ModItems.fluid_barrel_infinite) if(tanks[0].unloadTank(17, 19, slots)) lsu0 = 0; + if(lsl1 >= fluidDelay && slots[18] != null && slots[18].getItem() != ModItems.fluid_barrel_infinite) if(tanks[1].unloadTank(18, 20, slots)) lsu1 = 0; tanks[2].unloadTank(9, 11, slots); tanks[3].unloadTank(10, 12, slots); + + if(lsl0 < fluidDelay) lsl0++; + if(lsl1 < fluidDelay) lsl1++; + if(lsu0 < fluidDelay) lsu0++; + if(lsu1 < fluidDelay) lsu1++; loadItems(); unloadItems(); diff --git a/src/main/resources/assets/hbm/textures/items/pipette.png b/src/main/resources/assets/hbm/textures/items/pipette.png index b4c5c7e2275107903c7128234c030d494f8d342f..a24218949eefc5925fc372ce4f715746dac584d3 100644 GIT binary patch delta 177 zcmV;i08an<0nGuBB!2{RLP=Bz2nYy#2xN!=004wZL_t(Ijm?lT3c^4TMPI-p>Fq=FSU;5CABp5M%5PTjAj@ z0o+bKwN{UJfdNuhbHc}rRn4+p^gVpMI^gNK!~71X?10aY9V%vMKkmAD4W}%*YQs|9 f4X*9(%72j=TxexSwm3N{00000NkvXXu0mjf!W>Ok delta 222 zcmV<403rX)0r~-uB!2;OQb$4nuFf3k00004XF*Lt006O%3;baP00009a7bBm000id z000id0mpBsWB>pFk4Z#9R5(v#pgY*KY14lYhH@Dgp)^qdr19IgZ(#QC-@h4RV`CYa zz&s+r$#?(%i`)2uHG&KQ(L@7~W+;KtUGt_F zBxrv1g94k;HG}*OWfBGtzEWT_2q1?zNqzCuPO_5+0bpPN Y0PeoCIA2c diff --git a/src/main/resources/assets/hbm/textures/items/pipette_boron.png b/src/main/resources/assets/hbm/textures/items/pipette_boron.png index 746c115f7781c96492fe2a3aa2cfae03de8398aa..7bf66ade3f382e17332ec4fe9fb1c1e3192348c4 100644 GIT binary patch delta 185 zcmV;q07n0q0@VSKB!2{RLP=Bz2nYy#2xN!=004|hL_t(Ijm?lT3Iah4Mc;x~n6u6q zQrk{#E7msl7A`V{2->XJ45{V-v0B!#(YPSKE|ACn3H%xnF%hwG?!0mc0f15pF~)B3 zsl2_a0SvnhwN_8=Bm<GZx^prw85kH?(j9#r85lP9bN@+X1@buyJR*x382Ao@Fyrz3 z6)8Z$$(}BbAr}703#@0D=ijRrXe*MGSZET+u;k+`6ORsvcZlIEljf=87z-@elq4bVA4FtXVPXzhG!*{Ob;FS^|}22I1y1GU}oXkrG1_qXNM_)$E)e-c@Ne9i)o$YKTtzQZ8Qcszea z3Q$nV)5S5w!arGpb#a17LX)@r|Nreqp6nu-b$@!9&Q4)uV`I?K=8n2O>4P&+HG`+C KpUXO@geCw8TOl+6 diff --git a/src/main/resources/assets/hbm/textures/items/pipette_overlay.png b/src/main/resources/assets/hbm/textures/items/pipette_overlay.png index c6bf6aadb19ac2f570b7dff1c3831c26b9c83d68..207f90f2e2fa58a0b4575d67d37045177e071025 100644 GIT binary patch delta 122 zcmV-=0EPeF0ha-gBy$9FLP=Bz2nYy#2xN!=002%&L_t(IjqQ%X4!|G?#l-*rTHxND zFvet4=8|3Pk)-sMa#+U902uFeMGn#3^JRd$`g8$6R7FHSEk7<$)h4COQSYCmGZx^prw85kH?(j9#r85lP9bN@+X1@buyJR*x382Ao@Fyrz3 z6)8Z$Vow*x5DWig3DzUcvHJi2@Bj1hf4zn{-;4z&aSWGE96xm6!yon#22KN~%sC88 ze!iAxW6N8>xa&`k#H)|H7?%AM7D&F#!(A9f~<$@3Z-85x%Fn5~Ixz0(i0pTX1B&t;ucLK6Uu1xNM(