forgive my terrible coding
This commit is contained in:
BallOfEnergy 2024-01-06 02:18:38 -06:00
parent 6739cde8f3
commit 5fc297a7b1
9 changed files with 87 additions and 40 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', ModItems.ingot_biorubber, 'G', KEY_CLEARGLASS});
CraftingManager.addRecipeAuto(new ItemStack(ModItems.pipette_boron, 1), new Object[] { " P", " B ", "B ", 'P', ANY_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

@ -696,6 +696,12 @@ public class AssemblerRecipes {
new ComparableStack(ModItems.motor, 2),
}, 200);
makeRecipe(new ComparableStack(ModItems.pipette_laboratory, 1),new AStack[] {
new ComparableStack(ModBlocks.glass_boron, 2),
new OreDictStack(ANY_HARDPLASTIC.ingot(), 1),
new ComparableStack(ModItems.circuit_aluminium, 2)
}, 30);
makeRecipe(new ComparableStack(ModBlocks.turret_chekhov, 1), new AStack[] {
new ComparableStack(ModBlocks.machine_battery, 1),
new OreDictStack(STEEL.ingot(), 16),

View File

@ -5,6 +5,7 @@ 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;
@ -23,16 +24,13 @@ import java.util.List;
public class ItemPipette extends Item implements IFillableItem {
public ItemPipette() {
this.setMaxDamage(0);
this.canRepair = false;
this.setMaxDamage(1);
}
@SideOnly(Side.CLIENT) protected IIcon overlayIcon;
public int amount = this.getMaxFill();
public FluidType type = Fluids.NONE;
public int getMaxFill() {
public short getMaxFill() {
if(this == ModItems.pipette_laboratory)
return 50;
else
@ -43,24 +41,41 @@ public class ItemPipette extends Item implements IFillableItem {
stack.stackTagCompound = new NBTTagCompound();
this.setFill(stack, type, 0);
this.setFill(stack, Fluids.NONE, (short) 0); //sets "type" and "fill" NBT
stack.stackTagCompound.setShort("capacity", this.getMaxFill()); //set "capacity"
}
public void setFill(ItemStack stack, FluidType type, int fill) {
public FluidType getType(ItemStack stack) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
this.type = type;
stack.stackTagCompound.setInteger(type.getName(), fill);
return Fluids.fromID(stack.stackTagCompound.getShort("type"));
}
public int getFill(ItemStack stack, FluidType type) {
public short getCapacity(ItemStack stack) {
if(!stack.hasTagCompound()) {
initNBT(stack);
}
return stack.stackTagCompound.getInteger(type.getName());
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
@ -71,17 +86,19 @@ public class ItemPipette extends Item implements IFillableItem {
}
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"));
// 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("Pipette not empty!"));
player.addChatMessage(new ChatComponentText(I18nUtil.resolveKey("desc.item.pipette.noEmpty"))); // if pipette is not empty, no chance in capacity and tell player
}
}
return stack;
@ -89,17 +106,21 @@ public class ItemPipette extends Item implements IFillableItem {
@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)");
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) {
if(this == ModItems.pipette_boron || this == ModItems.pipette_laboratory)
return (type == this.type || this.getFill(stack, type) == 0 && !type.isAntimatter());
return (type == this.type || this.getFill(stack, type) == 0) && (!type.isCorrosive() && !type.isAntimatter());
return (type == this.getType(stack) || this.getFill(stack) == 0) && (!type.isAntimatter());
}
@Override
@ -108,27 +129,37 @@ public class ItemPipette extends Item implements IFillableItem {
if(!acceptsFluid(type, stack))
return amount;
if(this.getFill(stack, type) == 0)
this.setFill(stack, type, 0);
if(this.getFill(stack) == 0)
this.setFill(stack, type, (short) 0);
int req = this.amount - this.getFill(stack, type);
int req = this.getCapacity(stack) - this.getFill(stack);
int toFill = Math.min(req, amount);
this.setFill(stack, type, this.getFill(stack, type) + toFill);
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.type == type;
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, type));
this.setFill(stack, type,this.getFill(stack, type) - toUnload);
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;
@ -140,7 +171,10 @@ public class ItemPipette extends Item implements IFillableItem {
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister icon) {
super.registerIcons(icon);
this.overlayIcon = icon.registerIcon("hbm:pipette_overlay");
if (this == ModItems.pipette_laboratory)
this.overlayIcon = icon.registerIcon("hbm:pipette_laboratory_overlay");
else
this.overlayIcon = icon.registerIcon("hbm:pipette_overlay");
}
@Override
@ -161,7 +195,7 @@ public class ItemPipette extends Item implements IFillableItem {
if(pass == 0) {
return 0xffffff;
} else {
int j = Fluids.fromID(stack.getItemDamage()).getColor();
int j = this.getType(stack).getColor();
if(j < 0) {
j = 0xffffff;

View File

@ -1003,7 +1003,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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

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.

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 222 B