cleaned up pipettes, chemplant loading change delay

This commit is contained in:
Boblet 2024-01-15 10:19:39 +01:00
parent da4160e89f
commit b76af3cffa
10 changed files with 173 additions and 161 deletions

View File

@ -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

View File

@ -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() });

View File

@ -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[] {

View File

@ -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;
}
}
}

View File

@ -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();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 151 B