go go gadget: 5 cups of coffee

This commit is contained in:
Bob 2025-05-29 18:09:00 +02:00
parent 9ff55acccf
commit a57e538479
12 changed files with 413 additions and 37 deletions

View File

@ -7,7 +7,7 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
/**
* Because vanilla slots have severe mental disabilities that prevent them from working as expected.
* Because vanilla slots have shit idiot brain fungus that prevent them from working as expected.
* @author hbm
*/
@NotableComments

View File

@ -22,12 +22,19 @@ import java.util.HashMap;
*/
public class UpgradeManagerNT {
public TileEntity owner;
public ItemStack[] cachedSlots;
private UpgradeType mutexType;
public HashMap<UpgradeType, Integer> upgrades = new HashMap<>();
public void checkSlots(TileEntity te, ItemStack[] slots, int start, int end) {
public UpgradeManagerNT(TileEntity te) { this.owner = te; }
@Deprecated public UpgradeManagerNT() { }
public void checkSlots(ItemStack[] slots, int start, int end) { checkSlots(owner, slots, start, end); }
@Deprecated public void checkSlots(TileEntity te, ItemStack[] slots, int start, int end) { checkSlotsInternal(te, slots, start, end); }
private void checkSlotsInternal(TileEntity te, ItemStack[] slots, int start, int end) {
if(!(te instanceof IUpgradeInfoProvider) || slots == null)
return;

View File

@ -1,6 +1,9 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotCraftingOutput;
import com.hbm.inventory.SlotNonRetarded;
import com.hbm.inventory.SlotTakeOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@ -57,6 +60,11 @@ public class ContainerBase extends Container {
return slotOriginal;
}
/** Standard player inventory with default hotbar offset */
public void playerInv(InventoryPlayer invPlayer, int playerInvX, int playerInvY) {
playerInv(invPlayer, playerInvX, playerInvY, playerInvY + 58);
}
/** Used to quickly set up the player inventory */
public void playerInv(InventoryPlayer invPlayer, int playerInvX, int playerInvY, int playerHotbarY) {
@ -88,4 +96,18 @@ public class ContainerBase extends Container {
}
}
}
public void addOutputSlots(EntityPlayer player, IInventory inv, int from, int x, int y, int rows, int cols) {
int slotSize = 18;
for(int row = 0; row < rows; row++) for(int col = 0; col < cols; col++) {
this.addSlotToContainer(new SlotCraftingOutput(player, inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
}
}
public void addTakeOnlySlots(IInventory inv, int from, int x, int y, int rows, int cols) {
int slotSize = 18;
for(int row = 0; row < rows; row++) for(int col = 0; col < cols; col++) {
this.addSlotToContainer(new SlotTakeOnly(inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
}
}
}

View File

@ -0,0 +1,79 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotCraftingOutput;
import com.hbm.inventory.SlotNonRetarded;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemChemistryTemplate;
import com.hbm.items.machine.ItemMachineUpgrade;
import api.hbm.energymk2.IBatteryItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerMachineChemicalPlant extends ContainerBase {
public ContainerMachineChemicalPlant(InventoryPlayer invPlayer, IInventory chemicalPlant) {
super(invPlayer, chemicalPlant);
// Battery
this.addSlotToContainer(new SlotNonRetarded(chemicalPlant, 0, 152, 81));
// Schematic
this.addSlotToContainer(new SlotNonRetarded(chemicalPlant, 1, 35, 126));
// Upgrades
this.addSlots(chemicalPlant, 2, 152, 108, 2, 1);
// Solid Input
this.addSlots(chemicalPlant, 4, 8, 99, 1, 3);
// Solid Output
this.addOutputSlots(invPlayer.player, chemicalPlant, 7, 80, 99, 1, 3);
// Fluid Input
this.addSlots( chemicalPlant, 10, 8, 54, 1, 3);
this.addTakeOnlySlots( chemicalPlant, 13, 8, 72, 1, 3);
// Fluid Output
this.addSlots( chemicalPlant, 16, 80, 54, 1, 3);
this.addTakeOnlySlots( chemicalPlant, 19, 80, 72, 1, 3);
this.playerInv(invPlayer, 8, 174);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack slotOriginal = null;
Slot slot = (Slot) this.inventorySlots.get(index);
if(slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
slotOriginal = slotStack.copy();
if(index <= tile.getSizeInventory() - 1) {
SlotCraftingOutput.checkAchievements(player, slotStack);
if(!this.mergeItemStack(slotStack, tile.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else {
if(slotOriginal.getItem() instanceof IBatteryItem || slotOriginal.getItem() == ModItems.battery_creative) {
if(!this.mergeItemStack(slotStack, 0, 1, false)) return null;
} else if(slotOriginal.getItem() instanceof ItemChemistryTemplate) {
if(!this.mergeItemStack(slotStack, 1, 2, false)) return null;
} else if(slotOriginal.getItem() instanceof ItemMachineUpgrade) {
if(!this.mergeItemStack(slotStack, 2, 4, false)) return null;
} else {
if(!this.mergeItemStack(slotStack, 4, 7, false)) return null;
}
}
if(slotStack.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
slot.onPickupFromSlot(player, slotStack);
}
return slotOriginal;
}
}

View File

@ -0,0 +1,66 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerMachineChemicalPlant;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineChemicalPlant;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIMachineChemicalPlant extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_chemplant.png");
private TileEntityMachineChemicalPlant chemplant;
public GUIMachineChemicalPlant(InventoryPlayer invPlayer, TileEntityMachineChemicalPlant tedf) {
super(new ContainerMachineChemicalPlant(invPlayer, tedf));
chemplant = tedf;
this.xSize = 176;
this.ySize = 256;
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
for(int i = 0; i < 3; i++) {
chemplant.inputTanks[i].renderTankInfo(this, mouseX, mouseY, guiLeft + 8 + i * 18, guiTop + 18, 16, 34);
chemplant.outputTanks[i].renderTankInfo(this, mouseX, mouseY, guiLeft + 80 + i * 18, guiTop + 18, 16, 34);
}
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, chemplant.power, chemplant.maxPower);
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.chemplant.hasCustomInventoryName() ? this.chemplant.getInventoryName() : I18n.format(this.chemplant.getInventoryName());
this.fontRendererObj.drawString(name, 70 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
int p = (int) (chemplant.power * 61 / chemplant.maxPower);
drawTexturedModalRect(guiLeft + 152, guiTop + 79 - p, 176, 61 - p, 16, p);
if(chemplant.maxProgress > 0) {
int j = chemplant.progress * 70 / chemplant.maxProgress;
drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61, j, 16);
}
for(int i = 0; i < 3; i++) {
chemplant.inputTanks[i].renderTank(guiLeft + 8, guiTop + 52, this.zLevel, 16, 34);
chemplant.outputTanks[i].renderTank(guiLeft + 80, guiTop + 52, this.zLevel, 16, 34);
}
}
}

View File

@ -6,10 +6,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Random;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.FluidStack;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemFluidIcon;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
@ -54,14 +58,54 @@ public abstract class GenericRecipes extends SerializableRecipe {
}
@Override
public void readRecipe(JsonElement recipe) {
public void readRecipe(JsonElement element) {
JsonObject obj = (JsonObject) element;
GenericRecipe recipe = instantiateRecipe(obj.get("name").getAsString(), obj.get("duration").getAsInt());
if(this.inputItemLimit() > 0) recipe.inputItem = this.readAStackArray(obj.get("inputItem").getAsJsonArray());
if(this.inputFluidLimit() > 0) recipe.inputFluid = this.readFluidArray(obj.get("inputFluid").getAsJsonArray());
if(this.outputItemLimit() > 0) recipe.outputItem = this.readOutputArray(obj.get("outputItem").getAsJsonArray());
if(this.outputFluidLimit() > 0) recipe.outputFluid = this.readFluidArray(obj.get("outputFluid").getAsJsonArray());
readExtraData(element, recipe);
register(recipe);
}
public GenericRecipe instantiateRecipe(String name, int duration) { return new GenericRecipe(name, duration); }
public void readExtraData(JsonElement element, GenericRecipe recipe) { }
@Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
}
public void writeExtraData(Object recipe, JsonWriter writer) { }
public IOutput[] readOutputArray(JsonArray array) {
IOutput[] output = new IOutput[array.size()];
int index = 0;
for(JsonElement element : array) {
JsonArray arrayElement = element.getAsJsonArray();
String type = arrayElement.get(0).getAsString();
if("single".equals(type)) {
ChanceOutput co = new ChanceOutput();
co.deserialize(arrayElement);
output[index] = co;
} else if("multi".equals(type)) {
ChanceOutputMulti com = new ChanceOutputMulti();
com.deserialize(arrayElement);
output[index] = com;
} else {
throw new IllegalArgumentException("Invalid IOutput type '" + type + "', expected 'single' or 'multi' for recipe " + array.toString());
}
index++;
}
return output;
}
///////////////
/// CLASSES ///
@ -75,25 +119,53 @@ public abstract class GenericRecipes extends SerializableRecipe {
public IOutput[] outputItem;
public FluidStack[] outputFluid;
public int duration;
public ItemStack icon;
public GenericRecipe(String name, int duration) {
this.name = name;
this.duration = duration;
}
public GenericRecipe setIcon(ItemStack icon) {
this.icon = icon;
return this;
}
public ItemStack getIcon() {
if(icon == null) {
if(outputItem != null) {
if(outputItem[0] instanceof ChanceOutput) icon = ((ChanceOutput) outputItem[0]).stack.copy();
if(outputItem[0] instanceof ChanceOutputMulti) icon = ((ChanceOutputMulti) outputItem[0]).pool.get(0).stack.copy();
return icon;
}
if(outputFluid != null) {
icon = ItemFluidIcon.make(outputFluid[0]);
}
}
if(icon == null) icon = new ItemStack(ModItems.nothing);
return icon;
}
}
public static interface IOutput {
public boolean possibleMultiOutput();
public ItemStack collapse();
public void serialize(JsonWriter writer) throws IOException;
public void deserialize(JsonArray array);
}
/** A chance output, produces either an ItemStack or null */
public static class ChanceOutput extends WeightedRandom.Item implements IOutput {
// a weight of 0 means this output is not part of a weighted output
public ItemStack stack;
public float chance;
public ChanceOutput(ItemStack stack) { this(stack, 1F, 1); }
public ChanceOutput() { super(0); } // for deserialization
public ChanceOutput(ItemStack stack) { this(stack, 1F, 0); }
public ChanceOutput(ItemStack stack, int weight) { this(stack, 1F, weight); }
public ChanceOutput(ItemStack stack, float chance, int weight) {
super(weight);
@ -108,6 +180,34 @@ public abstract class GenericRecipes extends SerializableRecipe {
}
@Override public boolean possibleMultiOutput() { return false; }
@Override
public void serialize(JsonWriter writer) throws IOException {
boolean standardStack = chance >= 1 && itemWeight == 0;
if(!standardStack) writer.beginArray();
if(itemWeight == 0) writer.value("single");
SerializableRecipe.writeItemStack(stack, writer);
if(!standardStack) {
writer.value(chance);
if(itemWeight > 0) writer.value(itemWeight);
writer.endArray();
}
}
@Override
public void deserialize(JsonArray array) {
if(array.get(0).isJsonPrimitive()) { // "single" tag, don't apply weight
this.stack = SerializableRecipe.readItemStack(array.get(1).getAsJsonArray());
if(array.size() > 2) this.chance = array.get(2).getAsFloat();
} else { // hopefully an array, therefore a weighted result
this.stack = SerializableRecipe.readItemStack(array.get(0).getAsJsonArray());
if(array.size() > 1) this.chance = array.get(1).getAsFloat();
if(array.size() > 2) this.itemWeight = array.get(2).getAsInt();
}
}
}
/** Multiple choice chance output, produces a ChanceOutput chosen randomly by weight */
@ -117,5 +217,22 @@ public abstract class GenericRecipes extends SerializableRecipe {
@Override public ItemStack collapse() { return ((ChanceOutput) WeightedRandom.getRandomItem(RNG, pool)).collapse(); }
@Override public boolean possibleMultiOutput() { return pool.size() > 1; }
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginArray();
writer.value("multi");
for(ChanceOutput output : pool) output.serialize(writer);
writer.endArray();
}
@Override
public void deserialize(JsonArray array) {
for(JsonElement element : array) {
ChanceOutput output = new ChanceOutput();
output.deserialize(element.getAsJsonArray());
pool.add(output);
}
}
}
}

View File

@ -1152,15 +1152,6 @@ public class ModItems {
public static Item ammo_bag_infinite;
public static Item casing_bag;
public static Item test_nuke_igniter;
public static Item test_nuke_propellant;
public static Item test_nuke_tier1_shielding;
public static Item test_nuke_tier2_shielding;
public static Item test_nuke_tier1_bullet;
public static Item test_nuke_tier2_bullet;
public static Item test_nuke_tier1_target;
public static Item test_nuke_tier2_target;
public static Item cordite;
public static Item ballistite;
public static Item ball_dynamite;
@ -2258,15 +2249,6 @@ public class ModItems {
redstone_sword = new RedstoneSword(ToolMaterial.STONE).setUnlocalizedName("redstone_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":redstone_sword");
big_sword = new BigSword(ToolMaterial.EMERALD).setUnlocalizedName("big_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":big_sword");
test_nuke_igniter = new Item().setUnlocalizedName("test_nuke_igniter").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_igniter");
test_nuke_propellant = new Item().setUnlocalizedName("test_nuke_propellant").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_propellant");
test_nuke_tier1_shielding = new Item().setUnlocalizedName("test_nuke_tier1_shielding").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_tier1_shielding");
test_nuke_tier2_shielding = new Item().setUnlocalizedName("test_nuke_tier2_shielding").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_tier2_shielding");
test_nuke_tier1_bullet = new Item().setUnlocalizedName("test_nuke_tier1_bullet").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_tier1_bullet");
test_nuke_tier2_bullet = new Item().setUnlocalizedName("test_nuke_tier2_bullet").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_tier2_bullet");
test_nuke_tier1_target = new Item().setUnlocalizedName("test_nuke_tier1_target").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_tier1_target");
test_nuke_tier2_target = new Item().setUnlocalizedName("test_nuke_tier2_target").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":test_nuke_tier2_target");
ingot_th232 = new Item().setUnlocalizedName("ingot_th232").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_th232");
ingot_uranium = new Item().setUnlocalizedName("ingot_uranium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_uranium");
ingot_u233 = new Item().setUnlocalizedName("ingot_u233").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":ingot_u233");
@ -4998,16 +4980,6 @@ public class ModItems {
GameRegistry.registerItem(redstone_sword, redstone_sword.getUnlocalizedName());
GameRegistry.registerItem(big_sword, big_sword.getUnlocalizedName());
//Test Nuke
GameRegistry.registerItem(test_nuke_igniter, test_nuke_igniter.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_propellant, test_nuke_propellant.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_tier1_shielding, test_nuke_tier1_shielding.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_tier2_shielding, test_nuke_tier2_shielding.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_tier1_bullet, test_nuke_tier1_bullet.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_tier2_bullet, test_nuke_tier2_bullet.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_tier1_target, test_nuke_tier1_target.getUnlocalizedName());
GameRegistry.registerItem(test_nuke_tier2_target, test_nuke_tier2_target.getUnlocalizedName());
//Ingots
GameRegistry.registerItem(ingot_uranium, ingot_uranium.getUnlocalizedName());
GameRegistry.registerItem(ingot_u233, ingot_u233.getUnlocalizedName());

View File

@ -350,16 +350,16 @@ public class ItemToolAbility extends ItemTool implements IDepthRockTool, IGUIPro
Block block = world.getBlock(x, y, z);
int l = world.getBlockMetadata(x, y, z);
world.playAuxSFXAtEntity(player, 2001, x, y, z, Block.getIdFromBlock(block) + (world.getBlockMetadata(x, y, z) << 12));
boolean flag = false;
boolean removedByPlayer = false;
if(player.capabilities.isCreativeMode) {
flag = removeBlock(world, x, y, z, false, player);
removedByPlayer = removeBlock(world, x, y, z, false, player);
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
} else {
ItemStack itemstack = player.getCurrentEquippedItem();
boolean flag1 = block.canHarvestBlock(player, l);
boolean canHarvest = block.canHarvestBlock(player, l);
flag = removeBlock(world, x, y, z, flag1, player);
removedByPlayer = removeBlock(world, x, y, z, canHarvest, player);
if(itemstack != null) {
itemstack.func_150999_a(world, block, x, y, z, player);
@ -368,6 +368,10 @@ public class ItemToolAbility extends ItemTool implements IDepthRockTool, IGUIPro
player.destroyCurrentEquippedItem();
}
}
if(removedByPlayer && canHarvest) {
block.harvestBlock(world, player, x, y, z, l);
}
}
// Why was this commented out?

View File

@ -1682,6 +1682,14 @@ public class MainRegistry {
ignoreMappings.add("hbm:item.gun_cryolator_ammo");
ignoreMappings.add("hbm:item.canteen_fab");
ignoreMappings.add("hbm:item.fabsols_vodka");
ignoreMappings.add("hbm:item.test_nuke_igniter");
ignoreMappings.add("hbm:item.test_nuke_propellant");
ignoreMappings.add("hbm:item.test_nuke_tier1_shielding");
ignoreMappings.add("hbm:item.test_nuke_tier2_shielding");
ignoreMappings.add("hbm:item.test_nuke_tier1_bullet");
ignoreMappings.add("hbm:item.test_nuke_tier2_bullet");
ignoreMappings.add("hbm:item.test_nuke_tier1_target");
ignoreMappings.add("hbm:item.test_nuke_tier2_target");
/// REMAP ///
remapItems.put("hbm:item.gadget_explosive8", ModItems.early_explosive_lenses);

View File

@ -1,19 +1,47 @@
package com.hbm.tileentity.machine;
import java.util.HashMap;
import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.UpgradeManagerNT;
import com.hbm.inventory.container.ContainerMachineChemicalPlant;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIMachineChemicalPlant;
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.lib.Library;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.IUpgradeInfoProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.BobMathUtil;
import com.hbm.util.i18n.I18nUtil;
public class TileEntityMachineChemicalPlant extends TileEntityMachineBase {
import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IGUIProvider {
public FluidTank[] inputTanks;
public FluidTank[] outputTanks;
public long power;
public long maxPower = 1_000_000;
public int progress;
public int maxProgress;
public UpgradeManagerNT upgradeManager = new UpgradeManagerNT(this);
public TileEntityMachineChemicalPlant() {
super(22);
this.inputTanks = new FluidTank[3];
this.outputTanks = new FluidTank[3];
for(int i = 0; i < 3; i++) {
@ -30,5 +58,78 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase {
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
this.power = Library.chargeTEFromItems(slots, 0, power, maxPower);
upgradeManager.checkSlots(slots, 2, 3);
this.networkPackNT(100);
} else {
}
}
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
for(FluidTank tank : inputTanks) tank.serialize(buf);
for(FluidTank tank : outputTanks) tank.serialize(buf);
buf.writeLong(power);
buf.writeLong(maxPower);
buf.writeInt(progress);
buf.writeInt(maxProgress);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
for(FluidTank tank : inputTanks) tank.deserialize(buf);
for(FluidTank tank : outputTanks) tank.deserialize(buf);
this.power = buf.readLong();
this.maxPower = buf.readLong();
this.progress = buf.readInt();
this.maxProgress = buf.readInt();
}
@Override public long getPower() { return power; }
@Override public void setPower(long power) { this.power = power; }
@Override public long getMaxPower() { return maxPower; }
@Override public FluidTank[] getReceivingTanks() { return inputTanks; }
@Override public FluidTank[] getSendingTanks() { return outputTanks; }
@Override public FluidTank[] getAllTanks() { return new FluidTank[] {inputTanks[0], inputTanks[1], inputTanks[2], outputTanks[0], outputTanks[1], outputTanks[2]}; }
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerMachineChemicalPlant(player.inventory, this); }
@Override @SideOnly(Side.CLIENT) public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIMachineChemicalPlant(player.inventory, this); }
@Override
public boolean canProvideInfo(UpgradeType type, int level, boolean extendedInfo) {
return type == UpgradeType.SPEED || type == UpgradeType.POWER || type == UpgradeType.OVERDRIVE;
}
@Override
public void provideInfo(UpgradeType type, int level, List<String> info, boolean extendedInfo) {
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_chemical_plant));
if(type == UpgradeType.SPEED) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(KEY_DELAY, "-" + (level * 25) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(KEY_CONSUMPTION, "+" + (level * 300) + "%"));
}
if(type == UpgradeType.POWER) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(KEY_CONSUMPTION, "-" + (level * 30) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(KEY_DELAY, "+" + (level * 5) + "%"));
}
if(type == UpgradeType.OVERDRIVE) {
info.add((BobMathUtil.getBlink() ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GRAY) + "YES");
}
}
@Override
public HashMap<UpgradeType, Integer> getValidUpgrades() {
HashMap<UpgradeType, Integer> upgrades = new HashMap<>();
upgrades.put(UpgradeType.SPEED, 3);
upgrades.put(UpgradeType.POWER, 3);
upgrades.put(UpgradeType.OVERDRIVE, 6);
return upgrades;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB