mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-19 19:59:49 +00:00
Feature/refactoring (#96)
* Some refactoring * Added some localization * Added some localization
This commit is contained in:
1 parent
895dd048f1
commit
286137a4d3
29 files changed
+518
-505
No files matched your search
@@ -76,7 +76,7 @@ public class WindowFieldKit extends Window {
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Field Kit";
|
||||
return I18N.localise(BinnieCore.instance, "gui.fieldKit");
|
||||
}
|
||||
|
||||
private void setupValidators() {
|
||||
@@ -89,7 +89,7 @@ public class WindowFieldKit extends Window {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Individual";
|
||||
return I18N.localise(BinnieCore.instance, "gui.tooltip.individual");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@ public class WindowFieldKit extends Window {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Paper";
|
||||
return I18N.localise(BinnieCore.instance, "gui.tooltip.paper");
|
||||
}
|
||||
});
|
||||
getWindowInventory().disableAutoDispense(1);
|
||||
@@ -119,8 +119,8 @@ public class WindowFieldKit extends Window {
|
||||
GlassControl = new ControlImage(this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
|
||||
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(InventoryType.Window, 0);
|
||||
new ControlSlot(this, 208.0f, 8.0f).assign(InventoryType.Window, 1);
|
||||
(text = new ControlText(this, new IPoint(232.0f, 13.0f), "Paper")).setColor(2236962);
|
||||
(text = new ControlText(this, new IArea(0.0f, 120.0f, w(), 24.0f), "", TextJustification.MiddleCenter)).setColor(2236962);
|
||||
(text = new ControlText(this, new IPoint(232.0f, 13.0f), I18N.localise(BinnieCore.instance, "gui.tooltip.paper"))).setColor(0x222222);
|
||||
(text = new ControlText(this, new IArea(0.0f, 120.0f, w(), 24.0f), "", TextJustification.MiddleCenter)).setColor(0x222222);
|
||||
chromo = new ControlChromosome(this, 150.0f, 24.0f);
|
||||
|
||||
addEventHandler(new EventValueChanged.Handler() {
|
||||
@@ -230,7 +230,7 @@ public class WindowFieldKit extends Window {
|
||||
|
||||
if (item != null && !Analyser.isAnalysed(item)) {
|
||||
if (getWindowInventory().getStackInSlot(1) == null) {
|
||||
text.setValue("No Paper!");
|
||||
text.setValue(I18N.localise(BinnieCore.instance, "gui.tooltip.noPaper"));
|
||||
isAnalysing = false;
|
||||
analyseProgress = 1.0f;
|
||||
} else {
|
||||
@@ -264,7 +264,7 @@ public class WindowFieldKit extends Window {
|
||||
|
||||
@Override
|
||||
public String showInfoButton() {
|
||||
return "The Field Kit analyses bees, trees, flowers and butterflies. All that is required is a piece of paper to jot notes";
|
||||
return I18N.localise(BinnieCore.instance, "gui.fieldKit.info");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import binnie.core.craftgui.minecraft.control.ControlTabIcon;
|
||||
import binnie.core.craftgui.window.Panel;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.gui.ControlGenesisOption;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import forestry.api.genetics.IAllele;
|
||||
@@ -55,7 +56,7 @@ public class WindowGenesis extends Window {
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Genesis";
|
||||
return I18N.localise(BinnieCore.instance, "gui.genesis");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package binnie.core.item;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.gui.BinnieCoreGUI;
|
||||
import binnie.core.util.I18N;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.Tabs;
|
||||
@@ -32,6 +33,6 @@ public class ItemGenesis extends Item {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return "Genesis";
|
||||
return I18N.localise(BinnieCore.instance, "item.genesis.name");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package binnie.core.liquid;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extratrees.alcohol.AlcoholEffect;
|
||||
import binnie.extratrees.alcohol.drink.DrinkManager;
|
||||
import binnie.extratrees.alcohol.drink.IDrinkLiquid;
|
||||
@@ -31,8 +33,8 @@ public class ItemFluidContainer extends ItemFood {
|
||||
public static int LiquidLiqueuer = 640;
|
||||
public static int LiquidGenetics = 768;
|
||||
|
||||
private static Map<Integer, String> idToFluid = new HashMap<Integer, String>();
|
||||
private static Map<String, Integer> fluidToID = new HashMap<String, Integer>();
|
||||
private static Map<Integer, String> idToFluid = new HashMap<>();
|
||||
private static Map<String, Integer> fluidToID = new HashMap<>();
|
||||
|
||||
public static void registerFluid(IFluidType fluid, int id) {
|
||||
ItemFluidContainer.idToFluid.put(id, fluid.getIdentifier().toLowerCase());
|
||||
@@ -61,14 +63,14 @@ public class ItemFluidContainer extends ItemFood {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return "???";
|
||||
}
|
||||
|
||||
FluidStack fluid = getLiquid(itemstack);
|
||||
FluidStack fluid = getLiquid(stack);
|
||||
if (fluid == null) {
|
||||
return "Missing Fluid";
|
||||
return I18N.localise(BinnieCore.instance, "item.fluidContainer.missed");
|
||||
}
|
||||
return fluid.getFluid().getLocalizedName(fluid) + " " + container.getName();
|
||||
}
|
||||
@@ -101,7 +103,7 @@ public class ItemFluidContainer extends ItemFood {
|
||||
public int getColorFromItemStack(ItemStack item, int pass) {
|
||||
FluidStack fluid = getLiquid(item);
|
||||
if (fluid == null) {
|
||||
return 16777215;
|
||||
return 0xffffff;
|
||||
}
|
||||
if (pass == 0 && fluid.getFluid() instanceof BinnieFluid) {
|
||||
return ((BinnieFluid) fluid.getFluid()).fluidType.getContainerColor();
|
||||
@@ -154,7 +156,7 @@ public class ItemFluidContainer extends ItemFood {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int func_150905_g(ItemStack p_150905_1_) {
|
||||
public int func_150905_g(ItemStack stack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,7 @@ public class ManagerLiquid extends ManagerBase {
|
||||
Map<String, IFluidType> fluids;
|
||||
|
||||
public ManagerLiquid() {
|
||||
fluids = new LinkedHashMap<String, IFluidType>();
|
||||
}
|
||||
|
||||
public Collection<IFluidType> getFluidTypes() {
|
||||
return fluids.values();
|
||||
fluids = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public void createLiquids(IFluidType[] liquids, int startID) {
|
||||
@@ -71,8 +67,4 @@ public class ManagerLiquid extends ManagerBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IFluidType getFluidType(String liquid) {
|
||||
return fluids.get(liquid.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
enum AccessDirection {
|
||||
Both,
|
||||
In,
|
||||
@@ -9,11 +7,13 @@ enum AccessDirection {
|
||||
Neither;
|
||||
|
||||
boolean canInsert() {
|
||||
return this == AccessDirection.Both || this == AccessDirection.In;
|
||||
return this == AccessDirection.Both
|
||||
|| this == AccessDirection.In;
|
||||
}
|
||||
|
||||
boolean canExtract() {
|
||||
return this == AccessDirection.Both || this == AccessDirection.Out;
|
||||
return this == AccessDirection.Both
|
||||
|| this == AccessDirection.Out;
|
||||
}
|
||||
|
||||
boolean canAccess() {
|
||||
@@ -57,32 +57,4 @@ enum AccessDirection {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTextColour() {
|
||||
switch (this) {
|
||||
case Both:
|
||||
return EnumChatFormatting.GREEN.toString();
|
||||
|
||||
case In:
|
||||
return EnumChatFormatting.YELLOW.toString();
|
||||
|
||||
case Neither:
|
||||
return EnumChatFormatting.RED.toString();
|
||||
}
|
||||
return EnumChatFormatting.AQUA.toString();
|
||||
}
|
||||
|
||||
public int getShadeColour() {
|
||||
switch (this) {
|
||||
case Both:
|
||||
return 0x5555ff55;
|
||||
|
||||
case In:
|
||||
return 0x55ffff55;
|
||||
|
||||
case Neither:
|
||||
return 0x55ff5555;
|
||||
}
|
||||
return 0x5555ffff;
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,12 @@ public class ComponentChargedSlots extends MachineComponent implements INetwork.
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
if (name.equals("slot-charges")) {
|
||||
for (int i : charges.keySet()) {
|
||||
charges.put(i, nbt.getShort("" + i) / 100.0f);
|
||||
}
|
||||
if (!name.equals("slot-charges")) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i : charges.keySet()) {
|
||||
charges.put(i, nbt.getShort("" + i) / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +68,7 @@ public class ComponentChargedSlots extends MachineComponent implements INetwork.
|
||||
|
||||
@Override
|
||||
public float getCharge(int slot) {
|
||||
return charges.containsKey(slot) ? charges.get(slot) : 0.0f;
|
||||
return charges.getOrDefault(slot, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,15 +63,6 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
|
||||
markDirty();
|
||||
}
|
||||
|
||||
protected void transferItem(int indexFrom, int indexTo) {
|
||||
if (inventory.containsKey(indexFrom) && inventory.containsKey(indexTo)) {
|
||||
ItemStack newStack = inventory.get(indexFrom).getContent().copy();
|
||||
inventory.get(indexFrom).setContent(null);
|
||||
inventory.get(indexTo).setContent(newStack);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
@@ -158,7 +149,7 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
|
||||
|
||||
@Override
|
||||
public InventorySlot[] getSlots(int[] indexes) {
|
||||
List<InventorySlot> list = new ArrayList<InventorySlot>();
|
||||
List<InventorySlot> list = new ArrayList<>();
|
||||
for (int i : indexes) {
|
||||
if (getSlot(i) != null) {
|
||||
list.add(getSlot(i));
|
||||
@@ -221,6 +212,7 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
|
||||
slots.add(slot.getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
int[] ids = new int[slots.size()];
|
||||
for (int i = 0; i < slots.size(); ++i) {
|
||||
ids[i] = slots.get(i);
|
||||
|
||||
@@ -29,10 +29,6 @@ public class ComponentInventoryTransfer extends MachineComponent {
|
||||
transfers.add(new Storage(getMachine(), source, destination));
|
||||
}
|
||||
|
||||
public void performTransfer(int source, int[] destination) {
|
||||
new Storage(getMachine(), source, destination).transfer(getMachine().getInterface(IInventoryMachine.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
for (Transfer transfer : transfers) {
|
||||
|
||||
@@ -50,12 +50,11 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
}
|
||||
|
||||
private int fill(int tankIndex, FluidStack resource, boolean doFill) {
|
||||
if (!tanks.containsKey(tankIndex)) {
|
||||
return 0;
|
||||
}
|
||||
if (!isLiquidValidForTank(resource, tankIndex)) {
|
||||
if (!tanks.containsKey(tankIndex) ||
|
||||
!isLiquidValidForTank(resource, tankIndex)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TankSlot tank = tanks.get(tankIndex);
|
||||
int filled = tank.getTank().fill(resource, doFill);
|
||||
if (filled > 0) {
|
||||
@@ -68,6 +67,7 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
if (!tanks.containsKey(tankIndex)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TankSlot tank = tanks.get(tankIndex);
|
||||
FluidStack drained = tank.getTank().drain(maxDrain, doDrain);
|
||||
if (drained != null) {
|
||||
@@ -97,14 +97,16 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound.hasKey("liquidTanks")) {
|
||||
NBTTagList tanksNBT = nbttagcompound.getTagList("liquidTanks", 10);
|
||||
for (int i = 0; i < tanksNBT.tagCount(); ++i) {
|
||||
NBTTagCompound tankNBT = tanksNBT.getCompoundTagAt(i);
|
||||
int index = tankNBT.getInteger("index");
|
||||
if (tanks.containsKey(index)) {
|
||||
tanks.get(index).readFromNBT(tankNBT);
|
||||
}
|
||||
if (!nbttagcompound.hasKey("liquidTanks")) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagList tanksNBT = nbttagcompound.getTagList("liquidTanks", 10);
|
||||
for (int i = 0; i < tanksNBT.tagCount(); ++i) {
|
||||
NBTTagCompound tankNBT = tanksNBT.getCompoundTagAt(i);
|
||||
int index = tankNBT.getInteger("index");
|
||||
if (tanks.containsKey(index)) {
|
||||
tanks.get(index).readFromNBT(tankNBT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +132,8 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
@Override
|
||||
public boolean isLiquidValidForTank(FluidStack liquid, int tank) {
|
||||
TankSlot slot = getTankSlot(tank);
|
||||
return slot != null && (slot.isValid(liquid) && !slot.isReadOnly());
|
||||
return slot != null
|
||||
&& (slot.isValid(liquid) && !slot.isReadOnly());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,10 +163,10 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
int index = getTankIndexToDrain(from, null);
|
||||
if (tanks.containsKey(index)) {
|
||||
return drain(index, resource.amount, doDrain);
|
||||
if (!tanks.containsKey(index)) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
return drain(index, resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ public class InventorySlot extends BaseSlot<ItemStack> {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemStack.stackSize <= amount) {
|
||||
ItemStack returnStack = itemStack.copy();
|
||||
itemStack = null;
|
||||
|
||||
@@ -8,7 +8,10 @@ import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class MachineSide {
|
||||
public static final EnumSet<ForgeDirection> TOP_AND_BOTTOM = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN);
|
||||
public static final EnumSet<ForgeDirection> TOP_AND_BOTTOM = EnumSet.of(
|
||||
ForgeDirection.UP,
|
||||
ForgeDirection.DOWN
|
||||
);
|
||||
public static final EnumSet<ForgeDirection> NONE = EnumSet.noneOf(ForgeDirection.class);
|
||||
public static final EnumSet<ForgeDirection> SIDES = EnumSet.of(
|
||||
ForgeDirection.NORTH,
|
||||
|
||||
@@ -30,18 +30,6 @@ class SidedAccess {
|
||||
return getAccess(side).canExtract();
|
||||
}
|
||||
|
||||
public boolean canAccess(ForgeDirection side) {
|
||||
return getAccess(side).canAccess();
|
||||
}
|
||||
|
||||
public boolean canChangeInsert() {
|
||||
return !insertLocked;
|
||||
}
|
||||
|
||||
public boolean canChangeExtract() {
|
||||
return !extractLocked;
|
||||
}
|
||||
|
||||
public void forbidInsertChange() {
|
||||
insertLocked = true;
|
||||
}
|
||||
@@ -70,12 +58,6 @@ class SidedAccess {
|
||||
return dirs;
|
||||
}
|
||||
|
||||
public void setInsert(ForgeDirection side, boolean b) {
|
||||
if (getAccess(side).canInsert() != b) {
|
||||
accesses.put(side, getAccess(side).changeInsert(b));
|
||||
}
|
||||
}
|
||||
|
||||
public void setExtract(ForgeDirection side, boolean b) {
|
||||
if (getAccess(side).canExtract() != b) {
|
||||
accesses.put(side, getAccess(side).changeExtract(b));
|
||||
|
||||
@@ -8,9 +8,10 @@ import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class TankSlot extends BaseSlot<FluidStack> {
|
||||
public static String NameJuice = "Juice Tank";
|
||||
public static String NameWater = "Water Tank";
|
||||
public static String NameCupboard = "Cupboard Slot";
|
||||
public static final String NAME_JUICE = "Juice Tank";
|
||||
public static final String NAME_WATER = "Water Tank";
|
||||
public static final String NAME_CUPBOARD = "Cupboard Slot";
|
||||
|
||||
private FluidTank tank;
|
||||
|
||||
public TankSlot(int index, String name, int capacity) {
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.util.List;
|
||||
|
||||
@Optional.Interface(iface = "binnie.core.machines.component.IBuildcraft.TriggerProvider", modid = "BuildCraft|Silicon")
|
||||
public class ComponentPowerReceptor extends MachineComponent implements
|
||||
IPoweredMachine,
|
||||
IBuildcraft.TriggerProvider,
|
||||
IInteraction.ChunkUnload,
|
||||
IInteraction.Invalidation {
|
||||
IPoweredMachine,
|
||||
IBuildcraft.TriggerProvider,
|
||||
IInteraction.ChunkUnload,
|
||||
IInteraction.Invalidation {
|
||||
public float previousPower;
|
||||
public LinkedList<Float> inputs;
|
||||
|
||||
private boolean registeredToIC2EnergyNet;
|
||||
float previousPower;
|
||||
LinkedList<Float> inputs;
|
||||
static int inputAverageTicks = 20;
|
||||
private PowerInterface container;
|
||||
|
||||
public ComponentPowerReceptor(IMachine machine) {
|
||||
|
||||
Reference in new issue
Block a user