Merge pull request #1293 from BallOfEnergy1/New_master

Pipettes!
This commit is contained in:
HbmMods 2024-01-15 09:37:56 +01:00 committed by GitHub
commit da4160e89f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 238 additions and 2 deletions

View File

@ -128,7 +128,10 @@ public class ToolRecipes {
CraftingManager.addRecipeAuto(new ItemStack(ModItems.bismuth_tool, 1), new Object[] { "TBT", "SRS", "SCS", 'T', TA.nugget(), 'B', ModItems.nugget_bismuth, 'S', ANY_RESISTANTALLOY.ingot(), 'R', ModItems.reacher, 'C', ModItems.circuit_aluminium });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.sat_designator, 1), new Object[] { "RRD", "PIC", " P", 'P', GOLD.plate(), 'R', Items.redstone, 'C', ModItems.circuit_gold, 'D', ModItems.sat_chip, 'I', GOLD.ingot() });
CraftingManager.addShapelessAuto(new ItemStack(ModItems.sat_relay), new Object[] { ModItems.sat_chip, ModItems.ducttape, ModItems.radar_linker });
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.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() });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.power_net_tool), new Object[] { "WRW", " I ", " B ", 'W', ModItems.wire_red_copper, 'R', REDSTONE.dust(), 'I', IRON.ingot(), 'B', ModItems.battery_su });

View File

@ -422,6 +422,13 @@ 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

@ -934,6 +934,9 @@ public class ModItems {
public static Item fluid_barrel_full;
public static Item fluid_barrel_empty;
public static Item fluid_barrel_infinite;
public static Item pipette;
public static Item pipette_boron;
public static Item pipette_laboratory;
public static Item disperser_canister_empty;
public static Item disperser_canister;
@ -4652,6 +4655,9 @@ public class ModItems {
fluid_barrel_empty = new Item().setUnlocalizedName("fluid_barrel_empty").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":fluid_barrel");
fluid_barrel_full = new ItemFluidTank().setUnlocalizedName("fluid_barrel_full").setContainerItem(ModItems.fluid_barrel_empty).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":fluid_barrel");
fluid_barrel_infinite = new ItemInfiniteFluid(null, 1_000_000_000).setUnlocalizedName("fluid_barrel_infinite").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":fluid_barrel_infinite");
pipette = new ItemPipette().setUnlocalizedName("pipette").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pipette");
pipette_boron = new ItemPipette().setUnlocalizedName("pipette_boron").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pipette_boron");
pipette_laboratory = new ItemPipette().setUnlocalizedName("pipette_laboratory").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pipette_laboratory");
disperser_canister_empty = new Item().setUnlocalizedName("disperser_canister_empty").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":disperser_canister");
disperser_canister = new ItemDisperser().setUnlocalizedName("disperser_canister").setContainerItem(ModItems.disperser_canister_empty).setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":disperser_canister");
@ -6381,6 +6387,11 @@ public class ModItems {
GameRegistry.registerItem(fluid_barrel_full, fluid_barrel_full.getUnlocalizedName());
GameRegistry.registerItem(fluid_barrel_infinite, fluid_barrel_infinite.getUnlocalizedName());
//Pipette
GameRegistry.registerItem(pipette, pipette.getUnlocalizedName());
GameRegistry.registerItem(pipette_boron, pipette_boron.getUnlocalizedName());
GameRegistry.registerItem(pipette_laboratory, pipette_laboratory.getUnlocalizedName());
//Disperser Canister
GameRegistry.registerItem(disperser_canister_empty, disperser_canister_empty.getUnlocalizedName());
GameRegistry.registerItem(disperser_canister, disperser_canister.getUnlocalizedName());

View File

@ -0,0 +1,208 @@
package com.hbm.items.tool;
import api.hbm.fluid.IFillableItem;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems;
import com.hbm.util.I18nUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.List;
public class ItemPipette extends Item implements IFillableItem {
public ItemPipette() {
this.canRepair = false;
this.setMaxDamage(1);
}
@SideOnly(Side.CLIENT) protected IIcon overlayIcon;
public short getMaxFill() {
if(this == ModItems.pipette_laboratory)
return 50;
else
return 1_000;
}
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"
}
public FluidType getType(ItemStack stack) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
return Fluids.fromID(stack.stackTagCompound.getShort("type"));
}
public short getCapacity(ItemStack stack) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
return stack.stackTagCompound.getShort("capacity");
}
public void setFill(ItemStack stack, FluidType type, short fill) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
stack.stackTagCompound.setShort("type", (short) type.getID());
stack.stackTagCompound.setShort("fill", fill);
}
public short getFill(ItemStack stack) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
return stack.stackTagCompound.getShort("fill");
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
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 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 boolean acceptsFluid(FluidType type, ItemStack stack) {
return (type == this.getType(stack) || this.getFill(stack) == 0) && (!type.isAntimatter());
}
@Override
public int tryFill(FluidType type, int amount, ItemStack stack) {
if(!acceptsFluid(type, stack))
return amount;
if(this.getFill(stack) == 0)
this.setFill(stack, type, (short) 0);
int req = this.getCapacity(stack) - this.getFill(stack);
int toFill = Math.min(req, amount);
this.setFill(stack, type, (short) (this.getFill(stack) + 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;
}
}
return amount - toFill;
}
@Override
public boolean providesFluid(FluidType type, ItemStack stack) {
return this.getType(stack) == type;
}
@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;
}
//this took me way too long to figure out
@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");
}
@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;
}
}
}

View File

@ -1004,7 +1004,11 @@ desc.item.kitArmor=Armor will be displaced by new set.
desc.item.kitHaz=Armor will be displaced by hazmat suit.
desc.item.kitPack=What a bargain!
desc.item.kitPool=Please empty inventory before opening!
desc.item.pileRod=§eUse on drilled graphite to insert$§eUse screwdriver to extract$
desc.item.pileRod=§eUse on drilled graphite to insert$§eUse screwdriver to extract$
desc.item.pipette.corrosive=Can handle corrosive liquids.
desc.item.pipette.laboratory=Now with 50x more precision!
desc.item.pipette.noCorrosive=§eCannot handle corrosive liquids.
desc.item.pipette.noEmpty=§ePipette not empty!
desc.item.rtgDecay=Decays to: %s
desc.item.rtgHeat=Power Level: %s
desc.item.storage.capacity=Capacity %s%%s
@ -3646,6 +3650,9 @@ item.powder_xe135_tiny.name=Tiny Pile of Xenon-135 Powder
item.powder_yellowcake.name=Yellowcake
item.powder_zirconium.name=Zirconium Powder
item.power_net_tool.name=Cable Network Analysis Tool
item.pipette.name=Pipette
item.pipette_boron.name=Boron Pipette
item.pipette_laboratory.name=Laboratory Grade Pipette
item.primer_357.name=.357 Magnum Primer (x24)
item.primer_44.name=.44 Magnum Primer (x24)
item.primer_50.name=Large Caliber Primer (x12)

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B