mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
pipettes!
This commit is contained in:
parent
aad9fadda3
commit
860d79a2d0
@ -935,6 +935,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");
|
||||
@ -6382,6 +6388,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());
|
||||
|
||||
171
src/main/java/com/hbm/items/tool/ItemPipette.java
Normal file
171
src/main/java/com/hbm/items/tool/ItemPipette.java
Normal file
@ -0,0 +1,171 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import api.hbm.fluid.IFillableItem;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
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 com.hbm.items.ModItems;
|
||||
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.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon overlayIcon;
|
||||
|
||||
public int amount = 50;
|
||||
|
||||
public FluidType type = Fluids.NONE;
|
||||
|
||||
public int getMaxFill() {
|
||||
if(this == ModItems.pipette_laboratory)
|
||||
return 50;
|
||||
else
|
||||
return 1_000;
|
||||
}
|
||||
|
||||
public void initNBT(ItemStack stack) {
|
||||
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
this.setFill(stack, type, 0);
|
||||
}
|
||||
|
||||
public void setFill(ItemStack stack, FluidType type, int fill) {
|
||||
if(!stack.hasTagCompound()) {
|
||||
initNBT(stack);
|
||||
}
|
||||
|
||||
this.type = type;
|
||||
stack.stackTagCompound.setInteger(type.getName(), fill);
|
||||
}
|
||||
|
||||
public int getFill(ItemStack stack, FluidType type) {
|
||||
if(!stack.hasTagCompound()) {
|
||||
initNBT(stack);
|
||||
}
|
||||
|
||||
return stack.stackTagCompound.getInteger(type.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
if(!stack.hasTagCompound()) {
|
||||
initNBT(stack);
|
||||
}
|
||||
|
||||
if(!world.isRemote) {
|
||||
if (this.getFill(stack, type) == 0) {
|
||||
|
||||
if(this != ModItems.pipette_laboratory)
|
||||
this.amount = player.isSneaking() ? Math.min(this.amount + 50, 1_000) : Math.max(this.amount - 50, 50);
|
||||
else
|
||||
this.amount = player.isSneaking() ? Math.min(this.amount + 1, 50) : Math.max(this.amount - 1, 1);
|
||||
|
||||
|
||||
player.addChatMessage(new ChatComponentText(this.amount + "/" + this.getMaxFill() + "mB"));
|
||||
} else {
|
||||
player.addChatMessage(new ChatComponentText("Pipette not empty!"));
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
if(this == ModItems.pipette_laboratory)
|
||||
list.add("Now with 50x more precision!");
|
||||
list.add("Fluid: " + type.getLocalizedName());
|
||||
list.add("Amount: " + this.getFill(stack, type) + "/" + amount + "mB (" + this.getMaxFill() + "mB)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsFluid(FluidType type, ItemStack stack) {
|
||||
if(this == ModItems.pipette_boron || this == ModItems.pipette_laboratory)
|
||||
return (type == this.type || this.getFill(stack, type) == 0);
|
||||
return (type == this.type || this.getFill(stack, type) == 0) && !type.needsLeadContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tryFill(FluidType type, int amount, ItemStack stack) {
|
||||
|
||||
if(!acceptsFluid(type, stack))
|
||||
return amount;
|
||||
|
||||
if(this.getFill(stack, type) == 0)
|
||||
this.setFill(stack, type, 0);
|
||||
|
||||
int req = this.amount - this.getFill(stack, type);
|
||||
int toFill = Math.min(req, amount);
|
||||
|
||||
this.setFill(stack, type, this.getFill(stack, type) + toFill);
|
||||
|
||||
return amount - toFill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean providesFluid(FluidType type, ItemStack stack) {
|
||||
return this.type == type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tryEmpty(FluidType type, int amount, ItemStack stack) {
|
||||
if(providesFluid(type, stack)) {
|
||||
int toUnload = Math.min(amount, this.getFill(stack, type));
|
||||
this.setFill(stack, type,this.getFill(stack, type) - toUnload);
|
||||
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);
|
||||
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 = Fluids.fromID(stack.getItemDamage()).getColor();
|
||||
|
||||
if(j < 0) {
|
||||
j = 0xffffff;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -3663,6 +3663,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)
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/items/pipette.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/pipette.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 186 B |
BIN
src/main/resources/assets/hbm/textures/items/pipette_overlay.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/pipette_overlay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 159 B |
Loading…
x
Reference in New Issue
Block a user