Compare commits

..
1 Commits
Author SHA1 Message Date
Alexdoru 7db1a4efa8 show size of the compartement chests inventories in the tooltip 2026-11-26 21:52:05 +01:00
7 changed files with 73 additions and 74 deletions

No files matched your search

@@ -1,6 +1,9 @@
package binnie.core.machines; package binnie.core.machines;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -24,4 +27,13 @@ public class ItemMachine extends ItemBlock {
public String getItemStackDisplayName(ItemStack itemstack) { public String getItemStackDisplayName(ItemStack itemstack) {
return associatedBlock.getMachineName(itemstack.getItemDamage()); return associatedBlock.getMachineName(itemstack.getItemDamage());
} }
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
final MachinePackage pkg = associatedBlock.getPackage(stack.getItemDamage());
if (pkg != null) {
pkg.addTooltip(tooltip);
}
}
} }
@@ -1,5 +1,7 @@
package binnie.core.machines; package binnie.core.machines;
import java.util.List;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import binnie.core.util.I18N; import binnie.core.util.I18N;
@@ -71,4 +73,6 @@ public abstract class MachinePackage {
public String getInformation() { public String getInformation() {
return I18N.localise(group.getMod().getModID() + ".machine." + group.getShortUID() + "." + getUID() + ".info"); return I18N.localise(group.getMod().getModID() + ".machine." + group.getShortUID() + "." + getUID() + ".info");
} }
public void addTooltip(List<String> tooltip) {}
} }
@@ -1,15 +1,19 @@
package binnie.core.machines.storage; package binnie.core.machines.storage;
import java.util.List;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import binnie.core.BinnieCore; import binnie.core.BinnieCore;
import binnie.core.gui.BinnieCoreGUI;
import binnie.core.machines.IMachineType; import binnie.core.machines.IMachineType;
import binnie.core.machines.Machine; import binnie.core.machines.Machine;
import binnie.core.machines.MachinePackage; import binnie.core.machines.MachinePackage;
import binnie.core.machines.TileEntityMachine; import binnie.core.machines.TileEntityMachine;
import binnie.core.resource.BinnieResource; import binnie.core.resource.BinnieResource;
import binnie.core.resource.IBinnieTexture; import binnie.core.resource.IBinnieTexture;
import binnie.core.util.I18N;
enum Compartment implements IMachineType { enum Compartment implements IMachineType {
@@ -37,11 +41,36 @@ enum Compartment implements IMachineType {
public abstract static class PackageCompartment extends MachinePackage { public abstract static class PackageCompartment extends MachinePackage {
private final BinnieResource renderTexture; static final int ROWS_PER_TAB = 5;
protected PackageCompartment(String uid, IBinnieTexture renderTexture) { private final BinnieResource renderTexture;
private final int tabs;
private final int slotsPerTab;
protected PackageCompartment(String uid, IBinnieTexture renderTexture, int tabs, int slotsPerTab) {
super(uid, false); super(uid, false);
this.renderTexture = renderTexture.getTexture(); this.renderTexture = renderTexture.getTexture();
this.tabs = tabs;
this.slotsPerTab = slotsPerTab;
}
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, tabs, slotsPerTab);
}
@Override
public void addTooltip(List<String> tooltip) {
final int slotsPerRow = slotsPerTab / ROWS_PER_TAB;
final int slotsTotal = this.tabs * slotsPerTab;
tooltip.add(
I18N.localise(
"binniecore.machine.storage.tooltip.size",
slotsPerRow,
ROWS_PER_TAB,
this.tabs,
slotsTotal));
} }
@Override @Override
@@ -1,7 +1,5 @@
package binnie.core.machines.storage; package binnie.core.machines.storage;
import binnie.core.gui.BinnieCoreGUI;
import binnie.core.machines.Machine;
import binnie.core.texture.BinnieCoreTexture; import binnie.core.texture.BinnieCoreTexture;
public class StandardCompartment { public class StandardCompartment {
@@ -9,84 +7,42 @@ public class StandardCompartment {
public static class PackageCompartment extends Compartment.PackageCompartment { public static class PackageCompartment extends Compartment.PackageCompartment {
public PackageCompartment() { public PackageCompartment() {
super("compartment", BinnieCoreTexture.Compartment); super("compartment", BinnieCoreTexture.Compartment, 4, 25);
} }
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, 4, 25);
}
} }
public static class PackageCompartmentCopper extends Compartment.PackageCompartment { public static class PackageCompartmentCopper extends Compartment.PackageCompartment {
public PackageCompartmentCopper() { public PackageCompartmentCopper() {
super("compartmentCopper", BinnieCoreTexture.CompartmentCopper); super("compartmentCopper", BinnieCoreTexture.CompartmentCopper, 6, 25);
} }
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, 6, 25);
}
} }
public static class PackageCompartmentBronze extends Compartment.PackageCompartment { public static class PackageCompartmentBronze extends Compartment.PackageCompartment {
public PackageCompartmentBronze() { public PackageCompartmentBronze() {
super("compartmentBronze", BinnieCoreTexture.CompartmentBronze); super("compartmentBronze", BinnieCoreTexture.CompartmentBronze, 8, 25);
} }
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, 8, 25);
}
} }
public static class PackageCompartmentIron extends Compartment.PackageCompartment { public static class PackageCompartmentIron extends Compartment.PackageCompartment {
public PackageCompartmentIron() { public PackageCompartmentIron() {
super("compartmentIron", BinnieCoreTexture.CompartmentIron); super("compartmentIron", BinnieCoreTexture.CompartmentIron, 4, 50);
} }
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, 4, 50);
}
} }
public static class PackageCompartmentGold extends Compartment.PackageCompartment { public static class PackageCompartmentGold extends Compartment.PackageCompartment {
public PackageCompartmentGold() { public PackageCompartmentGold() {
super("compartmentGold", BinnieCoreTexture.CompartmentGold); super("compartmentGold", BinnieCoreTexture.CompartmentGold, 6, 50);
} }
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, 6, 50);
}
} }
public static class PackageCompartmentDiamond extends Compartment.PackageCompartment { public static class PackageCompartmentDiamond extends Compartment.PackageCompartment {
public PackageCompartmentDiamond() { public PackageCompartmentDiamond() {
super("compartmentDiamond", BinnieCoreTexture.CompartmentDiamond); super("compartmentDiamond", BinnieCoreTexture.CompartmentDiamond, 8, 50);
} }
@Override
public void createMachine(Machine machine) {
new ComponentBinnieCoreGUI(machine, BinnieCoreGUI.Compartment);
new ComponentCompartmentInventory(machine, 8, 50);
}
} }
} }
@@ -104,7 +104,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
tabs2 = new Integer[] { 4, 5, 6, 7 }; tabs2 = new Integer[] { 4, 5, 6, 7 };
} }
boolean doubleTabbed = tabs2.length > 0; boolean doubleTabbed = tabs2.length > 0;
int compartmentPageWidth = 16 + 18 * inv.getPageSize() / 5; int compartmentPageWidth = 16 + 18 * inv.getPageSize() / Compartment.PackageCompartment.ROWS_PER_TAB;
int compartmentPageHeight = 106; int compartmentPageHeight = 106;
int compartmentWidth = compartmentPageWidth + (doubleTabbed ? 48 : 24); int compartmentWidth = compartmentPageWidth + (doubleTabbed ? 48 : 24);
@@ -193,8 +193,12 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
slotsIDs[k] = i++; slotsIDs[k] = i++;
} }
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5) new ControlSlotArray(
.create(actions, InventoryType.Machine, slotsIDs); thisPage,
8,
8,
inv.getPageSize() / Compartment.PackageCompartment.ROWS_PER_TAB,
Compartment.PackageCompartment.ROWS_PER_TAB).create(actions, InventoryType.Machine, slotsIDs);
} }
MessageCraftGUI.sendToServer(actions); MessageCraftGUI.sendToServer(actions);
x += compartmentPageWidth; x += compartmentPageWidth;
@@ -1,7 +1,5 @@
package binnie.extrabees.products; package binnie.extrabees.products;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@@ -13,7 +11,6 @@ import binnie.core.BinnieCore;
import binnie.core.Mods; import binnie.core.Mods;
import binnie.extrabees.ExtraBees; import binnie.extrabees.ExtraBees;
import binnie.extrabees.core.ExtraBeeItems; import binnie.extrabees.core.ExtraBeeItems;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs; import forestry.api.core.Tabs;
@@ -82,7 +79,7 @@ public class ItemHoneyComb extends ItemProduct {
EnumHoneyComb.LATEX.addProduct(honeyDrop, 0.50f); EnumHoneyComb.LATEX.addProduct(honeyDrop, 0.50f);
EnumHoneyComb.LATEX.addProduct(beeswax, 0.85f); EnumHoneyComb.LATEX.addProduct(beeswax, 0.85f);
if (!OreDictionary.getOres("itemRubber").isEmpty()) { if (!OreDictionary.getOres("itemRubber").isEmpty()) {
EnumHoneyComb.LATEX.tryAddProduct(getOreDictionary("itemRubber"), 1.00f); EnumHoneyComb.LATEX.tryAddProduct(OreDictionary.getOres("itemRubber").get(0), 1.00f);
} else { } else {
EnumHoneyComb.LATEX.active = false; EnumHoneyComb.LATEX.active = false;
} }
@@ -119,7 +116,7 @@ public class ItemHoneyComb extends ItemProduct {
EnumHoneyComb.URANIUM.copyProducts(EnumHoneyComb.STONE); EnumHoneyComb.URANIUM.copyProducts(EnumHoneyComb.STONE);
if (!OreDictionary.getOres("crushedUranium").isEmpty()) { if (!OreDictionary.getOres("crushedUranium").isEmpty()) {
EnumHoneyComb.URANIUM.tryAddProduct(getOreDictionary("crushedUranium"), 0.50f); EnumHoneyComb.URANIUM.tryAddProduct(OreDictionary.getOres("crushedUranium").get(0), 0.50f);
} }
EnumHoneyComb.CLAY.tryAddProduct(beeswax, 0.25f); EnumHoneyComb.CLAY.tryAddProduct(beeswax, 0.25f);
@@ -136,7 +133,7 @@ public class ItemHoneyComb extends ItemProduct {
EnumHoneyComb.ACIDIC.addProduct(beeswax, 0.80f); EnumHoneyComb.ACIDIC.addProduct(beeswax, 0.80f);
EnumHoneyComb.ACIDIC.tryAddProduct(EnumHoneyDrop.ACID, 0.50f); EnumHoneyComb.ACIDIC.tryAddProduct(EnumHoneyDrop.ACID, 0.50f);
if (!OreDictionary.getOres("dustSulfur").isEmpty()) { if (!OreDictionary.getOres("dustSulfur").isEmpty()) {
EnumHoneyComb.ACIDIC.addProduct(getOreDictionary("dustSulfur"), 0.75f); EnumHoneyComb.ACIDIC.addProduct(OreDictionary.getOres("dustSulfur").get(0), 0.75f);
} }
EnumHoneyComb.VENOMOUS.addProduct(beeswax, 0.80f); EnumHoneyComb.VENOMOUS.addProduct(beeswax, 0.80f);
@@ -152,7 +149,7 @@ public class ItemHoneyComb extends ItemProduct {
EnumHoneyComb.COFFEE.addProduct(beeswax, 0.90f); EnumHoneyComb.COFFEE.addProduct(beeswax, 0.90f);
EnumHoneyComb.COFFEE.addProduct(honeyDrop, 0.75f); EnumHoneyComb.COFFEE.addProduct(honeyDrop, 0.75f);
if (!OreDictionary.getOres("dustCoffee").isEmpty()) { if (!OreDictionary.getOres("dustCoffee").isEmpty()) {
EnumHoneyComb.COFFEE.tryAddProduct(getOreDictionary("dustCoffee"), 0.75f); EnumHoneyComb.COFFEE.tryAddProduct(OreDictionary.getOres("dustCoffee").get(0), 0.75f);
} }
EnumHoneyComb.GLACIAL.tryAddProduct(EnumHoneyDrop.ICE, 0.80f); EnumHoneyComb.GLACIAL.tryAddProduct(EnumHoneyDrop.ICE, 0.80f);
@@ -160,7 +157,7 @@ public class ItemHoneyComb extends ItemProduct {
EnumHoneyComb.SHADOW.addProduct(honeyDrop, 0.50f); EnumHoneyComb.SHADOW.addProduct(honeyDrop, 0.50f);
if (!OreDictionary.getOres("dustObsidian").isEmpty()) { if (!OreDictionary.getOres("dustObsidian").isEmpty()) {
EnumHoneyComb.SHADOW.tryAddProduct(getOreDictionary("dustObsidian"), 0.75f); EnumHoneyComb.SHADOW.tryAddProduct(OreDictionary.getOres("dustObsidian").get(0), 0.75f);
} else { } else {
EnumHoneyComb.SHADOW.active = false; EnumHoneyComb.SHADOW.active = false;
} }
@@ -209,20 +206,20 @@ public class ItemHoneyComb extends ItemProduct {
EnumHoneyComb.SAWDUST.addProduct(honeyDrop, 0.25f); EnumHoneyComb.SAWDUST.addProduct(honeyDrop, 0.25f);
if (!OreDictionary.getOres("dustSawdust").isEmpty()) { if (!OreDictionary.getOres("dustSawdust").isEmpty()) {
EnumHoneyComb.SAWDUST.tryAddProduct(getOreDictionary("dustSawdust"), 1.00f); EnumHoneyComb.SAWDUST.tryAddProduct(OreDictionary.getOres("dustSawdust").get(0), 1.00f);
} else if (!OreDictionary.getOres("sawdust").isEmpty()) { } else if (!OreDictionary.getOres("sawdust").isEmpty()) {
EnumHoneyComb.SAWDUST.tryAddProduct(getOreDictionary("sawdust"), 1.00f); EnumHoneyComb.SAWDUST.tryAddProduct(OreDictionary.getOres("sawdust").get(0), 1.00f);
} }
EnumHoneyComb.CERTUS.addProduct(honeyDrop, 0.25f); EnumHoneyComb.CERTUS.addProduct(honeyDrop, 0.25f);
EnumHoneyComb.CERTUS.addProduct(new ItemStack(Items.quartz), 0.25f); EnumHoneyComb.CERTUS.addProduct(new ItemStack(Items.quartz), 0.25f);
if (!OreDictionary.getOres("dustCertusQuartz").isEmpty()) { if (!OreDictionary.getOres("dustCertusQuartz").isEmpty()) {
EnumHoneyComb.CERTUS.tryAddProduct(getOreDictionary("dustCertusQuartz"), 0.20f); EnumHoneyComb.CERTUS.tryAddProduct(OreDictionary.getOres("dustCertusQuartz").get(0), 0.20f);
} }
EnumHoneyComb.ENDERPEARL.addProduct(honeyDrop, 0.25f); EnumHoneyComb.ENDERPEARL.addProduct(honeyDrop, 0.25f);
if (!OreDictionary.getOres("dustEnderPearl").isEmpty()) { if (!OreDictionary.getOres("dustEnderPearl").isEmpty()) {
EnumHoneyComb.ENDERPEARL.tryAddProduct(getOreDictionary("dustEnderPearl"), 0.25f); EnumHoneyComb.ENDERPEARL.tryAddProduct(OreDictionary.getOres("dustEnderPearl").get(0), 0.25f);
} }
EnumHoneyComb.YELLORIUM.copyProducts(EnumHoneyComb.STONE); EnumHoneyComb.YELLORIUM.copyProducts(EnumHoneyComb.STONE);
@@ -262,15 +259,11 @@ public class ItemHoneyComb extends ItemProduct {
} }
} }
/// The item registered under `string`: MaterialLib's when it registers one, since other mods' items under the
/// same name are copies of it, else the first registered.
private static ItemStack getOreDictionary(String string) { private static ItemStack getOreDictionary(String string) {
List<ItemStack> ores = OreDictionary.getOres(string); if (!OreDictionary.getOres(string).isEmpty()) {
for (ItemStack ore : ores) { return OreDictionary.getOres(string).get(0);
GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(ore.getItem());
if (id != null && "materiallib".equals(id.modId)) return ore;
} }
return ores.isEmpty() ? null : ores.get(0); return null;
} }
@Override @Override
@@ -282,6 +282,7 @@ binniecore.machine.storage.tab.properties=Tab Properties
binniecore.machine.storage.tab.properties.desc=The label, color and icon of the Tab can be altered here. Clicking on the icon with a held item will change it binniecore.machine.storage.tab.properties.desc=The label, color and icon of the Tab can be altered here. Clicking on the icon with a held item will change it
binniecore.machine.storage.tab.name=Tab Name: binniecore.machine.storage.tab.name=Tab Name:
binniecore.machine.storage.tab.icon=Tab Icon: binniecore.machine.storage.tab.icon=Tab Icon:
binniecore.machine.storage.tooltip.size=Inventory %s*%s*%s - %s Slots
binniecore.machine.storage.tooltip.icon=Icon for Current Tab binniecore.machine.storage.tooltip.icon=Icon for Current Tab
binniecore.machine.storage.tooltip.icon.desc=Click here with an item to change binniecore.machine.storage.tooltip.icon.desc=Click here with an item to change
binniecore.machine.storage.tab.color=Color: binniecore.machine.storage.tab.color=Color: