From dc9f9df28ff6d9f53a335d9de9ebc723ed11e23a Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:35:58 +1000 Subject: [PATCH 01/99] AbstractMod.java --- core/src/main/java/binnie/core/AbstractMod.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/AbstractMod.java b/core/src/main/java/binnie/core/AbstractMod.java index 56be5ca6e..1ff40d36f 100644 --- a/core/src/main/java/binnie/core/AbstractMod.java +++ b/core/src/main/java/binnie/core/AbstractMod.java @@ -38,17 +38,23 @@ public AbstractMod() { public abstract String getChannel(); + private static final IPacketID[] PACKET_IDS_EMPTY = new IPacketID[0]; + @Override public IPacketID[] getPacketIDs() { - return new IPacketID[0]; + return PACKET_IDS_EMPTY; } + private static final IBinnieGUID[] BINNIE_GUIDS_EMPTY = new IBinnieGUID[0]; + public IBinnieGUID[] getGUIDs() { - return new IBinnieGUID[0]; + return BINNIE_GUIDS_EMPTY; } + private static final Class[] CLASS_CONFIG_EMPTY = new Class[0]; + public Class[] getConfigs() { - return new Class[0]; + return CLASS_CONFIG_EMPTY; } public abstract IProxyCore getProxy(); From 2247599d5acd0e0cdea6e945610e64a142e3be78 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:37:19 +1000 Subject: [PATCH 02/99] AlvearyLogicStimulator.java --- .../binnie/extrabees/alveary/AlvearyLogicStimulator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extrabees/src/main/java/binnie/extrabees/alveary/AlvearyLogicStimulator.java b/extrabees/src/main/java/binnie/extrabees/alveary/AlvearyLogicStimulator.java index ecc25c844..d74b38bc0 100644 --- a/extrabees/src/main/java/binnie/extrabees/alveary/AlvearyLogicStimulator.java +++ b/extrabees/src/main/java/binnie/extrabees/alveary/AlvearyLogicStimulator.java @@ -32,11 +32,13 @@ public class AlvearyLogicStimulator extends AlvearyLogicElectrical { private boolean powered; private StimulatorCircuit[] modifiers; + private static final StimulatorCircuit[] STIMULATOR_CIRCUITS_EMPTY = new StimulatorCircuit[0]; + public AlvearyLogicStimulator() { super(10000); this.powerUsage = 0; this.powered = false; - this.modifiers = new StimulatorCircuit[0]; + this.modifiers = STIMULATOR_CIRCUITS_EMPTY; this.inv = new ChipsetItemStackHandler(); } @@ -78,7 +80,7 @@ private ICircuitBoard getHiveFrame() { public StimulatorCircuit[] getCircuits() { final ICircuitBoard board = this.getHiveFrame(); if (board == null) { - return new StimulatorCircuit[0]; + return STIMULATOR_CIRCUITS_EMPTY; } final ICircuit[] circuits = board.getCircuits(); final List mod = new ArrayList<>(); @@ -87,7 +89,7 @@ public StimulatorCircuit[] getCircuits() { mod.add((StimulatorCircuit) circuit); } } - return mod.toArray(new StimulatorCircuit[0]); + return mod.toArray(STIMULATOR_CIRCUITS_EMPTY); } @Override From 87d0f00285902330d1e656facfe722e4cf4d7d14 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:40:49 +1000 Subject: [PATCH 03/99] AnalystPageFruit.java --- .../extratrees/genetics/gui/analyst/AnalystPageFruit.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java b/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java index 586492eaf..ef8cd9987 100644 --- a/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java +++ b/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java @@ -57,7 +57,7 @@ public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager a FruitProviderPod pod = (FruitProviderPod) ind.getGenome().getFruitProvider(); Field f = FruitProviderPod.class.getDeclaredField("drops"); f.setAccessible(true); - Collections.addAll(products, ((Map) f.get(pod)).keySet().toArray(new ItemStack[0])); + Collections.addAll(products, ((Map) f.get(pod)).keySet().toArray(ITEM_STACKS_EMPTY)); } } catch (IllegalAccessException | NoSuchFieldException e) { throw new RuntimeException(e); @@ -118,7 +118,7 @@ public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager a FruitProviderPod pod2 = (FruitProviderPod) ((IAlleleFruit) a).getProvider(); Field field = FruitProviderPod.class.getDeclaredField("drops"); field.setAccessible(true); - Collections.addAll(stacks, ((Map) field.get(pod2)).keySet().toArray(new ItemStack[0])); + Collections.addAll(stacks, ((Map) field.get(pod2)).keySet().toArray(ITEM_STACKS_EMPTY)); } } catch (IllegalAccessException | NoSuchFieldException e) { throw new RuntimeException(e); @@ -131,6 +131,8 @@ public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager a setSize(new Point(getWidth(), y + 8)); } + private static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; + @Override public String getTitle() { return I18N.localise(AnalystConstants.FRUIT_KEY + ".title"); From 234b8638af746da51de663e530d2441ea6571050 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:42:50 +1000 Subject: [PATCH 04/99] BlockDesign.java --- design/src/main/java/binnie/design/blocks/BlockDesign.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/design/src/main/java/binnie/design/blocks/BlockDesign.java b/design/src/main/java/binnie/design/blocks/BlockDesign.java index c475d2783..43da36b50 100644 --- a/design/src/main/java/binnie/design/blocks/BlockDesign.java +++ b/design/src/main/java/binnie/design/blocks/BlockDesign.java @@ -199,9 +199,11 @@ public void registerModel(Item item, IModelManager manager) { manager.registerItemModel(item, new DesignMeshDefinition()); } + private static final IProperty[] PROPERTIES_EMPTY = new IProperty[0]; + @Override protected BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS}); + return new ExtendedBlockState(this, PROPERTIES_EMPTY, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS}); } @Override From 2fe06eb52681332fccce7e6c1e011a4635f1c760 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:44:18 +1000 Subject: [PATCH 05/99] Botany.java remove override method. It is same with AbstractMod --- botany/src/main/java/binnie/botany/Botany.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/botany/src/main/java/binnie/botany/Botany.java b/botany/src/main/java/binnie/botany/Botany.java index da673d233..70fc506b6 100644 --- a/botany/src/main/java/binnie/botany/Botany.java +++ b/botany/src/main/java/binnie/botany/Botany.java @@ -82,11 +82,6 @@ public IBinnieGUID[] getGUIDs() { return BotanyGUI.values(); } - @Override - public Class[] getConfigs() { - return new Class[0]; - } - @Override public IPacketID[] getPacketIDs() { return PacketID.values(); From f730dcab98a0dfd6b515f088457a17f129e8827c Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:45:42 +1000 Subject: [PATCH 06/99] ComponentTankContainer.java --- .../core/machines/inventory/ComponentTankContainer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java index 4f6840c65..a45b218ff 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java @@ -129,13 +129,15 @@ public IFluidTank getTank(final int index) { return this.getTanks()[index]; } + private static final IFluidTank[] FLUID_TANKS_EMPTY = new IFluidTank[0]; + @Override public IFluidTank[] getTanks() { final List tankList = new ArrayList<>(); for (final TankSlot tank : this.tanks.values()) { tankList.add(tank.getTank()); } - return tankList.toArray(new IFluidTank[0]); + return tankList.toArray(FLUID_TANKS_EMPTY); } @Override @@ -229,7 +231,7 @@ private IFluidTank[] getTanks() { for (final TankSlot tank : this.tanks.values()) { ltanks.add(tank.getTank()); } - return ltanks.toArray(new IFluidTank[0]); + return ltanks.toArray(FLUID_TANKS_EMPTY); } private static int getTankIndexToFill(Map tanks, @Nullable EnumFacing from, final FluidStack resource) { From 9306a8838978756ad495777b8fe47700032c99d8 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:46:31 +1000 Subject: [PATCH 07/99] ContainerCraftGUI.java --- .../java/binnie/core/gui/minecraft/ContainerCraftGUI.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java index aad4e0a48..51c48989a 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java @@ -383,6 +383,8 @@ public int getErrorType() { return this.errorType; } + private static final CustomSlot[] CUSTOM_SLOTS_EMPTY = new CustomSlot[0]; + public CustomSlot[] getCustomSlots() { final List slots = new ArrayList<>(); for (final Object object : this.inventorySlots) { @@ -390,7 +392,7 @@ public CustomSlot[] getCustomSlots() { slots.add((CustomSlot) object); } } - return slots.toArray(new CustomSlot[0]); + return slots.toArray(CUSTOM_SLOTS_EMPTY); } @SideOnly(Side.CLIENT) From 6c751845dc3092f971df2e402c96f6cf326e8ccd Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:47:56 +1000 Subject: [PATCH 08/99] DefaultMachineInventory.java --- .../binnie/core/machines/base/DefaultMachineInventory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java b/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java index 126a87a25..75f1e85f7 100644 --- a/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java +++ b/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java @@ -30,9 +30,11 @@ public boolean isUsableByPlayer(final EntityPlayer entityplayer) { public void markDirty() { } + private static final int[] SLOTS_FOR_FACE_EMPTY = new int[0]; + @Override public int[] getSlotsForFace(EnumFacing side) { - return new int[0]; + return SLOTS_FOR_FACE_EMPTY; } @Override From d0d8bb1975bae3d0dadd1d462ecf201b10a47720 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:50:36 +1000 Subject: [PATCH 09/99] DefaultTankContainer.java --- .../binnie/core/machines/base/DefaultTankContainer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java b/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java index a56b2441b..9941313b4 100644 --- a/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java +++ b/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java @@ -14,9 +14,12 @@ import binnie.core.machines.power.TankInfo; class DefaultTankContainer implements ITankMachine { + + private static final TankInfo[] TANK_INFOS_EMPTY = new TankInfo[0]; + @Override public TankInfo[] getTankInfos() { - return new TankInfo[0]; + return TANK_INFOS_EMPTY; } @Override @@ -61,8 +64,10 @@ public IFluidHandler getHandler(int[] targetTanks) { return null; } + private static final IFluidTank[] FLUID_TANKS_EMPTY = new IFluidTank[0]; + @Override public IFluidTank[] getTanks() { - return new IFluidTank[0]; + return FLUID_TANKS_EMPTY; } } From 62d828ad61faef2389077d946f3dcf8d8410540c Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:51:30 +1000 Subject: [PATCH 10/99] Engineering.java --- .../src/main/java/binnie/genetics/genetics/Engineering.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/genetics/src/main/java/binnie/genetics/genetics/Engineering.java b/genetics/src/main/java/binnie/genetics/genetics/Engineering.java index be4cf4eb1..1537eb83a 100644 --- a/genetics/src/main/java/binnie/genetics/genetics/Engineering.java +++ b/genetics/src/main/java/binnie/genetics/genetics/Engineering.java @@ -66,6 +66,8 @@ public static ItemStack addGene(ItemStack stack, IGene gene) { return stack; } + private static final IGene[] GENES_EMPTY = new IGene[0]; + public static IGene[] getGenes(ItemStack serum) { if (!serum.isEmpty()) { Item item = serum.getItem(); @@ -80,7 +82,7 @@ public static IGene[] getGenes(ItemStack serum) { } } } - return new IGene[0]; + return GENES_EMPTY; } public static int getCharges(ItemStack serum) { From 0e4c264d591af82932ac21c45fd8129b941ee866 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:53:23 +1000 Subject: [PATCH 11/99] ErrorState.java --- .../main/java/binnie/core/machines/errors/ErrorState.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/errors/ErrorState.java b/core/src/main/java/binnie/core/machines/errors/ErrorState.java index 7372b0d53..abe6759c2 100644 --- a/core/src/main/java/binnie/core/machines/errors/ErrorState.java +++ b/core/src/main/java/binnie/core/machines/errors/ErrorState.java @@ -41,9 +41,11 @@ public ErrorState(IErrorStateDefinition definition, int data) { } public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition) { - this(nameDefinition, definition, new int[0]); + this(nameDefinition, definition, DATA_EMPTY); } + private static final int[] DATA_EMPTY = new int[0]; + public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition, int[] data) { EnumErrorType type = definition.getType(); this.data = data; @@ -55,7 +57,7 @@ public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition de } public ErrorState(NBTTagCompound nbtTagCompound) { - this.data = new int[0]; + this.data = DATA_EMPTY; this.itemError = false; this.tankError = false; this.powerError = false; From a81a986411e365683a2265afc79c9868096b827f Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:54:35 +1000 Subject: [PATCH 12/99] WindowGenesis.java --- core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java index c423cb739..f3755d762 100644 --- a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java +++ b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java @@ -125,10 +125,12 @@ public void initialiseClient() { this.panelPickup = new Panel(this, 16, 140, 60, 42, MinecraftGUI.PanelType.BLACK); this.refreshTemplate(null); } + + private static final IChromosomeType[] CHROMOSOME_TYPES_EMPTY = new IChromosomeType[0]; private void refreshTemplate(@Nullable IChromosomeType selection) { List genes = new ArrayList<>(); - IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(new IChromosomeType[0]); + IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(CHROMOSOME_TYPES_EMPTY); for (IChromosomeType type : chromosomeTypes) { IAllele allele = this.template[type.ordinal()]; if (allele == null) { From e6ae7a7b50f9523fd849b7a7e406eed4b8d7254c Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:57:04 +1000 Subject: [PATCH 13/99] TransferRequest.java --- .../binnie/core/machines/transfer/TransferRequest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java b/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java index 7b1c90454..39d2ce139 100644 --- a/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java +++ b/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java @@ -32,10 +32,12 @@ public class TransferRequest { private boolean ignoreReadOnly; private final List insertedSlots; + private static final int[] DEFAULT_SLOTS_TANKS_EMPTY = new int[0]; + public TransferRequest(final ItemStack toTransfer, final IInventory destination) { this.returnItem = ItemStack.EMPTY; - this.targetSlots = new int[0]; - this.targetTanks = new int[0]; + this.targetSlots = DEFAULT_SLOTS_TANKS_EMPTY; + this.targetTanks = DEFAULT_SLOTS_TANKS_EMPTY; this.transferLiquids = true; this.ignoreReadOnly = false; this.insertedSlots = new ArrayList<>(); @@ -43,7 +45,7 @@ public TransferRequest(final ItemStack toTransfer, final IInventory destination) for (int i = 0; i < target.length; ++i) { target[i] = i; } - int[] targetTanks = new int[0]; + int[] targetTanks = DEFAULT_SLOTS_TANKS_EMPTY; if (destination instanceof ITankMachine) { targetTanks = new int[((ITankMachine) destination).getTanks().length]; for (int j = 0; j < targetTanks.length; ++j) { From f42565acf34d99dc2863c5eeb00818d89b302017 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 22:57:59 +1000 Subject: [PATCH 14/99] WindowCompartment.java --- .../binnie/core/machines/storage/WindowCompartment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index abeeb28a8..dfdb9a6f8 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -63,6 +63,8 @@ public WindowCompartment(final EntityPlayer player, @Nullable final IInventory i this.currentTab = 0; } + private static final Integer[] DEFAULT_TABS_EMPTY = new Integer[0]; + //TODO: Clean Up, Localise @Override @SideOnly(Side.CLIENT) @@ -74,8 +76,8 @@ public void initialiseClient() { int x = 16; final int y = 32; final ComponentCompartmentInventory inv = machine.getInterface(ComponentCompartmentInventory.class); - Integer[] tabs1 = new Integer[0]; - Integer[] tabs2 = new Integer[0]; + Integer[] tabs1 = DEFAULT_TABS_EMPTY; + Integer[] tabs2 = DEFAULT_TABS_EMPTY; if (inv.getTabCount() == 4) { tabs1 = new Integer[]{0, 1}; tabs2 = new Integer[]{2, 3}; From 2f551a05571c803e9f72d11f0ac2b5a89cc323a7 Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 23:02:31 +1000 Subject: [PATCH 15/99] MachineComponent.java, ManagerMachine.java, ItemSerumArray.java, RotatedOreIngredient.java --- .../main/java/binnie/core/machines/MachineComponent.java | 4 +++- core/src/main/java/binnie/core/machines/ManagerMachine.java | 4 +++- .../src/main/java/binnie/genetics/item/ItemSerumArray.java | 6 ++++-- .../java/binnie/genetics/recipes/RotatedOreIngredient.java | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/MachineComponent.java b/core/src/main/java/binnie/core/machines/MachineComponent.java index 333fb170d..606157b21 100644 --- a/core/src/main/java/binnie/core/machines/MachineComponent.java +++ b/core/src/main/java/binnie/core/machines/MachineComponent.java @@ -36,10 +36,12 @@ public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound) { public void onUpdate() { } + private static final Class[] CLASSES_EMPTY = new Class[0]; + public Class[] getComponentInterfaces() { Class[] componentInterfaces = Binnie.MACHINE.getComponentInterfaces(this.getClass()); if (componentInterfaces == null) { - return new Class[0]; + return CLASSES_EMPTY; } return componentInterfaces; } diff --git a/core/src/main/java/binnie/core/machines/ManagerMachine.java b/core/src/main/java/binnie/core/machines/ManagerMachine.java index 76cecb178..979e65884 100644 --- a/core/src/main/java/binnie/core/machines/ManagerMachine.java +++ b/core/src/main/java/binnie/core/machines/ManagerMachine.java @@ -64,6 +64,8 @@ public MachinePackage getPackage(final String group, final String name) { return (machineGroup == null) ? null : machineGroup.getPackage(name); } + private static final Class[] CLASSES_EMPTY = new Class[0]; + private void registerComponentClass(final Class component) { if (this.componentInterfaceMap.containsKey(component)) { return; @@ -74,7 +76,7 @@ private void registerComponentClass(final Class comp } interfaces.remove(INbtWritable.class); interfaces.remove(INbtReadable.class); - this.componentInterfaceMap.put(component, interfaces.toArray(new Class[0])); + this.componentInterfaceMap.put(component, interfaces.toArray(CLASSES_EMPTY)); final int networkID = this.nextNetworkID++; } diff --git a/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java b/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java index 67c4e8902..e480d8cbf 100644 --- a/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java +++ b/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java @@ -49,13 +49,15 @@ public int getMaxCharges(ItemStack stack) { return stack.getMaxDamage(); } + private static final IGene[] GENES_EMPTY = new IGene[0]; + @Override public IGene[] getGenes(final ItemStack stack) { GeneArrayItem geneItem = this.getGeneItem(stack); if (geneItem != null) { - return geneItem.getGenes().toArray(new IGene[0]); + return geneItem.getGenes().toArray(GENES_EMPTY); } - return new IGene[0]; + return GENES_EMPTY; } @Override diff --git a/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java b/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java index 6bb0b2e36..8f0e262b0 100644 --- a/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java +++ b/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java @@ -36,6 +36,8 @@ public RotatedOreIngredient(String ore, int offset) { this.offset = offset; } + private static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; + @Override @Nonnull public ItemStack[] getMatchingStacks() @@ -51,7 +53,7 @@ public ItemStack[] getMatchingStacks() lst.add(itemstack); } Collections.rotate(lst, offset); - this.array = lst.toArray(new ItemStack[0]); + this.array = lst.toArray(ITEM_STACKS_EMPTY); } return this.array; } From f25638a35947174babe13fa2fde5ed9862dddc7f Mon Sep 17 00:00:00 2001 From: RusTit Date: Thu, 5 Apr 2018 23:08:41 +1000 Subject: [PATCH 16/99] FlowerRoot.java - remove method override getRandomTemplate. It is same as in parent class. --- botany/src/main/java/binnie/botany/genetics/FlowerRoot.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/botany/src/main/java/binnie/botany/genetics/FlowerRoot.java b/botany/src/main/java/binnie/botany/genetics/FlowerRoot.java index fa3fcc2df..d2b50e42f 100644 --- a/botany/src/main/java/binnie/botany/genetics/FlowerRoot.java +++ b/botany/src/main/java/binnie/botany/genetics/FlowerRoot.java @@ -209,11 +209,6 @@ public IAllele[] getDefaultTemplate() { return alleles; } - @Override - public IAllele[] getRandomTemplate(Random rand) { - return speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(speciesTemplates.values().size())]; - } - @Override public ArrayList getMutations(boolean shuffle) { if (shuffle) { From f9efc57898c614200b8610130e8c37d8816227bc Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 13:48:26 +1000 Subject: [PATCH 17/99] Refactoring and clean up --- .../main/java/binnie/core/AbstractMod.java | 13 +++---- .../core/gui/genesis/WindowGenesis.java | 5 +-- .../core/gui/minecraft/ContainerCraftGUI.java | 5 +-- .../core/machines/MachineComponent.java | 5 ++- .../binnie/core/machines/ManagerMachine.java | 5 ++- .../base/DefaultMachineInventory.java | 5 ++- .../machines/base/DefaultTankContainer.java | 9 ++--- .../core/machines/errors/ErrorState.java | 7 ++-- .../inventory/ComponentTankContainer.java | 7 ++-- .../machines/storage/WindowCompartment.java | 7 ++-- .../machines/transfer/TransferRequest.java | 9 +++-- .../java/binnie/core/util/EmptyHelper.java | 34 +++++++++++++++++++ .../binnie/design/blocks/BlockDesign.java | 6 ++-- .../gui/analyst/AnalystPageFruit.java | 7 ++-- .../binnie/genetics/genetics/Engineering.java | 5 ++- .../binnie/genetics/item/ItemSerumArray.java | 7 ++-- .../recipes/RotatedOreIngredient.java | 5 ++- 17 files changed, 78 insertions(+), 63 deletions(-) diff --git a/core/src/main/java/binnie/core/AbstractMod.java b/core/src/main/java/binnie/core/AbstractMod.java index 1ff40d36f..3acdbb19a 100644 --- a/core/src/main/java/binnie/core/AbstractMod.java +++ b/core/src/main/java/binnie/core/AbstractMod.java @@ -19,6 +19,7 @@ import binnie.core.network.IPacketProvider; import binnie.core.network.packet.MessageBinnie; import binnie.core.proxy.IProxyCore; +import binnie.core.util.EmptyHelper; public abstract class AbstractMod implements IPacketProvider, IInitializable { protected final List modules; @@ -38,23 +39,17 @@ public AbstractMod() { public abstract String getChannel(); - private static final IPacketID[] PACKET_IDS_EMPTY = new IPacketID[0]; - @Override public IPacketID[] getPacketIDs() { - return PACKET_IDS_EMPTY; + return EmptyHelper.PACKET_IDS_EMPTY; } - private static final IBinnieGUID[] BINNIE_GUIDS_EMPTY = new IBinnieGUID[0]; - public IBinnieGUID[] getGUIDs() { - return BINNIE_GUIDS_EMPTY; + return EmptyHelper.BINNIE_GUIDS_EMPTY; } - private static final Class[] CLASS_CONFIG_EMPTY = new Class[0]; - public Class[] getConfigs() { - return CLASS_CONFIG_EMPTY; + return EmptyHelper.CLASS_ARRAY_EMPTY; } public abstract IProxyCore getProxy(); diff --git a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java index f3755d762..422fbfe66 100644 --- a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java +++ b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java @@ -41,6 +41,7 @@ import binnie.core.gui.minecraft.control.ControlTabIcon; import binnie.core.gui.window.Panel; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; import binnie.core.gui.ControlGenesisOption; import net.minecraftforge.fml.relauncher.SideOnly; @@ -126,11 +127,11 @@ public void initialiseClient() { this.refreshTemplate(null); } - private static final IChromosomeType[] CHROMOSOME_TYPES_EMPTY = new IChromosomeType[0]; + private void refreshTemplate(@Nullable IChromosomeType selection) { List genes = new ArrayList<>(); - IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(CHROMOSOME_TYPES_EMPTY); + IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(EmptyHelper.CHROMOSOME_TYPES_EMPTY); for (IChromosomeType type : chromosomeTypes) { IAllele allele = this.template[type.ordinal()]; if (allele == null) { diff --git a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java index 51c48989a..c29fd8cd8 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java @@ -25,6 +25,7 @@ import binnie.core.machines.transfer.TransferRequest; import binnie.core.machines.transfer.TransferResult; import binnie.core.network.packet.MessageContainerUpdate; +import binnie.core.util.EmptyHelper; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; import com.mojang.authlib.GameProfile; @@ -383,7 +384,7 @@ public int getErrorType() { return this.errorType; } - private static final CustomSlot[] CUSTOM_SLOTS_EMPTY = new CustomSlot[0]; + public CustomSlot[] getCustomSlots() { final List slots = new ArrayList<>(); @@ -392,7 +393,7 @@ public CustomSlot[] getCustomSlots() { slots.add((CustomSlot) object); } } - return slots.toArray(CUSTOM_SLOTS_EMPTY); + return slots.toArray(EmptyHelper.CUSTOM_SLOTS_EMPTY); } @SideOnly(Side.CLIENT) diff --git a/core/src/main/java/binnie/core/machines/MachineComponent.java b/core/src/main/java/binnie/core/machines/MachineComponent.java index 606157b21..d5312d815 100644 --- a/core/src/main/java/binnie/core/machines/MachineComponent.java +++ b/core/src/main/java/binnie/core/machines/MachineComponent.java @@ -1,5 +1,6 @@ package binnie.core.machines; +import binnie.core.util.EmptyHelper; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; @@ -36,12 +37,10 @@ public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound) { public void onUpdate() { } - private static final Class[] CLASSES_EMPTY = new Class[0]; - public Class[] getComponentInterfaces() { Class[] componentInterfaces = Binnie.MACHINE.getComponentInterfaces(this.getClass()); if (componentInterfaces == null) { - return CLASSES_EMPTY; + return EmptyHelper.CLASS_ARRAY_EMPTY; } return componentInterfaces; } diff --git a/core/src/main/java/binnie/core/machines/ManagerMachine.java b/core/src/main/java/binnie/core/machines/ManagerMachine.java index 979e65884..6ab5168ae 100644 --- a/core/src/main/java/binnie/core/machines/ManagerMachine.java +++ b/core/src/main/java/binnie/core/machines/ManagerMachine.java @@ -17,6 +17,7 @@ import binnie.core.machines.inventory.ValidatorSprite; import binnie.core.machines.render.RenderTESRMachine; import binnie.core.proxy.IBinnieProxy; +import binnie.core.util.EmptyHelper; import forestry.api.core.INbtReadable; import forestry.api.core.INbtWritable; @@ -64,8 +65,6 @@ public MachinePackage getPackage(final String group, final String name) { return (machineGroup == null) ? null : machineGroup.getPackage(name); } - private static final Class[] CLASSES_EMPTY = new Class[0]; - private void registerComponentClass(final Class component) { if (this.componentInterfaceMap.containsKey(component)) { return; @@ -76,7 +75,7 @@ private void registerComponentClass(final Class comp } interfaces.remove(INbtWritable.class); interfaces.remove(INbtReadable.class); - this.componentInterfaceMap.put(component, interfaces.toArray(CLASSES_EMPTY)); + this.componentInterfaceMap.put(component, interfaces.toArray(EmptyHelper.CLASS_ARRAY_EMPTY)); final int networkID = this.nextNetworkID++; } diff --git a/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java b/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java index 75f1e85f7..4d880afad 100644 --- a/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java +++ b/core/src/main/java/binnie/core/machines/base/DefaultMachineInventory.java @@ -8,6 +8,7 @@ import net.minecraft.util.text.TextComponentString; import binnie.core.machines.inventory.IInventoryMachine; +import binnie.core.util.EmptyHelper; class DefaultMachineInventory implements IInventoryMachine { private final DefaultInventory inventory; @@ -30,11 +31,9 @@ public boolean isUsableByPlayer(final EntityPlayer entityplayer) { public void markDirty() { } - private static final int[] SLOTS_FOR_FACE_EMPTY = new int[0]; - @Override public int[] getSlotsForFace(EnumFacing side) { - return SLOTS_FOR_FACE_EMPTY; + return EmptyHelper.INT_ARRAY_EMPTY; } @Override diff --git a/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java b/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java index 9941313b4..cc00b17a5 100644 --- a/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java +++ b/core/src/main/java/binnie/core/machines/base/DefaultTankContainer.java @@ -2,6 +2,7 @@ import javax.annotation.Nullable; +import binnie.core.util.EmptyHelper; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; @@ -15,11 +16,9 @@ class DefaultTankContainer implements ITankMachine { - private static final TankInfo[] TANK_INFOS_EMPTY = new TankInfo[0]; - @Override public TankInfo[] getTankInfos() { - return TANK_INFOS_EMPTY; + return EmptyHelper.TANK_INFO_EMPTY; } @Override @@ -64,10 +63,8 @@ public IFluidHandler getHandler(int[] targetTanks) { return null; } - private static final IFluidTank[] FLUID_TANKS_EMPTY = new IFluidTank[0]; - @Override public IFluidTank[] getTanks() { - return FLUID_TANKS_EMPTY; + return EmptyHelper.FLUID_TANKS_EMPTY; } } diff --git a/core/src/main/java/binnie/core/machines/errors/ErrorState.java b/core/src/main/java/binnie/core/machines/errors/ErrorState.java index abe6759c2..ad99ef276 100644 --- a/core/src/main/java/binnie/core/machines/errors/ErrorState.java +++ b/core/src/main/java/binnie/core/machines/errors/ErrorState.java @@ -10,6 +10,7 @@ import binnie.core.machines.inventory.InventorySlot; import binnie.core.machines.inventory.SlotValidator; import binnie.core.machines.inventory.Validator; +import binnie.core.util.EmptyHelper; import it.unimi.dsi.fastutil.ints.IntArraySet; import it.unimi.dsi.fastutil.ints.IntSet; import net.minecraft.entity.player.InventoryPlayer; @@ -41,11 +42,9 @@ public ErrorState(IErrorStateDefinition definition, int data) { } public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition) { - this(nameDefinition, definition, DATA_EMPTY); + this(nameDefinition, definition, EmptyHelper.INT_ARRAY_EMPTY); } - private static final int[] DATA_EMPTY = new int[0]; - public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition, int[] data) { EnumErrorType type = definition.getType(); this.data = data; @@ -57,7 +56,7 @@ public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition de } public ErrorState(NBTTagCompound nbtTagCompound) { - this.data = DATA_EMPTY; + this.data = EmptyHelper.INT_ARRAY_EMPTY; this.itemError = false; this.tankError = false; this.powerError = false; diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java index a45b218ff..0b1010815 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java @@ -22,6 +22,7 @@ import binnie.core.machines.MachineComponent; import binnie.core.machines.power.ITankMachine; import binnie.core.machines.power.TankInfo; +import binnie.core.util.EmptyHelper; import binnie.core.util.NBTUtil; public class ComponentTankContainer extends MachineComponent implements ITankMachine { @@ -129,15 +130,13 @@ public IFluidTank getTank(final int index) { return this.getTanks()[index]; } - private static final IFluidTank[] FLUID_TANKS_EMPTY = new IFluidTank[0]; - @Override public IFluidTank[] getTanks() { final List tankList = new ArrayList<>(); for (final TankSlot tank : this.tanks.values()) { tankList.add(tank.getTank()); } - return tankList.toArray(FLUID_TANKS_EMPTY); + return tankList.toArray(EmptyHelper.FLUID_TANKS_EMPTY); } @Override @@ -231,7 +230,7 @@ private IFluidTank[] getTanks() { for (final TankSlot tank : this.tanks.values()) { ltanks.add(tank.getTank()); } - return ltanks.toArray(FLUID_TANKS_EMPTY); + return ltanks.toArray(EmptyHelper.FLUID_TANKS_EMPTY); } private static int getTankIndexToFill(Map tanks, @Nullable EnumFacing from, final FluidStack resource) { diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index dfdb9a6f8..6db684916 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -49,6 +49,7 @@ import binnie.core.gui.window.Panel; import binnie.core.machines.Machine; import binnie.core.machines.transfer.TransferRequest; +import binnie.core.util.EmptyHelper; public class WindowCompartment extends WindowMachine implements IWindowAffectsShiftClick { private final Map panels; @@ -63,8 +64,6 @@ public WindowCompartment(final EntityPlayer player, @Nullable final IInventory i this.currentTab = 0; } - private static final Integer[] DEFAULT_TABS_EMPTY = new Integer[0]; - //TODO: Clean Up, Localise @Override @SideOnly(Side.CLIENT) @@ -76,8 +75,8 @@ public void initialiseClient() { int x = 16; final int y = 32; final ComponentCompartmentInventory inv = machine.getInterface(ComponentCompartmentInventory.class); - Integer[] tabs1 = DEFAULT_TABS_EMPTY; - Integer[] tabs2 = DEFAULT_TABS_EMPTY; + Integer[] tabs1 = EmptyHelper.DEFAULT_TABS_EMPTY; + Integer[] tabs2 = EmptyHelper.DEFAULT_TABS_EMPTY; if (inv.getTabCount() == 4) { tabs1 = new Integer[]{0, 1}; tabs2 = new Integer[]{2, 3}; diff --git a/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java b/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java index 39d2ce139..a6a6dbebb 100644 --- a/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java +++ b/core/src/main/java/binnie/core/machines/transfer/TransferRequest.java @@ -7,6 +7,7 @@ import binnie.core.machines.inventory.IInventorySlots; import binnie.core.machines.inventory.InventorySlot; import binnie.core.machines.power.ITankMachine; +import binnie.core.util.EmptyHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -32,12 +33,10 @@ public class TransferRequest { private boolean ignoreReadOnly; private final List insertedSlots; - private static final int[] DEFAULT_SLOTS_TANKS_EMPTY = new int[0]; - public TransferRequest(final ItemStack toTransfer, final IInventory destination) { this.returnItem = ItemStack.EMPTY; - this.targetSlots = DEFAULT_SLOTS_TANKS_EMPTY; - this.targetTanks = DEFAULT_SLOTS_TANKS_EMPTY; + this.targetSlots = EmptyHelper.INT_ARRAY_EMPTY; + this.targetTanks = EmptyHelper.INT_ARRAY_EMPTY; this.transferLiquids = true; this.ignoreReadOnly = false; this.insertedSlots = new ArrayList<>(); @@ -45,7 +44,7 @@ public TransferRequest(final ItemStack toTransfer, final IInventory destination) for (int i = 0; i < target.length; ++i) { target[i] = i; } - int[] targetTanks = DEFAULT_SLOTS_TANKS_EMPTY; + int[] targetTanks = EmptyHelper.INT_ARRAY_EMPTY; if (destination instanceof ITankMachine) { targetTanks = new int[((ITankMachine) destination).getTanks().length]; for (int j = 0; j < targetTanks.length; ++j) { diff --git a/core/src/main/java/binnie/core/util/EmptyHelper.java b/core/src/main/java/binnie/core/util/EmptyHelper.java index 41bccfa45..efc6bcb34 100644 --- a/core/src/main/java/binnie/core/util/EmptyHelper.java +++ b/core/src/main/java/binnie/core/util/EmptyHelper.java @@ -1,7 +1,41 @@ package binnie.core.util; +import binnie.core.api.genetics.IGene; +import binnie.core.gui.IBinnieGUID; +import binnie.core.gui.minecraft.CustomSlot; +import binnie.core.machines.power.TankInfo; +import binnie.core.network.IPacketID; +import forestry.api.genetics.IChromosomeType; +import net.minecraft.block.properties.IProperty; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.IFluidTank; + public final class EmptyHelper { private EmptyHelper() {} public static final String EMPTY_STRING = ""; + + public static final IPacketID[] PACKET_IDS_EMPTY = new IPacketID[0]; + + public static final IBinnieGUID[] BINNIE_GUIDS_EMPTY = new IBinnieGUID[0]; + + public static final Class[] CLASS_ARRAY_EMPTY = new Class[0]; + + public static final IChromosomeType[] CHROMOSOME_TYPES_EMPTY = new IChromosomeType[0]; + + public static final CustomSlot[] CUSTOM_SLOTS_EMPTY = new CustomSlot[0]; + + public static final int[] INT_ARRAY_EMPTY = new int[0]; + + public static final TankInfo[] TANK_INFO_EMPTY = new TankInfo[0]; + + public static final IFluidTank[] FLUID_TANKS_EMPTY = new IFluidTank[0]; + + public static final Integer[] DEFAULT_TABS_EMPTY = new Integer[0]; + + public static final IProperty[] PROPERTIES_EMPTY = new IProperty[0]; + + public static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; + + public static final IGene[] GENES_EMPTY = new IGene[0]; } diff --git a/design/src/main/java/binnie/design/blocks/BlockDesign.java b/design/src/main/java/binnie/design/blocks/BlockDesign.java index 43da36b50..8e7a16949 100644 --- a/design/src/main/java/binnie/design/blocks/BlockDesign.java +++ b/design/src/main/java/binnie/design/blocks/BlockDesign.java @@ -9,7 +9,6 @@ import binnie.design.api.IDesignSystem; import binnie.design.api.IToolHammer; import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; @@ -57,6 +56,7 @@ import binnie.core.models.ModelManager; import binnie.core.models.ModelMutlipass; import binnie.core.util.TileUtil; +import binnie.core.util.EmptyHelper; public abstract class BlockDesign extends BlockMetadata implements IMultipassBlock, IColoredBlock, ISpriteRegister, IItemModelRegister, IStateMapperRegister { public static final EnumFacing[] RENDER_DIRECTIONS = new EnumFacing[]{EnumFacing.DOWN, EnumFacing.UP, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.SOUTH}; @@ -199,11 +199,9 @@ public void registerModel(Item item, IModelManager manager) { manager.registerItemModel(item, new DesignMeshDefinition()); } - private static final IProperty[] PROPERTIES_EMPTY = new IProperty[0]; - @Override protected BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, PROPERTIES_EMPTY, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS}); + return new ExtendedBlockState(this, EmptyHelper.PROPERTIES_EMPTY, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS}); } @Override diff --git a/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java b/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java index ef8cd9987..9b03444e7 100644 --- a/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java +++ b/extratrees/src/main/java/binnie/extratrees/genetics/gui/analyst/AnalystPageFruit.java @@ -29,6 +29,7 @@ import binnie.core.gui.geometry.Point; import binnie.core.gui.minecraft.control.ControlItemDisplay; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; import binnie.core.util.UniqueItemStackSet; import binnie.genetics.api.analyst.AnalystConstants; import net.minecraftforge.fml.relauncher.Side; @@ -57,7 +58,7 @@ public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager a FruitProviderPod pod = (FruitProviderPod) ind.getGenome().getFruitProvider(); Field f = FruitProviderPod.class.getDeclaredField("drops"); f.setAccessible(true); - Collections.addAll(products, ((Map) f.get(pod)).keySet().toArray(ITEM_STACKS_EMPTY)); + Collections.addAll(products, ((Map) f.get(pod)).keySet().toArray(EmptyHelper.ITEM_STACKS_EMPTY)); } } catch (IllegalAccessException | NoSuchFieldException e) { throw new RuntimeException(e); @@ -118,7 +119,7 @@ public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager a FruitProviderPod pod2 = (FruitProviderPod) ((IAlleleFruit) a).getProvider(); Field field = FruitProviderPod.class.getDeclaredField("drops"); field.setAccessible(true); - Collections.addAll(stacks, ((Map) field.get(pod2)).keySet().toArray(ITEM_STACKS_EMPTY)); + Collections.addAll(stacks, ((Map) field.get(pod2)).keySet().toArray(EmptyHelper.ITEM_STACKS_EMPTY)); } } catch (IllegalAccessException | NoSuchFieldException e) { throw new RuntimeException(e); @@ -131,8 +132,6 @@ public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager a setSize(new Point(getWidth(), y + 8)); } - private static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; - @Override public String getTitle() { return I18N.localise(AnalystConstants.FRUIT_KEY + ".title"); diff --git a/genetics/src/main/java/binnie/genetics/genetics/Engineering.java b/genetics/src/main/java/binnie/genetics/genetics/Engineering.java index 1537eb83a..99575c475 100644 --- a/genetics/src/main/java/binnie/genetics/genetics/Engineering.java +++ b/genetics/src/main/java/binnie/genetics/genetics/Engineering.java @@ -12,6 +12,7 @@ import binnie.genetics.item.GeneticsItems; import binnie.genetics.item.ItemSerum; import binnie.genetics.item.ItemSerumArray; +import binnie.core.util.EmptyHelper; public class Engineering { public static boolean isGeneAcceptor(ItemStack stack) { @@ -66,8 +67,6 @@ public static ItemStack addGene(ItemStack stack, IGene gene) { return stack; } - private static final IGene[] GENES_EMPTY = new IGene[0]; - public static IGene[] getGenes(ItemStack serum) { if (!serum.isEmpty()) { Item item = serum.getItem(); @@ -82,7 +81,7 @@ public static IGene[] getGenes(ItemStack serum) { } } } - return GENES_EMPTY; + return EmptyHelper.GENES_EMPTY; } public static int getCharges(ItemStack serum) { diff --git a/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java b/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java index e480d8cbf..3896d2019 100644 --- a/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java +++ b/genetics/src/main/java/binnie/genetics/item/ItemSerumArray.java @@ -19,6 +19,7 @@ import binnie.core.Binnie; import binnie.core.genetics.Gene; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; import binnie.genetics.Genetics; import binnie.core.api.genetics.IGene; import binnie.genetics.api.IItemSerum; @@ -49,15 +50,13 @@ public int getMaxCharges(ItemStack stack) { return stack.getMaxDamage(); } - private static final IGene[] GENES_EMPTY = new IGene[0]; - @Override public IGene[] getGenes(final ItemStack stack) { GeneArrayItem geneItem = this.getGeneItem(stack); if (geneItem != null) { - return geneItem.getGenes().toArray(GENES_EMPTY); + return geneItem.getGenes().toArray(EmptyHelper.GENES_EMPTY); } - return GENES_EMPTY; + return EmptyHelper.GENES_EMPTY; } @Override diff --git a/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java b/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java index 8f0e262b0..c204227fb 100644 --- a/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java +++ b/genetics/src/main/java/binnie/genetics/recipes/RotatedOreIngredient.java @@ -5,6 +5,7 @@ import java.util.Collections; +import binnie.core.util.EmptyHelper; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntComparators; import it.unimi.dsi.fastutil.ints.IntList; @@ -36,8 +37,6 @@ public RotatedOreIngredient(String ore, int offset) { this.offset = offset; } - private static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; - @Override @Nonnull public ItemStack[] getMatchingStacks() @@ -53,7 +52,7 @@ public ItemStack[] getMatchingStacks() lst.add(itemstack); } Collections.rotate(lst, offset); - this.array = lst.toArray(ITEM_STACKS_EMPTY); + this.array = lst.toArray(EmptyHelper.ITEM_STACKS_EMPTY); } return this.array; } From 3164761a0e2cc7d5dab71acf22fd6de8698c6c7f Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 14:57:20 +1000 Subject: [PATCH 18/99] Small refactor --- .../java/binnie/core/block/BlockMetadata.java | 20 +++++++++---------- .../binnie/core/gui/renderer/RenderUtil.java | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/binnie/core/block/BlockMetadata.java b/core/src/main/java/binnie/core/block/BlockMetadata.java index 212e0c55c..7d8d4bde7 100644 --- a/core/src/main/java/binnie/core/block/BlockMetadata.java +++ b/core/src/main/java/binnie/core/block/BlockMetadata.java @@ -24,42 +24,40 @@ public BlockMetadata(final Material material) { } public static ItemStack getBlockDropped(IBlockMetadata block, IBlockAccess world, BlockPos pos) { - TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); + final TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); if (tile != null && !tile.hasDroppedBlock()) { - int meta = block.getDroppedMeta(world.getBlockState(pos), tile.getTileMetadata()); + final int meta = block.getDroppedMeta(world.getBlockState(pos), tile.getTileMetadata()); return TileEntityMetadata.getItemStack((Block) block, meta); } return ItemStack.EMPTY; } public static void getDrops(NonNullList drops, IBlockMetadata block, IBlockAccess world, BlockPos pos) { - ItemStack drop = getBlockDropped(block, world, pos); + final ItemStack drop = getBlockDropped(block, world, pos); if (!drop.isEmpty()) { drops.add(drop); } } public static boolean breakBlock(IBlockMetadata blockMetadata, @Nullable EntityPlayer player, World world, BlockPos pos) { - List drops = new ArrayList<>(); - Block block = (Block) blockMetadata; - TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); + List drops = null; + final Block block = (Block) blockMetadata; + final TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); if (tile != null && !tile.hasDroppedBlock()) { drops = block.getDrops(world, pos, world.getBlockState(pos), 0); } boolean hasBeenBroken = world.setBlockToAir(pos); - if (hasBeenBroken && !world.isRemote && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) { + if (hasBeenBroken && !world.isRemote && drops != null && (player == null || !player.capabilities.isCreativeMode)) { for (ItemStack drop : drops) { spawnAsEntity(world, pos, drop); } - if (tile != null) { - tile.dropBlock(); - } + tile.dropBlock(); } return hasBeenBroken; } public static ItemStack getPickBlock(World world, BlockPos pos) { - Block block = world.getBlockState(pos).getBlock(); + final Block block = world.getBlockState(pos).getBlock(); return getBlockDropped((IBlockMetadata) block, world, pos); } diff --git a/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java b/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java index cb60865bf..877c96d2d 100644 --- a/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java +++ b/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java @@ -92,8 +92,8 @@ public static void drawTexture(double xCoord, double yCoord, TextureAtlasSprite double uMax = textureSprite.getMaxU(); double vMin = textureSprite.getMinV(); double vMax = textureSprite.getMaxV(); - uMax = uMax - maskRight / 16.0 * (uMax - uMin); - vMax = vMax - maskTop / 16.0 * (vMax - vMin); + uMax -= maskRight / 16.0 * (uMax - uMin); + vMax -= maskTop / 16.0 * (vMax - vMin); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); From 67f6167894762f8636990a8dbc6368557699252c Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 15:02:43 +1000 Subject: [PATCH 19/99] Small refactor --- core/src/main/java/binnie/core/block/BlockMetadata.java | 1 - core/src/main/java/binnie/core/block/ItemMetadata.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/block/BlockMetadata.java b/core/src/main/java/binnie/core/block/BlockMetadata.java index 7d8d4bde7..bd030e0b9 100644 --- a/core/src/main/java/binnie/core/block/BlockMetadata.java +++ b/core/src/main/java/binnie/core/block/BlockMetadata.java @@ -1,7 +1,6 @@ package binnie.core.block; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; diff --git a/core/src/main/java/binnie/core/block/ItemMetadata.java b/core/src/main/java/binnie/core/block/ItemMetadata.java index a85a6ca9b..806740e8c 100644 --- a/core/src/main/java/binnie/core/block/ItemMetadata.java +++ b/core/src/main/java/binnie/core/block/ItemMetadata.java @@ -27,7 +27,7 @@ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, B if (!(block instanceof IBlockMetadata)) { return false; } - int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, pos, side); + final int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, pos, side); if (placedMeta < 0) { return false; } @@ -35,7 +35,7 @@ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, B return false; } if (world.getBlockState(pos).getBlock() == block) { - TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); + final TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); if (tile != null) { tile.setTileMetadata(placedMeta, false); } From 9e666289fa22e810e035965657f6b5a4b3ec7f54 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 15:25:36 +1000 Subject: [PATCH 20/99] Small refactor --- .../main/java/binnie/core/block/TileEntityMetadata.java | 8 +++++--- .../src/main/java/binnie/core/circuits/BinnieCircuit.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/binnie/core/block/TileEntityMetadata.java b/core/src/main/java/binnie/core/block/TileEntityMetadata.java index 9be053ee6..6540302ba 100644 --- a/core/src/main/java/binnie/core/block/TileEntityMetadata.java +++ b/core/src/main/java/binnie/core/block/TileEntityMetadata.java @@ -40,8 +40,10 @@ public static ItemStack getItemStack(final Block block, final int damage) { return itemStack; } + private static final int MAX_ITEM_DAMAGE = 16387; + public static void setItemDamage(final ItemStack item, final int i) { - item.setItemDamage((i < 16387) ? i : 16387); + item.setItemDamage((i < MAX_ITEM_DAMAGE) ? i : MAX_ITEM_DAMAGE); final NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("meta", i); item.setTagCompound(tag); @@ -76,7 +78,7 @@ public NBTTagCompound getUpdateTag() { @Override public void readFromNBT(final NBTTagCompound nbt) { super.readFromNBT(nbt); - if(world!=null) + if (world != null) setTileMetadata(nbt.getInteger("meta"), world.isRemote); else this.meta = nbt.getInteger("meta"); @@ -97,7 +99,7 @@ public void setTileMetadata(final int meta, final boolean notify) { if (this.meta != meta) { this.meta = meta; if (notify) { - IBlockState state = world.getBlockState(pos); + final IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 3); } } diff --git a/core/src/main/java/binnie/core/circuits/BinnieCircuit.java b/core/src/main/java/binnie/core/circuits/BinnieCircuit.java index 174868d77..e244c6323 100644 --- a/core/src/main/java/binnie/core/circuits/BinnieCircuit.java +++ b/core/src/main/java/binnie/core/circuits/BinnieCircuit.java @@ -14,8 +14,10 @@ public class BinnieCircuit implements ICircuit { private final int limit; private final List tooltips; + private static final int TOOLTIPS_ARRAY_CAPACITY = 8; + public BinnieCircuit(final String uid, final int limit, final ICircuitLayout layout, final ItemStack itemStack) { - this.tooltips = new ArrayList<>(); + this.tooltips = new ArrayList<>(TOOLTIPS_ARRAY_CAPACITY); this.uid = "for.binnie.circuit." + uid; this.limit = limit; ChipsetManager.circuitRegistry.registerCircuit(this); From 56e3a6ce0d942ac225eeccd8fe0e8efdcc6d5911 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 15:34:23 +1000 Subject: [PATCH 21/99] AlleleHelper.java - add final to vars in methods. --- .../binnie/core/genetics/AlleleHelper.java | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/binnie/core/genetics/AlleleHelper.java b/core/src/main/java/binnie/core/genetics/AlleleHelper.java index afd341ad8..393f615ba 100644 --- a/core/src/main/java/binnie/core/genetics/AlleleHelper.java +++ b/core/src/main/java/binnie/core/genetics/AlleleHelper.java @@ -18,78 +18,78 @@ import javax.annotation.Nullable; public class AlleleHelper extends forestry.core.genetics.alleles.AlleleHelper { - public static IAllele getAllele(EnumTemperature temperature) { + public static IAllele getAllele(final EnumTemperature temperature) { return getAllele(getUid(temperature)); } - public static IAllele getAllele(EnumHumidity humidity) { + public static IAllele getAllele(final EnumHumidity humidity) { return getAllele(getUid(humidity)); } - public static IAllele getAllele(EnumTolerance tolerance) { + public static IAllele getAllele(final EnumTolerance tolerance) { return getAllele(getUid(tolerance)); } - public static IAllele getAllele(EnumAllele.Fertility fertility) { + public static IAllele getAllele(final EnumAllele.Fertility fertility) { return getAllele(getUid(fertility)); } - public static IAllele getAllele(EnumAllele.Territory territory) { + public static IAllele getAllele(final EnumAllele.Territory territory) { return getAllele(getUid(territory)); } - public static IAllele getAllele(EnumAllele.Lifespan lifespan) { + public static IAllele getAllele(final EnumAllele.Lifespan lifespan) { return getAllele(getUid(lifespan)); } - public static IAllele getAllele(EnumAllele.Sappiness sappiness) { + public static IAllele getAllele(final EnumAllele.Sappiness sappiness) { return getAllele(getUid(sappiness)); } - public static IAllele getAllele(EnumAllele.Speed speed) { + public static IAllele getAllele(final EnumAllele.Speed speed) { return getAllele(getUid(speed)); } - public static IAllele getAllele(EnumAllele.Flowering flowering) { + public static IAllele getAllele(final EnumAllele.Flowering flowering) { return getAllele(getUid(flowering)); } - public static IAllele getAllele(EnumAllele.Height height) { + public static IAllele getAllele(final EnumAllele.Height height) { return getAllele(getUid(height)); } - public static IAllele getAllele(EnumAllele.Maturation maturation) { + public static IAllele getAllele(final EnumAllele.Maturation maturation) { return getAllele(getUid(maturation)); } - public static IAllele getAllele(EnumAllele.Yield yield) { + public static IAllele getAllele(final EnumAllele.Yield yield) { return getAllele(getUid(yield)); } - public static IAllele getAllele(EnumAllele.Saplings saplings) { + public static IAllele getAllele(final EnumAllele.Saplings saplings) { return getAllele(getUid(saplings)); } - public static IAllele getAllele(int number) { + public static IAllele getAllele(final int number) { return getAllele("forestry.i" + number + 'd'); } - public static IAllele getAllele(boolean bool) { + public static IAllele getAllele(final boolean bool) { if (bool) { return getAllele("forestry.boolTrue"); } return getAllele("forestry.boolFalse"); } - public static IAllele getAllele(String uid) { + public static IAllele getAllele(final String uid) { return AlleleManager.alleleRegistry.getAllele(uid); } - public static String toDisplay(EnumTemperature temperature) { + public static String toDisplay(final EnumTemperature temperature) { return AlleleManager.climateHelper.toDisplay(temperature); } - public static String toDisplay(EnumHumidity humidity) { + public static String toDisplay(final EnumHumidity humidity) { return AlleleManager.climateHelper.toDisplay(humidity); } @@ -105,46 +105,46 @@ public static String toDisplay(EnumHumidity humidity) { // return I18N.localise("botany.soil." + soilType.getName()); // } - public static String toDisplay(EnumTolerance tolerance) { + public static String toDisplay(final EnumTolerance tolerance) { return toAlleleDisplay("tolerance", tolerance.name()); } - public static String toDisplay(EnumAllele.Flowering flowering) { + public static String toDisplay(final EnumAllele.Flowering flowering) { if (flowering == EnumAllele.Flowering.AVERAGE) { return toAlleleDisplay("flowering", "normal"); } return toAlleleDisplay(null, flowering.name()); } - public static String toDisplay(EnumAllele.Speed speed) { + public static String toDisplay(final EnumAllele.Speed speed) { return toAlleleDisplay(null, speed.name()); } - public static String toDisplay(EnumAllele.Lifespan lifespan) { + public static String toDisplay(final EnumAllele.Lifespan lifespan) { return toAlleleDisplay("lifespan", lifespan.name()); } - public static String getUid(EnumAllele.Fertility fertility) { + public static String getUid(final EnumAllele.Fertility fertility) { return getUid("fertility", fertility.name()); } - public static String getUid(EnumAllele.Lifespan lifespan) { + public static String getUid(final EnumAllele.Lifespan lifespan) { return getUid("lifespan", lifespan.name()); } - public static String getUid(EnumAllele.Sappiness sappiness) { + public static String getUid(final EnumAllele.Sappiness sappiness) { return getUid("sappiness", sappiness.name()); } - private static String getUid(EnumTemperature temperature) { + private static String getUid(final EnumTemperature temperature) { return getUid("temperature", temperature.name()); } - private static String getUid(EnumHumidity humidity) { + private static String getUid(final EnumHumidity humidity) { return getUid("humidity", humidity.name()); } - public static String getUid(EnumAllele.Saplings saplings) { + public static String getUid(final EnumAllele.Saplings saplings) { if (saplings == EnumAllele.Saplings.AVERAGE) { return getUid("saplings", "Default"); } @@ -157,51 +157,51 @@ public static String getUid(EnumAllele.Saplings saplings) { return getUid("saplings", saplings.name()); } - public static String getUid(EnumAllele.Height height) { + public static String getUid(final EnumAllele.Height height) { if (height == EnumAllele.Height.AVERAGE) { return getUid("height", "Max10", false); } return getUid("height", height.name()); } - public static String getUid(EnumAllele.Maturation maturation) { + public static String getUid(final EnumAllele.Maturation maturation) { return getUid("maturation", maturation.name()); } - public static String getUid(EnumAllele.Territory territory) { + public static String getUid(final EnumAllele.Territory territory) { return getUid("territory", territory.name()); } - public static String getUid(EnumAllele.Yield yield) { + public static String getUid(final EnumAllele.Yield yield) { if (yield == EnumAllele.Yield.AVERAGE) { return getUid("yield", "Default", false); } return getUid("yield", yield.name()); } - public static String getUid(EnumAllele.Fireproof fireproof) { + public static String getUid(final EnumAllele.Fireproof fireproof) { return getUid("bool", fireproof.name()); } - public static String getUid(EnumAllele.Flowering flowering) { + public static String getUid(final EnumAllele.Flowering flowering) { return getUid("flowering", flowering.name()); } - public static String getUid(EnumTolerance tolerance) { + public static String getUid(final EnumTolerance tolerance) { return getUid("tolerance", tolerance.name()); } - public static String getUid(EnumAllele.Speed speed) { + public static String getUid(final EnumAllele.Speed speed) { return getUid("speed", speed.name()); } - protected static String getUid(String key, String valueName) { + protected static String getUid(final String key, final String valueName) { return getUid(key, valueName, true); } private static final Pattern PATTERN_REPLACEMENT = Pattern.compile("_"); - private static String getUid(String key, String valueName, boolean needCapitalize) { + private static String getUid(final String key, String valueName, final boolean needCapitalize) { if (needCapitalize) { valueName = WordUtils.capitalize(valueName.toLowerCase(Locale.ENGLISH)); } @@ -209,7 +209,7 @@ private static String getUid(String key, String valueName, boolean needCapitaliz return "forestry." + key + valueName; } - private static String toAlleleDisplay(@Nullable String key, String valueName) { + private static String toAlleleDisplay(final @Nullable String key, final String valueName) { String name = PATTERN_REPLACEMENT.matcher(valueName.toLowerCase()).replaceAll(EmptyHelper.EMPTY_STRING); if (key == null) { return I18N.localise("forestry.allele." + name); From 1546d7cd0b0951f9eb928095523ef3b045444b9a Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 16:10:18 +1000 Subject: [PATCH 22/99] Refactoring BreedingSystem.java --- .../botany/genetics/FlowerBreedingSystem.java | 2 +- .../binnie/core/genetics/BreedingSystem.java | 138 +++++++++--------- 2 files changed, 66 insertions(+), 74 deletions(-) diff --git a/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java b/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java index 485191bf7..7a610966e 100644 --- a/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java +++ b/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java @@ -41,7 +41,7 @@ public FlowerBreedingSystem() { } @Override - public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies) { + public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) { return mutation.getBaseChance(); } diff --git a/core/src/main/java/binnie/core/genetics/BreedingSystem.java b/core/src/main/java/binnie/core/genetics/BreedingSystem.java index 09cc31616..e1301a25d 100644 --- a/core/src/main/java/binnie/core/genetics/BreedingSystem.java +++ b/core/src/main/java/binnie/core/genetics/BreedingSystem.java @@ -88,10 +88,8 @@ public String getChromosomeShortName(final IChromosomeType chromo) { @Override public final String getEpitome(final float discoveredPercentage) { - int i = 0; - if (discoveredPercentage == 1.0f) { - i = 6; - } else if (discoveredPercentage < 0.1f) { + int i; + if (discoveredPercentage < 0.1f) { i = 0; } else if (discoveredPercentage < 0.3f) { i = 1; @@ -103,6 +101,8 @@ public final String getEpitome(final float discoveredPercentage) { i = 4; } else if (discoveredPercentage < 1.0f) { i = 5; + } else { + i = 6; } return I18N.localise("binniecore." + this.getSpeciesRoot().getUID() + ".epitome." + i); } @@ -127,26 +127,26 @@ public final Collection getAllMutations() { @Override public void calculateArrays() { - ISpeciesRoot speciesRoot = getSpeciesRoot(); + final ISpeciesRoot speciesRoot = getSpeciesRoot(); calculateAlleles(speciesRoot); calculateBranches(speciesRoot); calculateMutations(speciesRoot); } @Override - public void calculateAlleles(ISpeciesRoot speciesRoot) { + public void calculateAlleles(final ISpeciesRoot speciesRoot) { this.allSpecies = new ArrayList<>(); this.allActiveSpecies = new ArrayList<>(); this.resultantMutations.clear(); this.furtherMutations.clear(); this.allResultantMutations.clear(); this.allFurtherMutations.clear(); - Collection allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values(); - for (IAllele allele : allAlleles) { + final Collection allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values(); + for (final IAllele allele : allAlleles) { String uid = allele.getUID(); - IAllele[] template = speciesRoot.getTemplate(uid); + final IAllele[] template = speciesRoot.getTemplate(uid); if (template != null) { - IAlleleSpecies species = (IAlleleSpecies) allele; + final IAlleleSpecies species = (IAlleleSpecies) allele; this.allSpecies.add(species); if (isBlacklisted(allele) || uid.contains("speciesBotAlfheim")) { continue; @@ -157,53 +157,50 @@ public void calculateAlleles(ISpeciesRoot speciesRoot) { } @Override - public void calculateBranches(ISpeciesRoot speciesRoot) { - Collection allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values(); - this.allBranches = new ArrayList<>(); - for (IClassification branch : allRegBranches) { - IAlleleSpecies[] species = branch.getMemberSpecies(); - if (species.length <= 0) { + public void calculateBranches(final ISpeciesRoot speciesRoot) { + final Collection allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values(); + this.allBranches.clear(); + for (final IClassification branch : allRegBranches) { + final IAlleleSpecies[] species = branch.getMemberSpecies(); + if (species.length == 0) { continue; } - IAlleleSpecies firstSpecies = species[0]; - IAllele[] template = speciesRoot.getTemplate(firstSpecies.getUID()); + final IAlleleSpecies firstSpecies = species[0]; + final IAllele[] template = speciesRoot.getTemplate(firstSpecies.getUID()); if (template != null) { - boolean possible = false; - for (IAlleleSpecies species2 : branch.getMemberSpecies()) { + for (final IAlleleSpecies species2 : branch.getMemberSpecies()) { if (allActiveSpecies.contains(species2)) { - possible = true; + this.allBranches.add(branch); + break; } } - if (!possible) { - continue; - } - this.allBranches.add(branch); } } } @Override public void calculateMutations(ISpeciesRoot speciesRoot) { - this.allMutations = new ArrayList<>(); - List speciesMutations = speciesRoot.getMutations(false); - if (!speciesMutations.isEmpty()) { - final Set mutations = new LinkedHashSet<>(speciesMutations); - for (final IMutation mutation : mutations) { - this.allMutations.add(mutation); - final Set participatingSpecies = new LinkedHashSet<>(); - participatingSpecies.add(mutation.getAllele0()); - participatingSpecies.add(mutation.getAllele1()); - for (final IAlleleSpecies species : participatingSpecies) { - this.allFurtherMutations.put(species, mutation); - if (this.allActiveSpecies.contains(species)) { - this.furtherMutations.put(species, mutation); - } + this.allMutations.clear(); + final List speciesMutations = speciesRoot.getMutations(false); + if (speciesMutations.isEmpty()) { + return; + } + final Set mutations = new LinkedHashSet<>(speciesMutations); + for (final IMutation mutation : mutations) { + this.allMutations.add(mutation); + final Set participatingSpecies = new LinkedHashSet<>(); + participatingSpecies.add(mutation.getAllele0()); + participatingSpecies.add(mutation.getAllele1()); + for (final IAlleleSpecies species : participatingSpecies) { + this.allFurtherMutations.put(species, mutation); + if (this.allActiveSpecies.contains(species)) { + this.furtherMutations.put(species, mutation); } - IAllele[] template = mutation.getTemplate(); - IAlleleSpecies speciesAllele = (IAlleleSpecies) template[0]; - this.allResultantMutations.put(speciesAllele, mutation); - this.resultantMutations.put(speciesAllele, mutation); } + final IAllele[] template = mutation.getTemplate(); + final IAlleleSpecies speciesAllele = (IAlleleSpecies) template[0]; + this.allResultantMutations.put(speciesAllele, mutation); + this.resultantMutations.put(speciesAllele, mutation); } } @@ -266,16 +263,13 @@ public final boolean isSecret(final IClassification branch) { @Override public final Collection getDiscoveredBranches(final World world, final GameProfile player) { final List branches = new ArrayList<>(); - for (final IClassification branch : this.getAllBranches()) { - boolean discovered = false; + for (final IClassification branch : this.allBranches) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, world, player)) { - discovered = true; + branches.add(branch); + break; } } - if (discovered) { - branches.add(branch); - } } return branches; } @@ -283,16 +277,13 @@ public final Collection getDiscoveredBranches(final World world @Override public final Collection getDiscoveredBranches(final IBreedingTracker tracker) { final List branches = new ArrayList<>(); - for (final IClassification branch : this.getAllBranches()) { - boolean discovered = false; + for (final IClassification branch : this.allBranches) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, tracker)) { - discovered = true; + branches.add(branch); + break; } } - if (discovered) { - branches.add(branch); - } } return branches; } @@ -300,7 +291,7 @@ public final Collection getDiscoveredBranches(final IBreedingTr @Override public final Collection getDiscoveredSpecies(final World world, final GameProfile player) { final List speciesList = new ArrayList<>(); - for (final IAlleleSpecies species : this.getAllSpecies()) { + for (final IAlleleSpecies species : this.allActiveSpecies) { if (this.isSpeciesDiscovered(species, world, player)) { speciesList.add(species); } @@ -311,7 +302,7 @@ public final Collection getDiscoveredSpecies(final World world, @Override public final Collection getDiscoveredSpecies(final IBreedingTracker tracker) { final List speciesList = new ArrayList<>(); - for (final IAlleleSpecies species : this.getAllSpecies()) { + for (final IAlleleSpecies species : this.allActiveSpecies) { if (this.isSpeciesDiscovered(species, tracker)) { speciesList.add(species); } @@ -321,7 +312,7 @@ public final Collection getDiscoveredSpecies(final IBreedingTrac public final List getDiscoveredMutations(final World world, final GameProfile player) { final List speciesList = new ArrayList<>(); - for (final IMutation species : this.getAllMutations()) { + for (final IMutation species : this.allMutations) { if (this.isMutationDiscovered(species, world, player)) { speciesList.add(species); } @@ -342,7 +333,7 @@ public TextureAtlasSprite getDiscoveredIcon() { } @Override - public abstract float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies); + public abstract float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies); @Override @SubscribeEvent @@ -365,17 +356,17 @@ public final void syncTracker(final IBreedingTracker tracker) { this.totalSecretCount = 0; this.discoveredSecretCount = 0; final Collection discoveredSpecies = this.getDiscoveredSpecies(tracker); - final Collection allSpecies = this.getAllSpecies(); + final Collection allSpecies = this.allActiveSpecies; for (final IAlleleSpecies species : allSpecies) { if (!this.isSecret(species)) { ++this.totalSpeciesCount; - if (!this.isSpeciesDiscovered(species, tracker)) { + if (!discoveredSpecies.contains(species)) { continue; } ++this.discoveredSpeciesCount; } else { ++this.totalSecretCount; - if (!this.isSpeciesDiscovered(species, tracker)) { + if (!discoveredSpecies.contains(species)) { continue; } ++this.discoveredSecretCount; @@ -385,7 +376,7 @@ public final void syncTracker(final IBreedingTracker tracker) { this.totalBranchCount = 0; this.discoveredBranchCount = 0; final Collection discoveredBranches = this.getDiscoveredBranches(tracker); - final Collection allBranches = this.getAllBranches(); + final Collection allBranches = this.allBranches; for (final IClassification branch : allBranches) { if (!this.isSecret(branch)) { ++this.totalBranchCount; @@ -403,8 +394,6 @@ public final void syncTracker(final IBreedingTracker tracker) { } this.discoveredSpeciesPercentage = this.discoveredSpeciesCount / this.totalSpeciesCount; this.discoveredBranchPercentage = this.discoveredBranchCount / this.totalBranchCount; - final String epithet = this.getEpitome(); - this.onSyncBreedingTracker(tracker); } @Override @@ -432,7 +421,7 @@ public final String getIdent() { @Override public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) { if (allele instanceof IAlleleBoolean) { - IAlleleBoolean alleleBoolean = (IAlleleBoolean) allele; + final IAlleleBoolean alleleBoolean = (IAlleleBoolean) allele; return alleleBoolean.getValue() ? I18N.localise("binniecore.allele.true") : I18N.localise("binniecore.allele.false"); } if (Objects.equals(allele.getAlleleName(), "for.gui.maximum")) { @@ -448,8 +437,9 @@ public String getName() { @Override public ItemStack getItemStackRepresentitive() { - final IIndividual first = this.getSpeciesRoot().getIndividualTemplates().get(0); - return this.getSpeciesRoot().getMemberStack(first, this.getDefaultType()); + final ISpeciesRoot root = this.getSpeciesRoot(); + final IIndividual first = root.getIndividualTemplates().get(0); + return root.getMemberStack(first, this.getDefaultType()); } @Override @@ -465,7 +455,8 @@ public IIndividual getConversion(final ItemStack stack) { @Override public final IIndividual getDefaultIndividual() { - return this.getSpeciesRoot().templateAsIndividual(this.getSpeciesRoot().getDefaultTemplate()); + final ISpeciesRoot root = this.getSpeciesRoot(); + return root.templateAsIndividual(root.getDefaultTemplate()); } @Override @@ -478,7 +469,7 @@ public final ISpeciesType getDefaultType() { @Override public ItemStack getConversionStack(final ItemStack stack) { - IIndividual conversion = this.getConversion(stack); + final IIndividual conversion = this.getConversion(stack); if (conversion == null) { return ItemStack.EMPTY; } @@ -496,7 +487,7 @@ public final Collection getActiveKaryotype() { @Override public ItemStack getDefaultMember(final String uid) { - IIndividual individual = this.getIndividual(uid); + final IIndividual individual = this.getIndividual(uid); if (individual == null) { return ItemStack.EMPTY; } @@ -506,11 +497,12 @@ public ItemStack getDefaultMember(final String uid) { @Override @Nullable public IIndividual getIndividual(String uid) { - IAllele[] template = this.getSpeciesRoot().getTemplate(uid); + final ISpeciesRoot root = this.getSpeciesRoot(); + final IAllele[] template = root.getTemplate(uid); if (template == null) { return null; } - return this.getSpeciesRoot().templateAsIndividual(template); + return root.templateAsIndividual(template); } @Override From fffb54d840a8765fe633e341c66b3e134ff681cf Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 16:17:03 +1000 Subject: [PATCH 23/99] Gene.java --- core/src/main/java/binnie/core/genetics/Gene.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/binnie/core/genetics/Gene.java b/core/src/main/java/binnie/core/genetics/Gene.java index 1ea2b8d41..198a02a02 100644 --- a/core/src/main/java/binnie/core/genetics/Gene.java +++ b/core/src/main/java/binnie/core/genetics/Gene.java @@ -26,8 +26,8 @@ public Gene(final IAllele allele, final IChromosomeType chromosome, final ISpeci public Gene(final NBTTagCompound nbt) { this.allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele")); - String rootKey = nbt.getString("root"); - ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); + final String rootKey = nbt.getString("root"); + final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); Preconditions.checkArgument(root != null, "Could not find root: %s", rootKey); this.root = root; final int chromoID = nbt.getByte("chromo"); @@ -56,8 +56,8 @@ public String toString() { @Override public void readFromNBT(final NBTTagCompound nbt) { this.allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele")); - String rootKey = nbt.getString("root"); - ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); + final String rootKey = nbt.getString("root"); + final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); Preconditions.checkArgument(root != null, "Could not find root: %s", rootKey); this.root = root; final int chromoID = nbt.getByte("chromo"); From a5dbd38223b03a6549a5c7598b405250f748fe9f Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 16:51:28 +1000 Subject: [PATCH 24/99] Code cleanup --- .../binnie/core/genetics/ManagerGenetics.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/binnie/core/genetics/ManagerGenetics.java b/core/src/main/java/binnie/core/genetics/ManagerGenetics.java index 5cb1aac08..ba274504d 100644 --- a/core/src/main/java/binnie/core/genetics/ManagerGenetics.java +++ b/core/src/main/java/binnie/core/genetics/ManagerGenetics.java @@ -64,19 +64,18 @@ public static boolean isAnalysed(final ItemStack stack) { return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack); } - public static ItemStack analyse(ItemStack stack, World world, GameProfile username) { + public static ItemStack analyse(ItemStack stack, final World world, final GameProfile username) { if (!stack.isEmpty()) { - ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy(); + final ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy(); if (!conv.isEmpty()) { conv.setCount(stack.getCount()); stack = conv; - } - ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack); + final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack); if (root != null) { final IIndividual ind = root.getMember(stack); ind.analyze(); - IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username); + final IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username); breedingTracker.registerBirth(ind); final NBTTagCompound nbttagcompound = new NBTTagCompound(); ind.writeToNBT(nbttagcompound); @@ -106,8 +105,8 @@ public IBreedingSystem getSystem(final String string) { } public IBreedingSystem getSystem(final ISpeciesRoot root) { - String rootUID = root.getUID(); - IBreedingSystem system = this.getSystem(rootUID); + final String rootUID = root.getUID(); + final IBreedingSystem system = this.getSystem(rootUID); Preconditions.checkState(system != null, "Could not find system for species root %s", rootUID); return system; } @@ -125,8 +124,8 @@ public Collection getActiveSystems() { } public IBreedingSystem getFirstActiveSystem() { - Collection activeSystems = getActiveSystems(); - IBreedingSystem first = Iterables.getFirst(activeSystems, null); + final Collection activeSystems = getActiveSystems(); + final IBreedingSystem first = Iterables.getFirst(activeSystems, null); if (first == null) { throw new IllegalStateException("There are no breeding systems"); } @@ -179,15 +178,16 @@ private void refreshData() { private void loadAlleles() { this.invalidChromosomeTypes.clear(); + final ComparatorAllele comparator = new ComparatorAllele(); for (IBreedingSystem system : BREEDING_SYSTEMS.values()) { - ISpeciesRoot root = system.getSpeciesRoot(); - Map> chromosomeMap = new LinkedHashMap<>(); - for (IChromosomeType chromosome : root.getKaryotype()) { - TreeSet alleles = new TreeSet<>(new ComparatorAllele()); + final ISpeciesRoot root = system.getSpeciesRoot(); + final Map> chromosomeMap = new LinkedHashMap<>(); + for (final IChromosomeType chromosome : root.getKaryotype()) { + final TreeSet alleles = new TreeSet<>(comparator); for (IIndividual individual : root.getIndividualTemplates()) { - IGenome genome = individual.getGenome(); - IAllele activeAllele = genome.getActiveAllele(chromosome); - IAllele inactiveAllele = genome.getInactiveAllele(chromosome); + final IGenome genome = individual.getGenome(); + final IAllele activeAllele = genome.getActiveAllele(chromosome); + final IAllele inactiveAllele = genome.getInactiveAllele(chromosome); if (chromosome.getAlleleClass().isInstance(activeAllele)) { alleles.add(activeAllele); } From 0ea7cbc19fb6dbc6f5745edc9d3303f1d2250b3f Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 16:59:55 +1000 Subject: [PATCH 25/99] Code cleanup --- .../java/binnie/core/genetics/BreedingSystem.java | 13 ++++++------- .../core/gui/controls/button/ControlButton.java | 6 ++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/binnie/core/genetics/BreedingSystem.java b/core/src/main/java/binnie/core/genetics/BreedingSystem.java index e1301a25d..9d11dfef0 100644 --- a/core/src/main/java/binnie/core/genetics/BreedingSystem.java +++ b/core/src/main/java/binnie/core/genetics/BreedingSystem.java @@ -52,11 +52,10 @@ public abstract class BreedingSystem implements IBreedingSystem, IItemStackRepre private int discoveredBranchCount; protected BinnieSprite iconUndiscovered; protected BinnieSprite iconDiscovered; - protected List allActiveSpecies; - protected String currentEpithet; - private List allBranches; - private List allSpecies; - private List allMutations; + protected final List allActiveSpecies; + private final List allBranches; + private final List allSpecies; + private final List allMutations; private final ListMultiMap resultantMutations; private final ListMultiMap furtherMutations; private final ListMultiMap allResultantMutations; @@ -135,8 +134,8 @@ public void calculateArrays() { @Override public void calculateAlleles(final ISpeciesRoot speciesRoot) { - this.allSpecies = new ArrayList<>(); - this.allActiveSpecies = new ArrayList<>(); + this.allSpecies.clear(); + this.allActiveSpecies.clear(); this.resultantMutations.clear(); this.furtherMutations.clear(); this.allResultantMutations.clear(); diff --git a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java index 80f147248..1f514d752 100644 --- a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java +++ b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java @@ -42,7 +42,7 @@ protected void onMouseClick(final EventMouse.Down event) { @Override public void onUpdateClient() { if (this.textWidget != null) { - String text = this.getText(); + final String text = this.getText(); if (text != null) { this.textWidget.setValue(text); } @@ -57,11 +57,13 @@ public String getText() { @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - Object texture = CraftGUITexture.BUTTON_DISABLED; + Object texture; if (this.isMouseOver()) { texture = CraftGUITexture.BUTTON_HIGHLIGHTED; } else if (this.isEnabled()) { texture = CraftGUITexture.BUTTON; + } else { + texture = CraftGUITexture.BUTTON_DISABLED; } CraftGUI.RENDER.texture(texture, this.getArea()); } From 1b5ab81f9369ab228c42a08413c444b5dfc8e48d Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 17:38:22 +1000 Subject: [PATCH 26/99] Code cleanup --- core/src/main/java/binnie/core/config/ConfigProperty.java | 4 +++- core/src/main/java/binnie/core/genetics/Tolerance.java | 7 ++++++- core/src/main/java/binnie/core/gui/Widget.java | 6 ++---- .../java/binnie/core/gui/controls/ControlCheckbox.java | 8 +++++--- .../core/gui/controls/ControlIndividualDisplay.java | 6 +++--- .../java/binnie/core/gui/controls/ControlTextEdit.java | 5 +++-- .../binnie/core/gui/controls/ControlToleranceBar.java | 3 ++- .../java/binnie/core/gui/controls/page/ControlPage.java | 2 +- .../binnie/core/gui/controls/scroll/ControlScrollBar.java | 4 +++- .../java/binnie/core/gui/controls/tab/ControlTab.java | 4 +++- 10 files changed, 31 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/binnie/core/config/ConfigProperty.java b/core/src/main/java/binnie/core/config/ConfigProperty.java index 918e5c24a..25085f17f 100644 --- a/core/src/main/java/binnie/core/config/ConfigProperty.java +++ b/core/src/main/java/binnie/core/config/ConfigProperty.java @@ -5,12 +5,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import binnie.core.util.EmptyHelper; + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface ConfigProperty { String key(); - String category() default ""; + String category() default EmptyHelper.EMPTY_STRING; String[] comment() default {}; diff --git a/core/src/main/java/binnie/core/genetics/Tolerance.java b/core/src/main/java/binnie/core/genetics/Tolerance.java index 2aa771f55..842305b1a 100644 --- a/core/src/main/java/binnie/core/genetics/Tolerance.java +++ b/core/src/main/java/binnie/core/genetics/Tolerance.java @@ -1,12 +1,15 @@ package binnie.core.genetics; import java.util.Locale; +import java.util.regex.Pattern; import org.apache.commons.lang3.text.WordUtils; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; +import binnie.core.util.EmptyHelper; + public enum Tolerance { NONE(0, 0), BOTH_1(-1, 1), BOTH_2(-2, 2), BOTH_3(-3, 3), BOTH_4(-4, 4), BOTH_5(-5, 5), @@ -29,9 +32,11 @@ public static > boolean canTolerate(final T base, final T test return get(tol).canTolerate(base, test); } + private static final Pattern PATTERN = Pattern.compile("_", Pattern.LITERAL); + @Override public String toString() { - return super.toString().toLowerCase(Locale.ENGLISH).replace("_", ""); + return PATTERN.matcher(name().toLowerCase(Locale.ENGLISH)).replaceAll(EmptyHelper.EMPTY_STRING); } public String getUID() { diff --git a/core/src/main/java/binnie/core/gui/Widget.java b/core/src/main/java/binnie/core/gui/Widget.java index 813c5ec50..dcf3ce662 100644 --- a/core/src/main/java/binnie/core/gui/Widget.java +++ b/core/src/main/java/binnie/core/gui/Widget.java @@ -357,11 +357,9 @@ public final void render(int guiWidth, int guiHeight) { public void onRender(final RenderStage stage, int guiWidth, int guiHeight) { if (stage == RenderStage.PRE_CHILDREN) { this.onRenderBackground(guiWidth, guiHeight); - } - if (stage == RenderStage.POST_CHILDREN) { + } else if (stage == RenderStage.POST_CHILDREN) { this.onRenderForeground(guiWidth, guiHeight); - } - if (stage == RenderStage.POST_SIBLINGS) { + } else if (stage == RenderStage.POST_SIBLINGS) { this.onRenderOverlay(); } } diff --git a/core/src/main/java/binnie/core/gui/controls/ControlCheckbox.java b/core/src/main/java/binnie/core/gui/controls/ControlCheckbox.java index 427ec12f9..7ef6aad0f 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlCheckbox.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlCheckbox.java @@ -46,15 +46,17 @@ public void setValue(final Boolean value) { } public void toggleValue() { - this.setValue(!this.getValue()); + this.setValue(!this.value); } @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - Object texture = this.getValue() ? CraftGUITexture.CHECKBOX_CHECKED : CraftGUITexture.CHECKBOX; + Object texture; if (this.isMouseOver()) { - texture = (this.getValue() ? CraftGUITexture.CHECKBOX_CHECKED_HIGHLIGHTED : CraftGUITexture.CHECKBOX_HIGHLIGHTED); + texture = (this.value ? CraftGUITexture.CHECKBOX_CHECKED_HIGHLIGHTED : CraftGUITexture.CHECKBOX_HIGHLIGHTED); + } else { + texture = this.value ? CraftGUITexture.CHECKBOX_CHECKED : CraftGUITexture.CHECKBOX; } CraftGUI.RENDER.texture(texture, Point.ZERO); } diff --git a/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java b/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java index 19a4f8443..b405e9b5b 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java @@ -20,18 +20,18 @@ public ControlIndividualDisplay(IWidget parent, int x, int y, IIndividual ind) { public ControlIndividualDisplay(IWidget parent, int x, int y, int size, IIndividual ind) { super(parent, x, y, size); - IBreedingSystem system = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot()); + final IBreedingSystem system = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot()); setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType())); setTooltip(); } @Override public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) { - ItemStack stack = getItemStack(); + final ItemStack stack = getItemStack(); if (stack.isEmpty()) { return; } - IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack); + final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack); if (ind == null) { return; } diff --git a/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java b/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java index 5f1fe938f..2054ba0b6 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java @@ -15,6 +15,7 @@ import binnie.core.gui.events.EventTextEdit; import binnie.core.gui.events.EventWidget; import binnie.core.gui.resource.textures.CraftGUITexture; +import binnie.core.util.EmptyHelper; @SideOnly(Side.CLIENT) public class ControlTextEdit extends Control implements IControlValue { @@ -23,7 +24,7 @@ public class ControlTextEdit extends Control implements IControlValue { public ControlTextEdit(final IWidget parent, final int x, final int y, final int width, final int height) { super(parent, x, y, width, height); - this.cachedValue = ""; + this.cachedValue = EmptyHelper.EMPTY_STRING; this.field = new GuiTextField(0, this.getWindow().getGui().getFontRenderer(), 0, 0, 10, 10); this.addAttribute(Attribute.CAN_FOCUS); this.addAttribute(Attribute.MOUSE_OVER); @@ -50,7 +51,7 @@ public ControlTextEdit(final IWidget parent, final int x, final int y, final int @Override public String getValue() { - return (this.field.getText() == null) ? "" : this.field.getText(); + return (this.field.getText() == null) ? EmptyHelper.EMPTY_STRING : this.field.getText(); } @Override diff --git a/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java b/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java index b1a547c5b..c6f2b7d4c 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java @@ -19,6 +19,7 @@ import binnie.core.gui.geometry.Area; import binnie.core.gui.geometry.Border; import binnie.core.gui.renderer.RenderUtil; +import binnie.core.util.EmptyHelper; public abstract class ControlToleranceBar> extends Control implements ITooltip { private final EnumSet tolerated; @@ -42,7 +43,7 @@ public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) { int type = getRelativeMousePosition().xPos() / (getSize().xPos() / types); for (T tol : fullSet) { if (tol.ordinal() - ((enumClass == EnumTemperature.class) ? 1 : 0) == type) { - tooltip.add((tolerated.contains(tol) ? "" : TextFormatting.DARK_GRAY) + getName(tol)); + tooltip.add((tolerated.contains(tol) ? EmptyHelper.EMPTY_STRING : TextFormatting.DARK_GRAY) + getName(tol)); } } } diff --git a/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java b/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java index ae9f757e0..fcb0f1ab8 100644 --- a/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java +++ b/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java @@ -15,7 +15,7 @@ public ControlPage(final IWidget parent, final int x, final int y, final int w, super(parent, x, y, w, h); this.value = value; if (parent instanceof IControlValue) { - IControlValue controlValue = (IControlValue) parent; + final IControlValue controlValue = (IControlValue) parent; if (controlValue.getValue() == null) { controlValue.setValue(value); } diff --git a/core/src/main/java/binnie/core/gui/controls/scroll/ControlScrollBar.java b/core/src/main/java/binnie/core/gui/controls/scroll/ControlScrollBar.java index b23fb76e6..5105bc081 100644 --- a/core/src/main/java/binnie/core/gui/controls/scroll/ControlScrollBar.java +++ b/core/src/main/java/binnie/core/gui/controls/scroll/ControlScrollBar.java @@ -63,11 +63,13 @@ protected Area getRenderArea() { @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { final Area renderArea = this.getRenderArea(); - Object texture = CraftGUITexture.SCROLL_DISABLED; + Object texture; if (this.isMouseOver()) { texture = CraftGUITexture.SCROLL_HIGHLIGHTED; } else if (this.isEnabled()) { texture = CraftGUITexture.SCROLL; + } else { + texture = CraftGUITexture.SCROLL_DISABLED; } CraftGUI.RENDER.texture(texture, renderArea); } diff --git a/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java b/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java index 8dacdd97f..577bc040b 100644 --- a/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java +++ b/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java @@ -77,11 +77,13 @@ public String getName() { @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - Object texture = CraftGUITexture.TAB_DISABLED; + Object texture; if (this.isMouseOver()) { texture = CraftGUITexture.TAB_HIGHLIGHTED; } else if (this.isCurrentSelection()) { texture = CraftGUITexture.TAB; + } else { + texture = CraftGUITexture.TAB_DISABLED; } final ITexture lTexture = CraftGUI.RENDER.getTexture(texture); final Alignment alignment = this.getTabPosition(); From ffcf1379d88b3aabe2deead064561bf887d7bc9e Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 18:21:05 +1000 Subject: [PATCH 27/99] Refactor to use EmptyHelper.EMPTY_STRING --- .../core/gui/database/PageBranchOverview.java | 11 ++++++----- .../gui/database/PageSpeciesClassification.java | 5 +++-- .../core/gui/database/PageSpeciesOverview.java | 17 +++++++++-------- .../gui/database/WindowAbstractDatabase.java | 3 ++- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java b/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java index 590db127e..db1ce1cba 100644 --- a/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java +++ b/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java @@ -16,6 +16,7 @@ import binnie.core.gui.controls.ControlTextCentered; import binnie.core.gui.renderer.RenderUtil; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; @SideOnly(Side.CLIENT) public class PageBranchOverview extends PageBranch { @@ -27,9 +28,9 @@ public class PageBranchOverview extends PageBranch { public PageBranchOverview(final IWidget parent, final DatabaseTab tab) { super(parent, tab); this.branchDescription = new ArrayList<>(); - this.branchName = new ControlTextCentered(this, 8, ""); - this.branchScientific = new ControlTextCentered(this, 32, ""); - this.branchAuthority = new ControlTextCentered(this, 44, ""); + this.branchName = new ControlTextCentered(this, 8, EmptyHelper.EMPTY_STRING); + this.branchScientific = new ControlTextCentered(this, 32, EmptyHelper.EMPTY_STRING); + this.branchAuthority = new ControlTextCentered(this, 44, EmptyHelper.EMPTY_STRING); } @Override @@ -42,7 +43,7 @@ public void onValueChanged(final IClassification branch) { } this.branchDescription.clear(); String desc = branch.getDescription(); - if (desc == null || Objects.equals(desc, "") || desc.contains("for.")) { + if (desc == null || Objects.equals(desc, EmptyHelper.EMPTY_STRING) || desc.contains("for.")) { desc = I18N.localise(DatabaseConstants.BRANCH_KEY + ".noDesc"); } StringBuilder line = new StringBuilder(); @@ -50,7 +51,7 @@ public void onValueChanged(final IClassification branch) { for (final String str : desc.split(" ")) { if (RenderUtil.getTextWidth(line + " " + str) > 134) { descLines.add(TextFormatting.ITALIC + line.toString() + TextFormatting.RESET); - line = new StringBuilder(); + line.setLength(0); } line.append(' ').append(str); } diff --git a/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java b/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java index 1df916f43..4dd12fffa 100644 --- a/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java +++ b/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java @@ -9,6 +9,7 @@ import binnie.core.api.gui.IWidget; import binnie.core.gui.controls.ControlText; import binnie.core.gui.controls.ControlTextCentered; +import binnie.core.util.EmptyHelper; public class PageSpeciesClassification extends PageSpecies { private final Map levels; @@ -19,12 +20,12 @@ public PageSpeciesClassification(final IWidget parent, final DatabaseTab tab) { this.levels = new LinkedHashMap<>(); int y = 16; for (final IClassification.EnumClassLevel level : IClassification.EnumClassLevel.values()) { - final ControlText text = new ControlTextCentered(this, y, ""); + final ControlText text = new ControlTextCentered(this, y, EmptyHelper.EMPTY_STRING); text.setColor(level.getColour()); this.levels.put(level, text); y += 12; } - (this.genus = new ControlTextCentered(this, y, "")).setColor(16759415); + (this.genus = new ControlTextCentered(this, y, EmptyHelper.EMPTY_STRING)).setColor(16759415); } @Override diff --git a/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java b/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java index 8445e802f..ac047dcf1 100644 --- a/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java +++ b/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java @@ -17,6 +17,7 @@ import binnie.core.gui.geometry.Point; import binnie.core.gui.geometry.TextJustification; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; @SideOnly(Side.CLIENT) public class PageSpeciesOverview extends PageSpecies { @@ -33,12 +34,12 @@ public PageSpeciesOverview(final IWidget parent, final DatabaseTab tab) { super(parent, tab); this.controlInd1 = new ControlIndividualDisplay(this, 5, 5); this.controlInd2 = new ControlIndividualDisplay(this, 123, 5); - this.controlName = new ControlTextCentered(this, 8, ""); - this.controlScientific = new ControlTextCentered(this, 32, ""); - this.controlAuthority = new ControlTextCentered(this, 44, ""); - this.controlComplexity = new ControlTextCentered(this, 68, ""); - this.controlDescription = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), "", TextJustification.MIDDLE_CENTER); - this.controlSignature = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), "", TextJustification.BOTTOM_RIGHT); + this.controlName = new ControlTextCentered(this, 8, EmptyHelper.EMPTY_STRING); + this.controlScientific = new ControlTextCentered(this, 32, EmptyHelper.EMPTY_STRING); + this.controlAuthority = new ControlTextCentered(this, 44, EmptyHelper.EMPTY_STRING); + this.controlComplexity = new ControlTextCentered(this, 68, EmptyHelper.EMPTY_STRING); + this.controlDescription = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), EmptyHelper.EMPTY_STRING, TextJustification.MIDDLE_CENTER); + this.controlSignature = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), EmptyHelper.EMPTY_STRING, TextJustification.BOTTOM_RIGHT); } @Override @@ -52,8 +53,8 @@ public void onValueChanged(final IAlleleSpecies species) { this.controlComplexity.setValue(I18N.localise(DatabaseConstants.KEY + ".overview.complexity") + ": " + species.getComplexity()); final String desc = species.getDescription(); StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString()); - String descSig = ""; - if (desc == null || Objects.equals(desc, "") || desc.contains("for.description") || desc.contains(".desc")) { + String descSig = EmptyHelper.EMPTY_STRING; + if (desc == null || Objects.equals(desc, EmptyHelper.EMPTY_STRING) || desc.contains("for.description") || desc.contains(".desc")) { descBody.append(I18N.localise(DatabaseConstants.KEY + ".no.description")); } else { final String[] descStrings = desc.split("\\|"); diff --git a/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java b/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java index 4fed4fc84..d9cd83a86 100644 --- a/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java +++ b/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java @@ -37,6 +37,7 @@ import binnie.core.gui.minecraft.control.ControlHelp; import binnie.core.gui.window.Panel; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; public abstract class WindowAbstractDatabase extends Window { private final boolean master; @@ -133,7 +134,7 @@ public void initialiseClient() { this.addEventHandler(EventTextEdit.class, EventHandlerOrigin.DIRECT_CHILD, this, event -> { for (final ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) { widgets.getListBox().setValidator(object -> { - if (Objects.equals(event.getValue(), "")) { + if (Objects.equals(event.getValue(), EmptyHelper.EMPTY_STRING)) { return true; } ControlTextOption controlTextOption = (ControlTextOption) object; From 71a9cb6658d25fa1012b3e71d46fbad6c2a7a35d Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 18:46:20 +1000 Subject: [PATCH 28/99] Clean up fieldkit --- .../gui/fieldkit/ControlChromoPicker.java | 4 +-- .../core/gui/fieldkit/ControlChromosome.java | 11 ++++---- .../core/gui/fieldkit/WindowFieldKit.java | 26 +++++++++---------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java index c329cd01b..8392e6fdf 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java @@ -44,8 +44,8 @@ public ControlChromoPicker(ControlChromosome parent, int x, int y, IChromosomeTy @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { super.onRenderBackground(guiWidth, guiHeight); - boolean selected = isMouseOver(); - Texture text = selected ? this.selected : texture; + final boolean selected = isMouseOver(); + final Texture text = selected ? this.selected : texture; CraftGUI.RENDER.texture(text, Point.ZERO); } diff --git a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java index 0f39807aa..eee8a0cbb 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java @@ -39,12 +39,11 @@ public void setSystem(@Nullable IBreedingSystem breedingSystem) { deleteAllChildren(); if (breedingSystem != null) { - IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); - fieldKitPlugin.getChromosomePickerPositions(); + final IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); for (Map.Entry entry : fieldKitPlugin.getChromosomePickerPositions().entrySet()) { - IChromosomeType chromosomeType = entry.getKey(); - IPoint position = entry.getValue(); + final IChromosomeType chromosomeType = entry.getKey(); + final IPoint position = entry.getValue(); new ControlChromoPicker(this, position.xPos(), position.yPos(), chromosomeType); } } @@ -68,7 +67,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { return; } super.onRenderBackground(guiWidth, guiHeight); - ITexture texture = getTypeTexture(); + final ITexture texture = getTypeTexture(); CraftGUI.RENDER.texture(texture, Point.ZERO); } @@ -77,7 +76,7 @@ private ITexture getTypeTexture() { if (breedingSystem == null) { return null; } - IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); + final IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); return fieldKitPlugin.getTypeTexture(); } } diff --git a/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java b/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java index ab6df4a2d..237b666b5 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java @@ -45,6 +45,7 @@ import binnie.core.gui.resource.textures.StandardTexture; import binnie.core.texture.BinnieCoreTexture; import binnie.core.util.I18N; +import binnie.core.util.EmptyHelper; public class WindowFieldKit extends Window { public static final int INDIVIDUAL_SLOT = 0; @@ -85,7 +86,7 @@ protected String getBackgroundTextureName() { } private void setupValidators() { - WindowInventory inventory = this.getWindowInventory(); + final WindowInventory inventory = this.getWindowInventory(); inventory.setValidator(INDIVIDUAL_SLOT, new SlotValidatorIndividual(null)); inventory.setValidator(PAPER_SLOT, new SlotValidatorPaper(null)); inventory.disableAutoDispense(PAPER_SLOT); @@ -96,7 +97,7 @@ private void setupValidators() { public void initialiseClient() { this.setTitle(I18N.localise("binniecore.gui.fieldkit.title")); CraftGUI.RENDER.setStyleSheet(StyleSheetManager.getSheet(StyleSheetManager.PUNNETT_SHEET)); - WindowInventory inventory = this.getWindowInventory(); + final WindowInventory inventory = this.getWindowInventory(); inventory.createSlot(INDIVIDUAL_SLOT); inventory.createSlot(PAPER_SLOT); this.setupValidators(); @@ -106,7 +107,7 @@ public void initialiseClient() { new ControlSlot.Builder(this, handGlass.xPos() + 54, handGlass.yPos() + 26).assign(InventoryType.WINDOW, 0); new ControlSlot.Builder(this, 208, 8).assign(InventoryType.WINDOW, 1); (this.text = new ControlText(this, new Point(232, 13), I18N.localise("binniecore.gui.fieldkit.paper"))).setColor(2236962); - (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), "", TextJustification.MIDDLE_CENTER)).setColor(2236962); + (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), EmptyHelper.EMPTY_STRING, TextJustification.MIDDLE_CENTER)).setColor(2236962); this.chromo = new ControlChromosome(this, 150, 24); this.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, this.chromo, event -> { final IChromosomeType type = (IChromosomeType) event.getValue(); @@ -114,7 +115,7 @@ public void initialiseClient() { final String t = WindowFieldKit.this.info.get(type); WindowFieldKit.this.text.setValue(t); } else { - WindowFieldKit.this.text.setValue(""); + WindowFieldKit.this.text.setValue(EmptyHelper.EMPTY_STRING); } }); } @@ -122,7 +123,7 @@ public void initialiseClient() { @Override public void initialiseServer() { //create slots - WindowInventory inventory = this.getWindowInventory(); + final WindowInventory inventory = this.getWindowInventory(); final ItemStack kit = this.getPlayer().getHeldItemMainhand(); final int sheets = 64 - kit.getItemDamage(); inventory.createSlot(INDIVIDUAL_SLOT); @@ -171,7 +172,7 @@ private void refreshSpecies() { if (root == null) { return; } - IBreedingSystem system = Binnie.GENETICS.getSystem(root); + final IBreedingSystem system = Binnie.GENETICS.getSystem(root); this.chromo.setSystem(system); final Random rand = new Random(); this.info.clear(); @@ -196,23 +197,22 @@ private void refreshSpecies() { @Override public void onWindowInventoryChanged() { super.onWindowInventoryChanged(); - WindowInventory inventory = getWindowInventory(); + final WindowInventory inventory = getWindowInventory(); if (this.isServer()) { final ItemStack kit = this.getPlayer().getHeldItemMainhand(); if (kit.isEmpty() || !kit.getItem().equals(BinnieCore.getFieldKit())) { return; } - ItemStack paper = inventory.getStackInSlot(PAPER_SLOT); + final ItemStack paper = inventory.getStackInSlot(PAPER_SLOT); final int sheets = 64 - kit.getItemDamage(); final int size = (paper.isEmpty()) ? 0 : paper.getCount(); if (sheets != size) { kit.setItemDamage(64 - size); } ((EntityPlayerMP) this.getPlayer()).updateHeldItem(); - } - if (this.isClient()) { + } else if (this.isClient()) { final ItemStack item = inventory.getStackInSlot(INDIVIDUAL_SLOT); - this.text.setValue(""); + this.text.setValue(EmptyHelper.EMPTY_STRING); if (!item.isEmpty() && !ManagerGenetics.isAnalysed(item)) { if (inventory.getStackInSlot(PAPER_SLOT).isEmpty()) { this.text.setValue(I18N.localise("binniecore.gui.fieldkit.paper.no")); @@ -257,8 +257,8 @@ public String showInfoButton() { public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) { super.receiveGuiNBTOnServer(player, name, nbt); if (name.equals("analyse")) { - WindowInventory inventory = getWindowInventory(); - ItemStack individualStack = inventory.getStackInSlot(INDIVIDUAL_SLOT); + final WindowInventory inventory = getWindowInventory(); + final ItemStack individualStack = inventory.getStackInSlot(INDIVIDUAL_SLOT); inventory.setInventorySlotContents(INDIVIDUAL_SLOT, ManagerGenetics.analyse(individualStack, this.getWorld(), this.getUsername())); inventory.decrStackSize(PAPER_SLOT, 1); } From a50ac55a4ba3fb9384440f7f1472d728487aeece Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 18:55:37 +1000 Subject: [PATCH 29/99] Clean up WindowGenesis.java --- .../core/gui/genesis/WindowGenesis.java | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java index 422fbfe66..179a1b1c0 100644 --- a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java +++ b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java @@ -93,29 +93,29 @@ public void initialiseClient() { refreshTemplate(null); }); this.geneList.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, this.geneList, event -> { - Object value = event.getValue(); + final Object value = event.getValue(); if (!(value instanceof Gene)) { return; } - Gene gene = (Gene) value; - Map> map = Binnie.GENETICS.getChromosomeMap(root); - List options = new ArrayList<>(); - IChromosomeType chromosomeType = gene.getChromosome(); - List alleles = map.get(chromosomeType); - for (IAllele allele : alleles) { + final Gene gene = (Gene) value; + final Map> map = Binnie.GENETICS.getChromosomeMap(root); + final IChromosomeType chromosomeType = gene.getChromosome(); + final List alleles = map.get(chromosomeType); + final List options = new ArrayList<>(alleles.size()); + for (final IAllele allele : alleles) { options.add(new Gene(allele, chromosomeType, root)); } geneOptions.setOptions(options); }); this.geneOptions.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, this.geneOptions, event -> { - Object value = event.getValue(); + final Object value = event.getValue(); if (!(value instanceof Gene)) { return; } - Gene gene = (Gene) value; - IChromosomeType chromosomeType = gene.getChromosome(); - ISpeciesRoot speciesRoot = gene.getSpeciesRoot(); - IAllele allele = gene.getAllele(); + final Gene gene = (Gene) value; + final IChromosomeType chromosomeType = gene.getChromosome(); + final ISpeciesRoot speciesRoot = gene.getSpeciesRoot(); + final IAllele allele = gene.getAllele(); if (chromosomeType == speciesRoot.getSpeciesChromosomeType()) { template = speciesRoot.getTemplate(allele.getUID()); }else { @@ -126,14 +126,12 @@ public void initialiseClient() { this.panelPickup = new Panel(this, 16, 140, 60, 42, MinecraftGUI.PanelType.BLACK); this.refreshTemplate(null); } - - private void refreshTemplate(@Nullable IChromosomeType selection) { - List genes = new ArrayList<>(); - IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(EmptyHelper.CHROMOSOME_TYPES_EMPTY); + final IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(EmptyHelper.CHROMOSOME_TYPES_EMPTY); + final List genes = new ArrayList<>(chromosomeTypes.length); for (IChromosomeType type : chromosomeTypes) { - IAllele allele = this.template[type.ordinal()]; + final IAllele allele = this.template[type.ordinal()]; if (allele == null) { throw new NullPointerException("Allele missing for Chromosome " + type.getName()); } @@ -151,12 +149,12 @@ private void refreshTemplate(@Nullable IChromosomeType selection) { private void refreshPickup() { this.panelPickup.deleteAllChildren(); int i = 0; - IBreedingSystem system = Binnie.GENETICS.getSystem(this.root); - for (ISpeciesType type : system.getActiveTypes()) { - IIndividual ind = this.root.templateAsIndividual(this.template); + final IBreedingSystem system = Binnie.GENETICS.getSystem(this.root); + for (final ISpeciesType type : system.getActiveTypes()) { + final IIndividual ind = this.root.templateAsIndividual(this.template); ind.analyze(); - ItemStack stack = this.root.getMemberStack(ind, type); - ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18); + final ItemStack stack = this.root.getMemberStack(ind, type); + final ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18); display.setItemStack(stack); display.setTooltip(); display.addEventHandler(EventMouse.Down.class, EventHandlerOrigin.SELF, display, event -> { @@ -172,12 +170,12 @@ private void refreshPickup() { public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) { super.receiveGuiNBTOnServer(player, name, nbt); if (name.equals(ACTION_GENESIS)) { - ItemStack stack = new ItemStack(nbt); - InventoryPlayer inventoryPlayer = player.inventory; - ItemStack playerStack = inventoryPlayer.getItemStack(); + final ItemStack stack = new ItemStack(nbt); if (stack.isEmpty()) { return; } + final InventoryPlayer inventoryPlayer = player.inventory; + final ItemStack playerStack = inventoryPlayer.getItemStack(); if (playerStack.isEmpty()) { inventoryPlayer.setItemStack(stack); } else if (playerStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(playerStack, stack)) { From 2700726a4ea01e5310b6628ddf276ee3696882cd Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 19:19:55 +1000 Subject: [PATCH 30/99] Clean up ControlEnergyBar.java --- .../minecraft/control/ControlEnergyBar.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java index 25758fe20..a11870acf 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java @@ -1,6 +1,7 @@ package binnie.core.gui.minecraft.control; import java.text.NumberFormat; +import java.util.regex.Pattern; import binnie.core.ModId; import binnie.core.api.gui.Alignment; @@ -56,28 +57,31 @@ private float getMaxEnergy() { @SideOnly(Side.CLIENT) public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.add(I18N.localise(ModId.CORE, "gui.energy.bar")); - NumberFormat numberFormat = I18N.getNumberFormat(); - String storedEnergy = numberFormat.format(this.getStoredEnergy()); - String maxEnergy = numberFormat.format(this.getMaxEnergy()); - String energyString = TextFormatting.GRAY + storedEnergy + '/' + maxEnergy + " RF"; + final NumberFormat numberFormat = I18N.getNumberFormat(); + final String storedEnergy = numberFormat.format(this.getStoredEnergy()); + final String maxEnergy = numberFormat.format(this.getMaxEnergy()); + final String energyString = TextFormatting.GRAY + storedEnergy + '/' + maxEnergy + " RF"; tooltip.add(energyString); } + private static final Pattern PATTERN_MAX = Pattern.compile("$MAX$", Pattern.LITERAL); + private static final Pattern PATTERN_PERCENT = Pattern.compile("$PERCENT$", Pattern.LITERAL); + @Override @SideOnly(Side.CLIENT) public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.add(I18N.localise(ModId.CORE, "gui.energy.bar")); if (tooltipFlag.isAdvanced()) { - String currentFormat = I18N.localise(ModId.CORE, "gui.energy.amount.current"); - NumberFormat numberFormat = I18N.getNumberFormat(); - String currentString = currentFormat.replace("$MAX$", numberFormat.format(this.getStoredEnergy())) - .replace("$PERCENT$", I18N.getPercentFormat().format(this.getPercentage() / 100.0)); + final String currentFormat = I18N.localise(ModId.CORE, "gui.energy.amount.current"); + final NumberFormat numberFormat = I18N.getNumberFormat(); + String currentString = PATTERN_MAX.matcher(currentFormat).replaceAll(numberFormat.format(this.getStoredEnergy())); + currentString = PATTERN_PERCENT.matcher(currentString).replaceAll(I18N.getPercentFormat().format(this.getPercentage() / 100.0)); tooltip.add(TextFormatting.GRAY + currentString); - String maxEnergy = numberFormat.format(this.getMaxEnergy()); + final String maxEnergy = numberFormat.format(this.getMaxEnergy()); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.energy.capacity", maxEnergy)); final IProcess process = Machine.getInterface(IProcess.class, Window.get(this).getInventory()); if (process != null) { - String energyPerTick = numberFormat.format((int) process.getEnergyPerTick()); + final String energyPerTick = numberFormat.format((int) process.getEnergyPerTick()); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.energy.cost.per.tick", energyPerTick)); } } @@ -94,7 +98,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { switch (this.direction) { case TOP: case BOTTOM: { - IPoint fullSize = area.size(); + final IPoint fullSize = area.size(); final int height = Math.round(fullSize.yPos() * percentage); area.setSize(new Point(fullSize.xPos(), height)); area.setYPos(fullSize.yPos() - height); From 1a4cd0557f204c2231dbabf6c16704e91a1f24a2 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 19:21:33 +1000 Subject: [PATCH 31/99] Clean up ControlErrorState.java --- .../core/gui/minecraft/control/ControlErrorState.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java index a4b2c04b0..fda646456 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java @@ -36,11 +36,13 @@ public ControlErrorState(final IWidget parent, final int x, final int y) { @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - Object texture = CraftGUITexture.STATE_WARNING; + Object texture; if (this.errorState == null) { texture = CraftGUITexture.STATE_NONE; } else if (this.type == 0) { texture = CraftGUITexture.STATE_ERROR; + } else { + texture = CraftGUITexture.STATE_WARNING; } CraftGUI.RENDER.texture(texture, Point.ZERO); super.onRenderBackground(guiWidth, guiHeight); @@ -65,8 +67,8 @@ public final void onUpdateClient() { } ControlEnergyBar.isError = this.errorState.isPowerError(); if (this.errorState.isItemError()) { - Collection slots = this.errorState.getCustomSlots(Window.get(this).getContainer()); - for (CustomSlot slot : slots) { + final Collection slots = this.errorState.getCustomSlots(Window.get(this).getContainer()); + for (final CustomSlot slot : slots) { if (this.type == 0) { ControlSlot.highlighting.get(EnumHighlighting.ERROR).add(slot.slotNumber); } else { From 5e134aa5b6c952dca9361bd61ddb5ed287e0ac6f Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:07:26 +1000 Subject: [PATCH 32/99] Add final to vars --- .../minecraft/control/ControlItemDisplay.java | 2 +- .../minecraft/control/ControlLiquidTank.java | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java index aad65026b..a2a718c14 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java @@ -97,7 +97,7 @@ public void setItemStack(ItemStack itemStack) { @SideOnly(Side.CLIENT) public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (this.hasTooltip && !this.itemStack.isEmpty()) { - List itemStackTooltip = this.itemStack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); + final List itemStackTooltip = this.itemStack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); tooltip.add(itemStackTooltip); tooltip.setItemStack(this.itemStack); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java index 5c66ab3d5..4fa065592 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java @@ -86,7 +86,7 @@ public int getTankCapacity() { @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(this.horizontal ? CraftGUITexture.HORIZONTAL_LIQUID_TANK : CraftGUITexture.LIQUID_TANK, Point.ZERO); - GuiCraftGUI gui = Window.get(this).getGui(); + final GuiCraftGUI gui = Window.get(this).getGui(); if (this.isMouseOver() && gui.isHelpMode()) { final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.HELP); RenderUtil.drawGradientRect(this.getArea().inset(1), c, c); @@ -142,7 +142,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { @SideOnly(Side.CLIENT) public void onRenderForeground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(this.horizontal ? CraftGUITexture.HORIZONTAL_LIQUID_TANK_OVERLAY : CraftGUITexture.LIQUID_TANK_OVERLAY, Point.ZERO); - GuiCraftGUI gui = Window.get(this).getGui(); + final GuiCraftGUI gui = Window.get(this).getGui(); if (this.isMouseOver() && gui.isHelpMode()) { final IArea area = this.getArea(); RenderUtil.setColour(MinecraftTooltip.getOutline(Tooltip.Type.HELP)); @@ -161,14 +161,14 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (this.getTankSlot() != null) { final TankSlot slot = this.getTankSlot(); tooltip.add(slot.getName()); - NumberFormat numberFormat = I18N.getNumberFormat(); + final NumberFormat numberFormat = I18N.getNumberFormat(); tooltip.add(I18N.localise(ModId.CORE, "gui.tank.capacity", numberFormat.format(this.getTankCapacity()))); if (tooltipFlag.isAdvanced()) { - Collection inputSides = slot.getInputSides(); + final Collection inputSides = slot.getInputSides(); if (inputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides))); } - Collection outputSides = slot.getOutputSides(); + final Collection outputSides = slot.getOutputSides(); if (outputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides))); } @@ -183,13 +183,13 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { @SideOnly(Side.CLIENT) public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (this.isTankValid()) { - NumberFormat numberFormat = I18N.getNumberFormat(); - NumberFormat percentFormat = I18N.getPercentFormat(); + final NumberFormat numberFormat = I18N.getNumberFormat(); + final NumberFormat percentFormat = I18N.getPercentFormat(); final float percentage = this.getTank().getAmount() / this.getTankCapacity(); tooltip.add(this.getTank().getName()); - String percentFull = percentFormat.format(percentage); + final String percentFull = percentFormat.format(percentage); tooltip.add(I18N.localise(ModId.CORE, "gui.tank.percent.full", percentFull)); - String tankAmount = numberFormat.format((int) this.getTank().getAmount()); + final String tankAmount = numberFormat.format((int) this.getTank().getAmount()); tooltip.add(I18N.localise(ModId.CORE, "gui.tank.amount", tankAmount)); return; } From c72e4c1d9aee6b3a2bb768587dda167c2d529c0f Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:12:10 +1000 Subject: [PATCH 33/99] Small refactoring in ControlPlayerInventory.java --- .../control/ControlPlayerInventory.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java index 17b129694..be004a987 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java @@ -15,20 +15,24 @@ public class ControlPlayerInventory extends Control { public ControlPlayerInventory(final IWidget parent, final boolean wide) { super(parent, parent.getSize().xPos() / 2 - (wide ? 110 : 81), parent.getSize().yPos() - (wide ? 54 : 76) - 12, wide ? 220 : 162, wide ? 54 : 76); - this.slots = new ArrayList<>(); - for (int row = 0; row < 3; ++row) { - for (int column = 0; column < 9; ++column) { - final ControlSlot slot = new ControlSlot.Builder(this, (wide ? 58 : 0) + column * 18, row * 18).assign(InventoryType.PLAYER, 9 + column + row * 9); + final int firstRowColumn = 9; + final int rowCount = 3; + final int columnCount = 9; + this.slots = new ArrayList<>(firstRowColumn + rowCount*columnCount); + for (int row = 0; row < rowCount; ++row) { + for (int column = 0; column < columnCount; ++column) { + final ControlSlot slot = new ControlSlot.Builder(this, (wide ? 58 : 0) + column * 18, row * 18) + .assign(InventoryType.PLAYER, firstRowColumn + column + row * columnCount); this.slots.add(slot); } } if (wide) { - for (int i1 = 0; i1 < 9; ++i1) { + for (int i1 = 0; i1 < firstRowColumn; ++i1) { final ControlSlot slot2 = new ControlSlot.Builder(this, i1 % 3 * 18, i1 / 3 * 18).assign(InventoryType.PLAYER, i1); this.slots.add(slot2); } } else { - for (int i1 = 0; i1 < 9; ++i1) { + for (int i1 = 0; i1 < firstRowColumn; ++i1) { final ControlSlot slot2 = new ControlSlot.Builder(this, i1 * 18, 58).assign(InventoryType.PLAYER, i1); this.slots.add(slot2); } @@ -41,10 +45,13 @@ public ControlPlayerInventory(final IWidget parent) { public ControlPlayerInventory(final IWidget parent, final int x, final int y) { super(parent, x, y, 54, 220); + final int rowCount = 6; + final int columnCount = 6; this.slots = new ArrayList<>(); - for (int row = 0; row < 6; ++row) { - for (int column = 0; column < 6; ++column) { - final ControlSlot slot = new ControlSlot.Builder(this, column * 18, row * 18).assign(InventoryType.PLAYER,column + row * 6); + for (int row = 0; row < rowCount; ++row) { + for (int column = 0; column < columnCount; ++column) { + final ControlSlot slot = new ControlSlot.Builder(this, column * 18, row * 18) + .assign(InventoryType.PLAYER,column + row * columnCount); this.slots.add(slot); } } From 56d499e4940656a1b3ef9d31b195ae989086078d Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:24:36 +1000 Subject: [PATCH 34/99] Refactor and localize ControlProgressBase.java --- .../control/ControlProgressBase.java | 20 +++++++++++++------ .../assets/binniecore/lang/en_US.lang | 4 ++++ .../assets/binniecore/lang/ru_RU.lang | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java index f9c2ee924..aec82de4c 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java @@ -33,17 +33,25 @@ public static String convertTime(final int time) { ++minutes; seconds -= 60; } - String ts = ""; + final StringBuilder stringBuilder = new StringBuilder(); if (minutes > 0) { - ts = ts + minutes + " minute" + ((minutes == 1) ? "" : "s"); + if (minutes == 1) { + stringBuilder.append(I18N.localise(ModId.CORE, "gui.progress.time.minute", minutes)); + } else { + stringBuilder.append(I18N.localise(ModId.CORE, "gui.progress.time.minutes", minutes)); + } } if (seconds > 0) { - if (ts.length() > 0) { - ts += " "; + if (stringBuilder.length() > 0) { + stringBuilder.append(' '); + } + if (seconds == 1) { + stringBuilder.append(I18N.localise(ModId.CORE, "gui.progress.time.second", seconds)); + } else { + stringBuilder.append(I18N.localise(ModId.CORE, "gui.progress.time.seconds", seconds)); } - ts = ts + seconds + " second" + ((seconds == 1) ? "" : "s"); } - return ts; + return stringBuilder.toString(); } public void setProgress(final float progress) { diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index 0d0e9003f..506c39698 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -376,6 +376,10 @@ binniecore.gui.charge.remaining.percent=Charge Remaining: %s binniecore.gui.progress.title=Progress binniecore.gui.progress.no.progress=Not in Progress binniecore.gui.progress.in.progress=In Progress +binniecore.gui.progress.time.minute=%d minute +binniecore.gui.progress.time.minutes=%d minutes +binniecore.gui.progress.time.second=%d second +binniecore.gui.progress.time.seconds=%d seconds binniecore.gui.progress.time.left=Time Left: %s binniecore.gui.progress.time.total=Total Time: %s binniecore.gui.progress.energy.cost.total=Energy Cost: %s RF diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index dab202497..8ce6fc535 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -375,6 +375,10 @@ binniecore.gui.charge.remaining.percent=Остаток заряда: %s binniecore.gui.progress.title=Прогресс binniecore.gui.progress.no.progress=Не выполняется binniecore.gui.progress.in.progress=Выполняется +binniecore.gui.progress.time.minute=%d минута +binniecore.gui.progress.time.minutes=%d минут +binniecore.gui.progress.time.second=%d секунда +binniecore.gui.progress.time.seconds=%d секунд binniecore.gui.progress.time.left=Осталось времени: %s binniecore.gui.progress.time.total=Общее время: %s binniecore.gui.progress.energy.cost.total=Энергетические затраты: %s RF From 0334c8df5231324e2234efd6f1c843f68036633d Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:25:39 +1000 Subject: [PATCH 35/99] Add final to vars --- .../core/gui/minecraft/control/ControlProgressBase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java index aec82de4c..033fc1cbe 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java @@ -93,14 +93,14 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (tooltipFlag.isAdvanced()) { NumberFormat numberFormat = I18N.getNumberFormat(); if (process.getProcessTime() > 0) { - String timeLeft = convertTime((int) ((1.0f - this.progress) * process.getProcessTime())); + final String timeLeft = convertTime((int) ((1.0f - this.progress) * process.getProcessTime())); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.progress.time.left", timeLeft)); - String timeTotal = convertTime(process.getProcessTime()); + final String timeTotal = convertTime(process.getProcessTime()); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.progress.time.total", timeTotal)); - String energyCostTotal = numberFormat.format(process.getProcessEnergy() * 10); + final String energyCostTotal = numberFormat.format(process.getProcessEnergy() * 10); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.progress.energy.cost.total", energyCostTotal)); } else { - String energyCostPerTick = numberFormat.format(process.getEnergyPerTick() * 10.0f); + final String energyCostPerTick = numberFormat.format(process.getEnergyPerTick() * 10.0f); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.energy.cost.per.tick", energyCostPerTick)); } } From 5ac0e500148465d440680f7839e8dd81a31b261b Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:27:55 +1000 Subject: [PATCH 36/99] Add Nullable annotation to label --- .../java/binnie/core/gui/minecraft/control/ControlSlide.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlide.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlide.java index 3f6b3f615..149a4cedf 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlide.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlide.java @@ -20,12 +20,14 @@ import binnie.core.gui.renderer.RenderUtil; import binnie.core.gui.resource.textures.CraftGUITexture; +import javax.annotation.Nullable; + public class ControlSlide extends Control { private final IArea expanded; private final IArea shrunk; private boolean slideActive; private final Alignment anchor; - private String label; + private @Nullable String label; public ControlSlide(final IWidget parent, final int x, final int y, final int w, final int h, final Alignment anchor2) { super(parent, x, y, w, h); From 70194663a3b75a374e59ae83c0d5692f7360c4e6 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:32:01 +1000 Subject: [PATCH 37/99] Add final to vars --- .../binnie/core/gui/minecraft/control/ControlSlot.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java index 9bb6f44b5..5b155da4c 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java @@ -58,9 +58,9 @@ public ControlSlot(final IWidget parent, final int x, final int y, final Slot sl super(parent, x, y); this.slot = slot; this.addSelfEventHandler(EventMouse.Down.class, event -> { - Window superParent = (Window) ControlSlot.this.getTopParent(); - GuiCraftGUI superParentGui = superParent.getGui(); - Minecraft mc = superParentGui.getMinecraft(); + final Window superParent = (Window) ControlSlot.this.getTopParent(); + final GuiCraftGUI superParentGui = superParent.getGui(); + final Minecraft mc = superParentGui.getMinecraft(); final PlayerControllerMP playerController = mc.playerController; final int windowId = superParent.getContainer().windowId; final int slotNumber = this.slot.slotNumber; @@ -87,7 +87,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(CraftGUITexture.SLOT, Point.ZERO); final InventorySlot islot = this.getInventorySlot(); if (islot != null) { - SlotValidator validator = islot.getValidator(); + final SlotValidator validator = islot.getValidator(); if (validator != null) { final TextureAtlasSprite icon = validator.getIcon(!islot.getInputSides().isEmpty()); if (icon != null && icon != Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()) { From 0c080155f6fecd4e9a266bac8464cc2ffd8f980d Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:54:14 +1000 Subject: [PATCH 38/99] Add final to vars --- .../binnie/core/gui/minecraft/control/ControlSlot.java | 4 ++-- .../core/gui/minecraft/control/ControlSlotArray.java | 8 ++++---- .../core/gui/minecraft/control/ControlSlotBase.java | 4 ++-- .../core/gui/minecraft/control/ControlSlotCharge.java | 4 ++-- .../binnie/core/gui/minecraft/control/ControlTabIcon.java | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java index 5b155da4c..a032065a7 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java @@ -193,11 +193,11 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (slot != null) { tooltip.add(slot.getName()); if (tooltipFlag.isAdvanced()) { - Collection inputSides = slot.getInputSides(); + final Collection inputSides = slot.getInputSides(); if (inputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides))); } - Collection outputSides = slot.getOutputSides(); + final Collection outputSides = slot.getOutputSides(); if (outputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides))); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java index d51000bca..328a768f5 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java @@ -28,8 +28,8 @@ public void setItemStacks(final ItemStack[] array) { if (i >= this.slots.size()) { return; } - ControlSlot controlSlot = this.slots.get(i); - Slot slot = controlSlot.slot; + final ControlSlot controlSlot = this.slots.get(i); + final Slot slot = controlSlot.slot; slot.putStack(item); ++i; } @@ -68,8 +68,8 @@ public ControlSlotArray create(final InventoryType type, final int[] index) { int i = 0; for (int row = 0; row < rows; ++row) { for (int column = 0; column < columns; ++column) { - ControlSlot.Builder slotBuilder = new ControlSlot.Builder(controlSlots, column * 18, row * 18); - ControlSlot slot = slotBuilder.assign(type, index[i++]); + final ControlSlot.Builder slotBuilder = new ControlSlot.Builder(controlSlots, column * 18, row * 18); + final ControlSlot slot = slotBuilder.assign(type, index[i++]); controlSlots.slots.add(slot); } } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java index d0a6e9fde..954b4c625 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java @@ -48,7 +48,7 @@ protected void setRotating() { public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(CraftGUITexture.SLOT, this.getArea()); if (this.getTopParent().getMousedOverWidget() == this) { - Area area = new Area(new Point(1, 1), this.getArea().size().sub(new Point(2, 2))); + final Area area = new Area(new Point(1, 1), this.getArea().size().sub(new Point(2, 2))); RenderUtil.drawGradientRect(area, -2130706433, -2130706433); } } @@ -67,7 +67,7 @@ public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (stack.isEmpty()) { return; } - List list = stack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); + final List list = stack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); for (int i = 0; i < list.size(); ++i) { if (i == 0) { diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java index 30e065048..3763cdc89 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java @@ -42,8 +42,8 @@ public void onRenderBackground(int guiWidth, int guiHeight) { @Override @SideOnly(Side.CLIENT) public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { - NumberFormat percentFormat = I18N.getPercentFormat(); - String chargePercent = percentFormat.format(this.getCharge()); + final NumberFormat percentFormat = I18N.getPercentFormat(); + final String chargePercent = percentFormat.format(this.getCharge()); tooltip.add(I18N.localise(ModId.CORE, "gui.charge.remaining.percent", chargePercent)); } } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java index d5c9611e2..6922950e7 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java @@ -31,11 +31,11 @@ public ItemStack getItemStack() { public void onUpdateClient() { super.onUpdateClient(); this.item.setItemStack(this.getItemStack()); - ControlTabBar parent = (ControlTabBar) this.getParent(); + final ControlTabBar parent = (ControlTabBar) this.getParent(); final int x = parent.getDirection().x(); - boolean selected = this.isCurrentSelection() || this.isMouseOver(); - int xOffset = selected ? 0 : (-4 * x); - Point offset = new Point(xOffset, 0); + final boolean selected = this.isCurrentSelection() || this.isMouseOver(); + final int xOffset = selected ? 0 : (-4 * x); + final Point offset = new Point(xOffset, 0); this.item.setOffset(offset); } From 71ea3e4a9c5a8b69cdbcbe65726123dd49cfefea Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:57:25 +1000 Subject: [PATCH 39/99] Improve localise in ControlUser.java --- .../java/binnie/core/gui/minecraft/control/ControlUser.java | 4 +++- core/src/main/resources/assets/binniecore/lang/en_US.lang | 2 ++ core/src/main/resources/assets/binniecore/lang/ru_RU.lang | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java index a80b34bad..5ac4526f4 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java @@ -13,6 +13,8 @@ import binnie.core.gui.Tooltip; import binnie.core.gui.controls.core.Control; import binnie.core.gui.resource.textures.CraftGUITexture; +import binnie.core.ModId; +import binnie.core.util.I18N; public class ControlUser extends Control implements ITooltip { private final String username; @@ -32,7 +34,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { @Override public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.setType(Tooltip.Type.USER); - tooltip.add("Owner"); + tooltip.add(I18N.localise(ModId.CORE, "gui.controluser.owner")); if (!Objects.equals(this.username, "")) { tooltip.add(this.username); } diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index 506c39698..89b9b5dea 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -384,6 +384,8 @@ binniecore.gui.progress.time.left=Time Left: %s binniecore.gui.progress.time.total=Total Time: %s binniecore.gui.progress.energy.cost.total=Energy Cost: %s RF +binniecore.gui.controluser.owner=Owner + binniecore.side.north=North binniecore.side.south=South binniecore.side.east=East diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 8ce6fc535..cb56c2826 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -383,6 +383,8 @@ binniecore.gui.progress.time.left=Осталось времени: %s binniecore.gui.progress.time.total=Общее время: %s binniecore.gui.progress.energy.cost.total=Энергетические затраты: %s RF +binniecore.gui.controluser.owner=Владелец + binniecore.side.north=Север binniecore.side.south=Юг binniecore.side.east=Восток From f01b9f4fb3deb58e2c8710523672888e3e0cde0d Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 21:58:13 +1000 Subject: [PATCH 40/99] Refactor to use EmptyHelper.EMPTY_STRING --- .../java/binnie/core/gui/minecraft/control/ControlUser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java index 5ac4526f4..e14bf177e 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java @@ -2,6 +2,7 @@ import java.util.Objects; +import binnie.core.util.EmptyHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -35,7 +36,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.setType(Tooltip.Type.USER); tooltip.add(I18N.localise(ModId.CORE, "gui.controluser.owner")); - if (!Objects.equals(this.username, "")) { + if (!Objects.equals(this.username, EmptyHelper.EMPTY_STRING)) { tooltip.add(this.username); } tooltip.setMaxWidth(200); From 0aacdca821c8e3b40fbf655feb715b58499b731e Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 22:11:11 +1000 Subject: [PATCH 41/99] Small refactoring in ContainerCraftGUI.java --- .../core/gui/minecraft/ContainerCraftGUI.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java index c29fd8cd8..687a6bd7e 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java @@ -88,17 +88,18 @@ private Side getSide() { public void onContainerClosed(final EntityPlayer playerIn) { this.crafters.remove(playerIn); super.onContainerClosed(playerIn); - WindowInventory inventory = this.window.getWindowInventory(); + final WindowInventory inventory = this.window.getWindowInventory(); for (int i = 0; i < inventory.getSizeInventory(); ++i) { if (inventory.dispenseOnClose(i)) { - ItemStack stack = inventory.getStackInSlot(i); - if (!stack.isEmpty()) { - TransferRequest transferRequest = new TransferRequest(stack, playerIn.inventory); - TransferResult transferResult = transferRequest.transfer(playerIn, true); - if (transferResult.isSuccess()) { - for (ItemStack result : transferResult.getRemaining()) { - playerIn.dropItem(result, false); - } + final ItemStack stack = inventory.getStackInSlot(i); + if (stack.isEmpty()) { + continue; + } + final TransferRequest transferRequest = new TransferRequest(stack, playerIn.inventory); + final TransferResult transferResult = transferRequest.transfer(playerIn, true); + if (transferResult.isSuccess()) { + for (ItemStack result : transferResult.getRemaining()) { + playerIn.dropItem(result, false); } } } @@ -125,7 +126,7 @@ public boolean canInteractWith(EntityPlayer entityPlayer) { crafters.add(entityPlayer); this.sentNBT.clear(); } - IInventory inventory = this.window.getInventory(); + final IInventory inventory = this.window.getInventory(); return inventory == null || inventory.isUsableByPlayer(entityPlayer); } @@ -136,9 +137,9 @@ public final ItemStack transferStackInSlot(final EntityPlayer player, final int private ItemStack shiftClick(final EntityPlayer player, final int slotnumber) { final TransferRequest request = this.getShiftClickRequest(player, slotnumber); - TransferResult transferResult = request.transfer(player, true); + final TransferResult transferResult = request.transfer(player, true); if (transferResult.isSuccess()) { - NonNullList results = transferResult.getRemaining(); + final NonNullList results = transferResult.getRemaining(); if (results.size() == 1) { final ItemStack itemstack = results.get(0); final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber); @@ -167,7 +168,7 @@ private TransferRequest getShiftClickRequest(final EntityPlayer player, final in request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory); } else { final int[] target = new int[36]; - for (int i = 0; i < 36; ++i) { + for (int i = 0; i < target.length; ++i) { target[i] = i; } request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory).setTargetSlots(target); @@ -179,7 +180,7 @@ private TransferRequest getShiftClickRequest(final EntityPlayer player, final in } public final void tankClick(final EntityPlayer player, final int slotID) { - IInventory inventory = this.window.getInventory(); + final IInventory inventory = this.window.getInventory(); if (inventory == null) { return; } @@ -188,18 +189,18 @@ public final void tankClick(final EntityPlayer player, final int slotID) { return; } heldItem = heldItem.copy(); - TransferRequest transferRequest = new TransferRequest(heldItem, inventory).setTargetTanks(slotID); - TransferResult transferResult = transferRequest.transfer(player, true); + final TransferRequest transferRequest = new TransferRequest(heldItem, inventory).setTargetTanks(slotID); + final TransferResult transferResult = transferRequest.transfer(player, true); if (transferResult.isSuccess()) { - NonNullList results = transferResult.getRemaining(); + final NonNullList results = transferResult.getRemaining(); if (results.size() > 0) { - ItemStack heldItemResult = results.remove(results.size() - 1); + final ItemStack heldItemResult = results.remove(results.size() - 1); player.inventory.setItemStack(heldItemResult); if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).updateHeldItem(); } if (results.size() > 0) { - IItemHandler itemHandler = new InvWrapper(inventory); + final IItemHandler itemHandler = new InvWrapper(inventory); for (ItemStack remaining : results) { ItemHandlerHelper.insertItemStacked(itemHandler, remaining, false); } @@ -245,7 +246,7 @@ public boolean handleNBTClient(final EntityPlayer player, final String name, fin @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (crafters.size() <= 0) { + if (crafters.isEmpty()) { return; } sendTankChanges(); @@ -269,7 +270,7 @@ public void detectAndSendChanges() { } private void sendTankChanges(){ - ITankMachine tanks = Machine.getInterface(ITankMachine.class, this.window.getInventory()); + final ITankMachine tanks = Machine.getInterface(ITankMachine.class, this.window.getInventory()); if (tanks != null && this.window.isServer()) { for (int i = 0; i < tanks.getTankInfos().length; ++i) { final TankInfo tank = tanks.getTankInfos()[i]; @@ -384,8 +385,6 @@ public int getErrorType() { return this.errorType; } - - public CustomSlot[] getCustomSlots() { final List slots = new ArrayList<>(); for (final Object object : this.inventorySlots) { From 5f57ea262370540990400c036d783c0431858bbf Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 22:15:24 +1000 Subject: [PATCH 42/99] Small refactoring in CustomSlot.java --- .../java/binnie/core/gui/minecraft/CustomSlot.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java b/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java index 44ca25c9c..fdd6fbf4d 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java @@ -38,16 +38,15 @@ public boolean handleClick() { } public void onSlotClick(final ContainerCraftGUI container, final int dragType, final ClickType modifier, final EntityPlayer player) { - InventoryPlayer inventory = player.inventory; - ItemStack stack = inventory.getItemStack(); - ItemStack slotStack = getStack().copy(); + final InventoryPlayer inventory = player.inventory; + final ItemStack stack = inventory.getItemStack(); //TODO modifier==mouseButton2? if (stack.isEmpty() || modifier == ClickType.PICKUP_ALL) { this.putStack(ItemStack.EMPTY); }else { - stack = stack.copy(); - stack.setCount(1); - this.putStack(stack); + final ItemStack slotStack = stack.copy(); + slotStack.setCount(1); + this.putStack(slotStack); } } } From fb23c582542fe480d2928d7baf7c522d3511bda4 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 22:40:36 +1000 Subject: [PATCH 43/99] Add final to vars GuiCraftGUI.java --- .../binnie/core/gui/minecraft/GuiCraftGUI.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java index aec5a9fcb..90f5b25f2 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java @@ -137,11 +137,11 @@ public void renderTooltip(final Point mousePosition, final MinecraftTooltip tool final int mouseX = mousePosition.xPos(); final int mouseY = mousePosition.yPos(); final FontRenderer font = this.getFontRenderer(); - ItemStack itemStack = tooltip.getItemStack(); + final ItemStack itemStack = tooltip.getItemStack(); boolean containsItemRender = false; - List textLines = new ArrayList<>(); + final List textLines = new ArrayList<>(tooltip.getList().size()); for (final String string : tooltip.getList()) { if (string != null) { if (!string.contains(Tooltip.NBT_SEPARATOR)) { @@ -200,15 +200,15 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List textLin if (needsWrap) { int wrappedTooltipWidth = 0; - List wrappedTextLines = new ArrayList<>(); + final List wrappedTextLines = new ArrayList<>(textLines.size()); for (int i = 0; i < textLines.size(); i++) { - String textLine = textLines.get(i); - List wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth); + final String textLine = textLines.get(i); + final List wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth); if (i == 0) { titleLinesCount = wrappedLine.size(); } - for (String line : wrappedLine) { + for (final String line : wrappedLine) { int lineWidth = font.getStringWidth(line); if (textLine.contains(Tooltip.NBT_SEPARATOR)) { lineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(EmptyHelper.EMPTY_STRING)); @@ -284,8 +284,8 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List textLin private void drawItem(String line, int tooltipX, int tooltipY){ String itemTag = line.split(Tooltip.NBT_SEPARATOR)[1]; try { - NBTTagCompound nbt = JsonToNBT.getTagFromJson(itemTag); - ItemStack stack = new ItemStack(nbt); + final NBTTagCompound nbt = JsonToNBT.getTagFromJson(itemTag); + final ItemStack stack = new ItemStack(nbt); GlStateManager.pushMatrix(); GlStateManager.translate(tooltipX, tooltipY - 1.5f, 0.0f); GlStateManager.scale(0.6f, 0.6f, 1.0f); From 5268728e5819def21b109af0089909c85ea4a663 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 22:47:19 +1000 Subject: [PATCH 44/99] Add final to vars Window.java --- core/src/main/java/binnie/core/gui/minecraft/Window.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/Window.java b/core/src/main/java/binnie/core/gui/minecraft/Window.java index e92f6bd93..42bce42ba 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/Window.java +++ b/core/src/main/java/binnie/core/gui/minecraft/Window.java @@ -164,7 +164,7 @@ public boolean showHelpButton() { @Nullable public String showInfoButton() { - IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory()); + final IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory()); if (machineInformation != null) { return machineInformation.getInformation(); } @@ -272,7 +272,7 @@ public boolean isClient() { } public World getWorld() { - return this.getPlayer().world; + return this.player.world; } public void sendClientAction(final String name, final NBTTagCompound action) { From 2b6cc7f9f5000d77ca98e6ea0d608a528c8a452c Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 22:53:03 +1000 Subject: [PATCH 45/99] Add final to vars renderer --- .../binnie/core/gui/renderer/RenderUtil.java | 22 +++++++++---------- .../core/gui/renderer/TextureRenderer.java | 6 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java b/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java index 877c96d2d..8583444c9 100644 --- a/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java +++ b/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java @@ -95,8 +95,8 @@ public static void drawTexture(double xCoord, double yCoord, TextureAtlasSprite uMax -= maskRight / 16.0 * (uMax - uMin); vMax -= maskTop / 16.0 * (vMax - vMin); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); + final Tessellator tessellator = Tessellator.getInstance(); + final BufferBuilder bufferBuilder = tessellator.getBuffer(); bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferBuilder.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex(); bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex(); @@ -121,12 +121,12 @@ public static void setColour(final int hexColour) { } public static int getTextWidth(final String text) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; return fontRenderer.getStringWidth(text); } public static int getTextHeight() { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; return (fontRenderer == null) ? 0 : fontRenderer.FONT_HEIGHT; } @@ -139,7 +139,7 @@ public static void drawText(final IArea area, final TextJustification justificat if (area.size().xPos() <= 0.0f) { return; } - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; final List wrappedStrings = fontRenderer.listFormattedStringToWidth(text, area.size().xPos()); final float totalHeight = wrappedStrings.size() * getTextHeight(); float posY = pos.yPos(); @@ -191,13 +191,13 @@ public static void drawFluid(Point pos, @Nullable FluidStack fluidStack) { GlStateManager.enableBlend(); GlStateManager.enableAlpha(); - Minecraft minecraft = Minecraft.getMinecraft(); + final Minecraft minecraft = Minecraft.getMinecraft(); if (fluidStack != null) { - Fluid fluid = fluidStack.getFluid(); + final Fluid fluid = fluidStack.getFluid(); if (fluid != null) { - TextureAtlasSprite stillSprite = getStillFluidSprite(minecraft, fluid); + final TextureAtlasSprite stillSprite = getStillFluidSprite(minecraft, fluid); - int fluidColor = fluid.getColor(fluidStack); + final int fluidColor = fluid.getColor(fluidStack); minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); setColour(fluidColor); @@ -209,8 +209,8 @@ public static void drawFluid(Point pos, @Nullable FluidStack fluidStack) { } private static TextureAtlasSprite getStillFluidSprite(Minecraft minecraft, Fluid fluid) { - TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); - ResourceLocation fluidStill = fluid.getStill(); + final TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); + final ResourceLocation fluidStill = fluid.getStill(); TextureAtlasSprite fluidStillSprite = null; if (fluidStill != null) { fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString()); diff --git a/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java b/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java index 7cc9e4894..b3bd11eeb 100644 --- a/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java +++ b/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java @@ -173,7 +173,7 @@ public void limitArea(final IArea area, int guiWidth, int guiHeight) { float w = area.size().xPos(); float h = area.size().yPos(); y = guiHeight - (y + h); - Minecraft minecraft = Minecraft.getMinecraft(); + final Minecraft minecraft = Minecraft.getMinecraft(); final float scaleX = guiWidth / (float) minecraft.displayWidth; final float scaleY = guiHeight / (float) minecraft.displayHeight; x += 0.0f; @@ -184,8 +184,8 @@ public void limitArea(final IArea area, int guiWidth, int guiHeight) { } public int textHeight(final String text, final int width) { - Minecraft minecraft = Minecraft.getMinecraft(); - FontRenderer fontRenderer = minecraft.fontRenderer; + final Minecraft minecraft = Minecraft.getMinecraft(); + final FontRenderer fontRenderer = minecraft.fontRenderer; return fontRenderer.listFormattedStringToWidth(text, width).size() * RenderUtil.getTextHeight(); } From c3e9f8be8fafd2bddda21e091bd1e8f4878d7574 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 22:53:57 +1000 Subject: [PATCH 46/99] Add final to vars renderer --- .../main/java/binnie/core/gui/renderer/TextureRenderer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java b/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java index b3bd11eeb..f1041b86a 100644 --- a/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java +++ b/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java @@ -96,7 +96,7 @@ public void setStyleSheet(IStyleSheet styleSheet) { this.styleSheet = styleSheet; } - public final void preRender(final IWidget widget, int guiWidth, int guiHeight) { + public final void preRender(final IWidget widget, final int guiWidth, final int guiHeight) { GlStateManager.pushMatrix(); GlStateManager.translate(widget.getPosition().xPos(), widget.getPosition().yPos(), 0.0f); RenderUtil.setColour(widget.getColor()); @@ -167,7 +167,7 @@ public void texture(@Nullable final ITexture texture, final IArea area) { } } - public void limitArea(final IArea area, int guiWidth, int guiHeight) { + public void limitArea(final IArea area, final int guiWidth, final int guiHeight) { float x = area.pos().xPos(); float y = area.pos().yPos(); float w = area.size().xPos(); From 4195e2b8baeefa0c4b192e691353b284e822059b Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 14:59:35 +1000 Subject: [PATCH 47/99] Refactor to use org.apache.commons.lang3.StringUtils.EMPTY --- .../binnie/core/config/ConfigProperty.java | 4 ++-- .../binnie/core/genetics/AlleleHelper.java | 6 +++--- .../java/binnie/core/genetics/Tolerance.java | 5 ++--- .../core/gui/controls/ControlTextEdit.java | 6 +++--- .../gui/controls/ControlToleranceBar.java | 4 ++-- .../core/gui/database/PageBranchOverview.java | 11 +++++----- .../database/PageSpeciesClassification.java | 6 +++--- .../gui/database/PageSpeciesOverview.java | 20 ++++++++++--------- .../gui/database/WindowAbstractDatabase.java | 4 ++-- .../core/gui/fieldkit/WindowFieldKit.java | 8 ++++---- .../core/gui/minecraft/GuiCraftGUI.java | 8 ++++---- .../gui/minecraft/control/ControlUser.java | 4 ++-- .../java/binnie/core/util/EmptyHelper.java | 2 -- 13 files changed, 43 insertions(+), 45 deletions(-) diff --git a/core/src/main/java/binnie/core/config/ConfigProperty.java b/core/src/main/java/binnie/core/config/ConfigProperty.java index 25085f17f..6e3d92be2 100644 --- a/core/src/main/java/binnie/core/config/ConfigProperty.java +++ b/core/src/main/java/binnie/core/config/ConfigProperty.java @@ -5,14 +5,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface ConfigProperty { String key(); - String category() default EmptyHelper.EMPTY_STRING; + String category() default StringUtils.EMPTY; String[] comment() default {}; diff --git a/core/src/main/java/binnie/core/genetics/AlleleHelper.java b/core/src/main/java/binnie/core/genetics/AlleleHelper.java index 393f615ba..713371757 100644 --- a/core/src/main/java/binnie/core/genetics/AlleleHelper.java +++ b/core/src/main/java/binnie/core/genetics/AlleleHelper.java @@ -3,7 +3,7 @@ import java.util.Locale; import java.util.regex.Pattern; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import forestry.api.core.EnumHumidity; @@ -205,12 +205,12 @@ private static String getUid(final String key, String valueName, final boolean n if (needCapitalize) { valueName = WordUtils.capitalize(valueName.toLowerCase(Locale.ENGLISH)); } - valueName = PATTERN_REPLACEMENT.matcher(valueName).replaceAll(EmptyHelper.EMPTY_STRING); + valueName = PATTERN_REPLACEMENT.matcher(valueName).replaceAll(StringUtils.EMPTY); return "forestry." + key + valueName; } private static String toAlleleDisplay(final @Nullable String key, final String valueName) { - String name = PATTERN_REPLACEMENT.matcher(valueName.toLowerCase()).replaceAll(EmptyHelper.EMPTY_STRING); + String name = PATTERN_REPLACEMENT.matcher(valueName.toLowerCase()).replaceAll(StringUtils.EMPTY); if (key == null) { return I18N.localise("forestry.allele." + name); } diff --git a/core/src/main/java/binnie/core/genetics/Tolerance.java b/core/src/main/java/binnie/core/genetics/Tolerance.java index 842305b1a..4adfb039f 100644 --- a/core/src/main/java/binnie/core/genetics/Tolerance.java +++ b/core/src/main/java/binnie/core/genetics/Tolerance.java @@ -3,13 +3,12 @@ import java.util.Locale; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; -import binnie.core.util.EmptyHelper; - public enum Tolerance { NONE(0, 0), BOTH_1(-1, 1), BOTH_2(-2, 2), BOTH_3(-3, 3), BOTH_4(-4, 4), BOTH_5(-5, 5), @@ -36,7 +35,7 @@ public static > boolean canTolerate(final T base, final T test @Override public String toString() { - return PATTERN.matcher(name().toLowerCase(Locale.ENGLISH)).replaceAll(EmptyHelper.EMPTY_STRING); + return PATTERN.matcher(name().toLowerCase(Locale.ENGLISH)).replaceAll(StringUtils.EMPTY); } public String getUID() { diff --git a/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java b/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java index 2054ba0b6..49679e10e 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlTextEdit.java @@ -15,7 +15,7 @@ import binnie.core.gui.events.EventTextEdit; import binnie.core.gui.events.EventWidget; import binnie.core.gui.resource.textures.CraftGUITexture; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; @SideOnly(Side.CLIENT) public class ControlTextEdit extends Control implements IControlValue { @@ -24,7 +24,7 @@ public class ControlTextEdit extends Control implements IControlValue { public ControlTextEdit(final IWidget parent, final int x, final int y, final int width, final int height) { super(parent, x, y, width, height); - this.cachedValue = EmptyHelper.EMPTY_STRING; + this.cachedValue = StringUtils.EMPTY; this.field = new GuiTextField(0, this.getWindow().getGui().getFontRenderer(), 0, 0, 10, 10); this.addAttribute(Attribute.CAN_FOCUS); this.addAttribute(Attribute.MOUSE_OVER); @@ -51,7 +51,7 @@ public ControlTextEdit(final IWidget parent, final int x, final int y, final int @Override public String getValue() { - return (this.field.getText() == null) ? EmptyHelper.EMPTY_STRING : this.field.getText(); + return (this.field.getText() == null) ? StringUtils.EMPTY : this.field.getText(); } @Override diff --git a/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java b/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java index c6f2b7d4c..13e0139c1 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlToleranceBar.java @@ -19,7 +19,7 @@ import binnie.core.gui.geometry.Area; import binnie.core.gui.geometry.Border; import binnie.core.gui.renderer.RenderUtil; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; public abstract class ControlToleranceBar> extends Control implements ITooltip { private final EnumSet tolerated; @@ -43,7 +43,7 @@ public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) { int type = getRelativeMousePosition().xPos() / (getSize().xPos() / types); for (T tol : fullSet) { if (tol.ordinal() - ((enumClass == EnumTemperature.class) ? 1 : 0) == type) { - tooltip.add((tolerated.contains(tol) ? EmptyHelper.EMPTY_STRING : TextFormatting.DARK_GRAY) + getName(tol)); + tooltip.add((tolerated.contains(tol) ? StringUtils.EMPTY : TextFormatting.DARK_GRAY) + getName(tol)); } } } diff --git a/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java b/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java index db1ce1cba..aca1e443b 100644 --- a/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java +++ b/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Objects; import net.minecraft.util.text.TextFormatting; @@ -16,7 +15,7 @@ import binnie.core.gui.controls.ControlTextCentered; import binnie.core.gui.renderer.RenderUtil; import binnie.core.util.I18N; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; @SideOnly(Side.CLIENT) public class PageBranchOverview extends PageBranch { @@ -28,9 +27,9 @@ public class PageBranchOverview extends PageBranch { public PageBranchOverview(final IWidget parent, final DatabaseTab tab) { super(parent, tab); this.branchDescription = new ArrayList<>(); - this.branchName = new ControlTextCentered(this, 8, EmptyHelper.EMPTY_STRING); - this.branchScientific = new ControlTextCentered(this, 32, EmptyHelper.EMPTY_STRING); - this.branchAuthority = new ControlTextCentered(this, 44, EmptyHelper.EMPTY_STRING); + this.branchName = new ControlTextCentered(this, 8, StringUtils.EMPTY); + this.branchScientific = new ControlTextCentered(this, 32, StringUtils.EMPTY); + this.branchAuthority = new ControlTextCentered(this, 44, StringUtils.EMPTY); } @Override @@ -43,7 +42,7 @@ public void onValueChanged(final IClassification branch) { } this.branchDescription.clear(); String desc = branch.getDescription(); - if (desc == null || Objects.equals(desc, EmptyHelper.EMPTY_STRING) || desc.contains("for.")) { + if (desc == null || desc.length() == 0 || desc.contains("for.")) { desc = I18N.localise(DatabaseConstants.BRANCH_KEY + ".noDesc"); } StringBuilder line = new StringBuilder(); diff --git a/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java b/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java index 4dd12fffa..e3ea39383 100644 --- a/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java +++ b/core/src/main/java/binnie/core/gui/database/PageSpeciesClassification.java @@ -9,7 +9,7 @@ import binnie.core.api.gui.IWidget; import binnie.core.gui.controls.ControlText; import binnie.core.gui.controls.ControlTextCentered; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; public class PageSpeciesClassification extends PageSpecies { private final Map levels; @@ -20,12 +20,12 @@ public PageSpeciesClassification(final IWidget parent, final DatabaseTab tab) { this.levels = new LinkedHashMap<>(); int y = 16; for (final IClassification.EnumClassLevel level : IClassification.EnumClassLevel.values()) { - final ControlText text = new ControlTextCentered(this, y, EmptyHelper.EMPTY_STRING); + final ControlText text = new ControlTextCentered(this, y, StringUtils.EMPTY); text.setColor(level.getColour()); this.levels.put(level, text); y += 12; } - (this.genus = new ControlTextCentered(this, y, EmptyHelper.EMPTY_STRING)).setColor(16759415); + (this.genus = new ControlTextCentered(this, y, StringUtils.EMPTY)).setColor(16759415); } @Override diff --git a/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java b/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java index ac047dcf1..b73984ba6 100644 --- a/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java +++ b/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java @@ -19,6 +19,8 @@ import binnie.core.util.I18N; import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; + @SideOnly(Side.CLIENT) public class PageSpeciesOverview extends PageSpecies { private final ControlText controlName; @@ -34,12 +36,12 @@ public PageSpeciesOverview(final IWidget parent, final DatabaseTab tab) { super(parent, tab); this.controlInd1 = new ControlIndividualDisplay(this, 5, 5); this.controlInd2 = new ControlIndividualDisplay(this, 123, 5); - this.controlName = new ControlTextCentered(this, 8, EmptyHelper.EMPTY_STRING); - this.controlScientific = new ControlTextCentered(this, 32, EmptyHelper.EMPTY_STRING); - this.controlAuthority = new ControlTextCentered(this, 44, EmptyHelper.EMPTY_STRING); - this.controlComplexity = new ControlTextCentered(this, 68, EmptyHelper.EMPTY_STRING); - this.controlDescription = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), EmptyHelper.EMPTY_STRING, TextJustification.MIDDLE_CENTER); - this.controlSignature = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), EmptyHelper.EMPTY_STRING, TextJustification.BOTTOM_RIGHT); + this.controlName = new ControlTextCentered(this, 8, StringUtils.EMPTY); + this.controlScientific = new ControlTextCentered(this, 32, StringUtils.EMPTY); + this.controlAuthority = new ControlTextCentered(this, 44, StringUtils.EMPTY); + this.controlComplexity = new ControlTextCentered(this, 68, StringUtils.EMPTY); + this.controlDescription = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), StringUtils.EMPTY, TextJustification.MIDDLE_CENTER); + this.controlSignature = new ControlText(this, new Area(8, 84, this.getSize().xPos() - 16, 0), StringUtils.EMPTY, TextJustification.BOTTOM_RIGHT); } @Override @@ -52,9 +54,9 @@ public void onValueChanged(final IAlleleSpecies species) { this.controlAuthority.setValue(I18N.localise(DatabaseConstants.KEY + ".discovered") + ": " + TextFormatting.BOLD + species.getAuthority()); this.controlComplexity.setValue(I18N.localise(DatabaseConstants.KEY + ".overview.complexity") + ": " + species.getComplexity()); final String desc = species.getDescription(); - StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString()); - String descSig = EmptyHelper.EMPTY_STRING; - if (desc == null || Objects.equals(desc, EmptyHelper.EMPTY_STRING) || desc.contains("for.description") || desc.contains(".desc")) { + final StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString()); + String descSig = StringUtils.EMPTY; + if (desc == null || desc.length() == 0 || desc.contains("for.description") || desc.contains(".desc")) { descBody.append(I18N.localise(DatabaseConstants.KEY + ".no.description")); } else { final String[] descStrings = desc.split("\\|"); diff --git a/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java b/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java index d9cd83a86..1e80eea0e 100644 --- a/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java +++ b/core/src/main/java/binnie/core/gui/database/WindowAbstractDatabase.java @@ -37,7 +37,7 @@ import binnie.core.gui.minecraft.control.ControlHelp; import binnie.core.gui.window.Panel; import binnie.core.util.I18N; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; public abstract class WindowAbstractDatabase extends Window { private final boolean master; @@ -134,7 +134,7 @@ public void initialiseClient() { this.addEventHandler(EventTextEdit.class, EventHandlerOrigin.DIRECT_CHILD, this, event -> { for (final ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) { widgets.getListBox().setValidator(object -> { - if (Objects.equals(event.getValue(), EmptyHelper.EMPTY_STRING)) { + if (Objects.equals(event.getValue(), StringUtils.EMPTY)) { return true; } ControlTextOption controlTextOption = (ControlTextOption) object; diff --git a/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java b/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java index 237b666b5..87cd86554 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java @@ -45,7 +45,7 @@ import binnie.core.gui.resource.textures.StandardTexture; import binnie.core.texture.BinnieCoreTexture; import binnie.core.util.I18N; -import binnie.core.util.EmptyHelper; +import org.apache.commons.lang3.StringUtils; public class WindowFieldKit extends Window { public static final int INDIVIDUAL_SLOT = 0; @@ -107,7 +107,7 @@ public void initialiseClient() { new ControlSlot.Builder(this, handGlass.xPos() + 54, handGlass.yPos() + 26).assign(InventoryType.WINDOW, 0); new ControlSlot.Builder(this, 208, 8).assign(InventoryType.WINDOW, 1); (this.text = new ControlText(this, new Point(232, 13), I18N.localise("binniecore.gui.fieldkit.paper"))).setColor(2236962); - (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), EmptyHelper.EMPTY_STRING, TextJustification.MIDDLE_CENTER)).setColor(2236962); + (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), StringUtils.EMPTY, TextJustification.MIDDLE_CENTER)).setColor(2236962); this.chromo = new ControlChromosome(this, 150, 24); this.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, this.chromo, event -> { final IChromosomeType type = (IChromosomeType) event.getValue(); @@ -115,7 +115,7 @@ public void initialiseClient() { final String t = WindowFieldKit.this.info.get(type); WindowFieldKit.this.text.setValue(t); } else { - WindowFieldKit.this.text.setValue(EmptyHelper.EMPTY_STRING); + WindowFieldKit.this.text.setValue(StringUtils.EMPTY); } }); } @@ -212,7 +212,7 @@ public void onWindowInventoryChanged() { ((EntityPlayerMP) this.getPlayer()).updateHeldItem(); } else if (this.isClient()) { final ItemStack item = inventory.getStackInSlot(INDIVIDUAL_SLOT); - this.text.setValue(EmptyHelper.EMPTY_STRING); + this.text.setValue(StringUtils.EMPTY); if (!item.isEmpty() && !ManagerGenetics.isAnalysed(item)) { if (inventory.getStackInSlot(PAPER_SLOT).isEmpty()) { this.text.setValue(I18N.localise("binniecore.gui.fieldkit.paper.no")); diff --git a/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java index 90f5b25f2..cc77f14a3 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java @@ -11,7 +11,6 @@ import binnie.core.gui.KeyBindings; import binnie.core.gui.geometry.Point; import binnie.core.util.Log; -import binnie.core.util.EmptyHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; @@ -29,6 +28,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.StringUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -156,7 +156,7 @@ public void renderTooltip(final Point mousePosition, final MinecraftTooltip tool for (String textLine : textLines) { int textLineWidth = font.getStringWidth(textLine); if (textLine.contains(Tooltip.NBT_SEPARATOR)) { - textLineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(EmptyHelper.EMPTY_STRING)); + textLineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(StringUtils.EMPTY)); } if (textLineWidth > tooltipTextWidth) { tooltipTextWidth = textLineWidth; @@ -211,7 +211,7 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List textLin for (final String line : wrappedLine) { int lineWidth = font.getStringWidth(line); if (textLine.contains(Tooltip.NBT_SEPARATOR)) { - lineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(EmptyHelper.EMPTY_STRING)); + lineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(StringUtils.EMPTY)); } if (lineWidth > wrappedTooltipWidth) { wrappedTooltipWidth = lineWidth; @@ -266,7 +266,7 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List textLin } if (line.contains(Tooltip.NBT_SEPARATOR)) { drawItem(line, tooltipX, tooltipY); - line = " " + PATTERN_NBT_CONTENT.matcher(line).replaceAll(EmptyHelper.EMPTY_STRING); + line = " " + PATTERN_NBT_CONTENT.matcher(line).replaceAll(StringUtils.EMPTY); } font.drawStringWithShadow(line, tooltipX, tooltipY, -1); if (lineNumber + 1 == titleLinesCount) { diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java index e14bf177e..957e2754d 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlUser.java @@ -2,7 +2,6 @@ import java.util.Objects; -import binnie.core.util.EmptyHelper; import net.minecraft.client.util.ITooltipFlag; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -16,6 +15,7 @@ import binnie.core.gui.resource.textures.CraftGUITexture; import binnie.core.ModId; import binnie.core.util.I18N; +import org.apache.commons.lang3.StringUtils; public class ControlUser extends Control implements ITooltip { private final String username; @@ -36,7 +36,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.setType(Tooltip.Type.USER); tooltip.add(I18N.localise(ModId.CORE, "gui.controluser.owner")); - if (!Objects.equals(this.username, EmptyHelper.EMPTY_STRING)) { + if (!Objects.equals(this.username, StringUtils.EMPTY)) { tooltip.add(this.username); } tooltip.setMaxWidth(200); diff --git a/core/src/main/java/binnie/core/util/EmptyHelper.java b/core/src/main/java/binnie/core/util/EmptyHelper.java index efc6bcb34..d2bb984a3 100644 --- a/core/src/main/java/binnie/core/util/EmptyHelper.java +++ b/core/src/main/java/binnie/core/util/EmptyHelper.java @@ -13,8 +13,6 @@ public final class EmptyHelper { private EmptyHelper() {} - public static final String EMPTY_STRING = ""; - public static final IPacketID[] PACKET_IDS_EMPTY = new IPacketID[0]; public static final IBinnieGUID[] BINNIE_GUIDS_EMPTY = new IBinnieGUID[0]; From 42555890d22dafd9b31e14989094f692d9210612 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 15:33:16 +1000 Subject: [PATCH 48/99] Fix crashing with NullPointerException in Tolerance.toString() --- .../main/java/binnie/core/genetics/Tolerance.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/genetics/Tolerance.java b/core/src/main/java/binnie/core/genetics/Tolerance.java index 4adfb039f..aa4ebb2f4 100644 --- a/core/src/main/java/binnie/core/genetics/Tolerance.java +++ b/core/src/main/java/binnie/core/genetics/Tolerance.java @@ -9,6 +9,8 @@ import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; +import javax.annotation.Nullable; + public enum Tolerance { NONE(0, 0), BOTH_1(-1, 1), BOTH_2(-2, 2), BOTH_3(-3, 3), BOTH_4(-4, 4), BOTH_5(-5, 5), @@ -31,11 +33,19 @@ public static > boolean canTolerate(final T base, final T test return get(tol).canTolerate(base, test); } - private static final Pattern PATTERN = Pattern.compile("_", Pattern.LITERAL); + @Nullable + private static Pattern PATTERN; + + private static Pattern GetPattern() { + if (PATTERN == null) { + PATTERN = Pattern.compile("_", Pattern.LITERAL); + } + return PATTERN; + } @Override public String toString() { - return PATTERN.matcher(name().toLowerCase(Locale.ENGLISH)).replaceAll(StringUtils.EMPTY); + return GetPattern().matcher(super.toString().toLowerCase(Locale.ENGLISH)).replaceAll(StringUtils.EMPTY); } public String getUID() { From 15a02042bee083cef2f6819b0afead67f3ee914c Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 16:28:26 +1000 Subject: [PATCH 49/99] Add final to vars. Rename min and sec in ru_lang. --- .../binnie/core/gui/BinnieGUIHandler.java | 6 +-- .../java/binnie/core/gui/KeyBindings.java | 2 +- .../main/java/binnie/core/gui/Tooltip.java | 4 +- .../java/binnie/core/gui/TopLevelWidget.java | 6 +-- .../src/main/java/binnie/core/gui/Widget.java | 22 ++++---- .../binnie/core/gui/minecraft/Window.java | 3 +- .../stylesheet/StyleSheetManager.java | 6 +-- .../resource/stylesheet/StyleSheetParser.java | 54 +++++++++---------- .../assets/binniecore/lang/ru_RU.lang | 4 +- 9 files changed, 54 insertions(+), 53 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java b/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java index 4f804e49b..470ae0696 100644 --- a/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java +++ b/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java @@ -21,7 +21,7 @@ public BinnieGUIHandler(final IBinnieGUID[] guiIds) { @Override @Nullable public final Object getServerGuiElement(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z) { - Window window = this.getWindow(id, player, world, x, y, z, Side.SERVER); + final Window window = this.getWindow(id, player, world, x, y, z, Side.SERVER); if (window == null) { return null; } @@ -36,7 +36,7 @@ public final Object getClientGuiElement(final int id, final EntityPlayer player, if (!world.isRemote) { return this.getServerGuiElement(id, player, world, x, y, z); } - Window window = this.getWindow(id, player, world, x, y, z, Side.CLIENT); + final Window window = this.getWindow(id, player, world, x, y, z, Side.CLIENT); if (window == null) { return null; } @@ -45,7 +45,7 @@ public final Object getClientGuiElement(final int id, final EntityPlayer player, @Nullable public Window getWindow(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) { - for (IBinnieGUID guid : guiIds) { + for (final IBinnieGUID guid : guiIds) { if (guid.ordinal() == id) { return guid.getWindow(player, world, x, y, z, side); } diff --git a/core/src/main/java/binnie/core/gui/KeyBindings.java b/core/src/main/java/binnie/core/gui/KeyBindings.java index 0c9c91e3f..0456e3508 100644 --- a/core/src/main/java/binnie/core/gui/KeyBindings.java +++ b/core/src/main/java/binnie/core/gui/KeyBindings.java @@ -28,7 +28,7 @@ private KeyBindings() { } public static void init() { - for (KeyBinding binding : allBindings) { + for (final KeyBinding binding : allBindings) { ClientRegistry.registerKeyBinding(binding); } } diff --git a/core/src/main/java/binnie/core/gui/Tooltip.java b/core/src/main/java/binnie/core/gui/Tooltip.java index d089805f9..e1165fd6f 100644 --- a/core/src/main/java/binnie/core/gui/Tooltip.java +++ b/core/src/main/java/binnie/core/gui/Tooltip.java @@ -71,7 +71,7 @@ public void setType(final ITooltipType type) { * Add a tooltip that also displays an itemStack on the tooltip directly. */ public void add(ItemStack itemStack, String string) { - NBTTagCompound nbt = new NBTTagCompound(); + final NBTTagCompound nbt = new NBTTagCompound(); itemStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_ITEM); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); @@ -81,7 +81,7 @@ public void add(ItemStack itemStack, String string) { * Add a tooltip that also displays an fluidStack on the tooltip directly. */ public void add(FluidStack fluidStack, String string) { - NBTTagCompound nbt = new NBTTagCompound(); + final NBTTagCompound nbt = new NBTTagCompound(); fluidStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_FLUID); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); diff --git a/core/src/main/java/binnie/core/gui/TopLevelWidget.java b/core/src/main/java/binnie/core/gui/TopLevelWidget.java index 4984945c2..040a4b8b6 100644 --- a/core/src/main/java/binnie/core/gui/TopLevelWidget.java +++ b/core/src/main/java/binnie/core/gui/TopLevelWidget.java @@ -157,14 +157,14 @@ public Deque calculateMousedOverWidgets() { } private Collection getQueuedWidgets(final IWidget widget) { - List widgets = new ArrayList<>(); + final List widgets = new ArrayList<>(); boolean addChildren = true; - IArea croppedZone = widget.getCroppedZone(); + final IArea croppedZone = widget.getCroppedZone(); if (croppedZone != null) { addChildren = croppedZone.contains(widget.getCropWidget().getRelativeMousePosition()); } if (addChildren) { - ListIterator iterator = widget.getChildren().listIterator(widget.getChildren().size()); + final ListIterator iterator = widget.getChildren().listIterator(widget.getChildren().size()); while (iterator.hasPrevious()) { final IWidget child = iterator.previous(); widgets.addAll(this.getQueuedWidgets(child)); diff --git a/core/src/main/java/binnie/core/gui/Widget.java b/core/src/main/java/binnie/core/gui/Widget.java index dcf3ce662..73178e971 100644 --- a/core/src/main/java/binnie/core/gui/Widget.java +++ b/core/src/main/java/binnie/core/gui/Widget.java @@ -91,7 +91,7 @@ public void addChild(IWidget child) { if(child == null){ return; } - IWidget topWidget = getTopChild(); + final IWidget topWidget = getTopChild(); if (topWidget != null && topWidget.hasAttribute(Attribute.ALWAYS_ON_TOP)) { this.children.add(this.children.size() - 1, child); } else { @@ -115,11 +115,11 @@ public final List getChildren() { @Override @Nullable public W getWidget(Class widgetClass) { - for (IWidget child : this.getChildren()) { + for (final IWidget child : this.getChildren()) { if (widgetClass.isInstance(child)) { return widgetClass.cast(child); } - W found = child.getWidget(widgetClass); + final W found = child.getWidget(widgetClass); if (found != null) { return found; } @@ -132,7 +132,7 @@ public IWidget getTopChild() { if(children.isEmpty()){ return null; } - int childrenCount = getChildren().size(); + final int childrenCount = getChildren().size(); return children.get(childrenCount - 1); } @@ -191,7 +191,7 @@ public final void setCroppedZone(final IWidget relative, final IArea area) { @Override public final IPoint getAbsolutePosition() { - IWidget parent = this.getParent(); + final IWidget parent = this.getParent(); return parent == null ? this.getPosition() : parent.getAbsolutePosition().add(this.getPosition()); } @@ -271,14 +271,14 @@ public void callEvent(final Event event) { @Override @SuppressWarnings("unchecked") public void receiveEvent(Event event) { - for (EventHandler handler : this.eventHandlers) { + for (final EventHandler handler : this.eventHandlers) { if (handler.handles(event)) { ((EventHandler) handler).onEvent(event); } } - List children = new LinkedList<>(getChildren()); - for (IWidget child : children) { + final List children = new LinkedList<>(getChildren()); + for (final IWidget child : children) { child.receiveEvent(event); } } @@ -295,7 +295,7 @@ public IPoint getMousePosition() { @Override public final IPoint getRelativeMousePosition() { - IWidget parent = this.getParent(); + final IWidget parent = this.getParent(); return parent == null ? this.getMousePosition() : parent.getRelativeMousePosition().sub(this.getPosition()); } @@ -388,7 +388,7 @@ public void onRenderOverlay() { /* STATES*/ @Override public boolean isEnabled() { - IWidget parent = this.getParent(); + final IWidget parent = this.getParent(); return parent == null || parent.isEnabled(); } @@ -407,7 +407,7 @@ public final void hide() { @Override public final boolean isVisible() { if (this.visible) { - IWidget parent = this.getParent(); + final IWidget parent = this.getParent(); return parent == null || parent.isVisible() && parent.isChildVisible(this); } return false; diff --git a/core/src/main/java/binnie/core/gui/minecraft/Window.java b/core/src/main/java/binnie/core/gui/minecraft/Window.java index 42bce42ba..6e8283cfb 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/Window.java +++ b/core/src/main/java/binnie/core/gui/minecraft/Window.java @@ -50,6 +50,7 @@ import binnie.core.resource.BinnieResource; import binnie.core.resource.IBinnieTexture; import binnie.core.resource.ResourceType; +import org.apache.commons.lang3.StringUtils; public abstract class Window extends TopLevelWidget implements INetwork.ReceiveGuiNBT { private final Side side; @@ -329,7 +330,7 @@ public BackgroundTexture(Window window, int i) { @Override @SideOnly(Side.CLIENT) public BinnieResource getTexture() { - return Binnie.RESOURCE.getPNG(window.getModId(), ResourceType.GUI, window.getBackgroundTextureName() + ((i == 1) ? "" : i)); + return Binnie.RESOURCE.getPNG(window.getModId(), ResourceType.GUI, window.getBackgroundTextureName() + ((i == 1) ? StringUtils.EMPTY : i)); } } } diff --git a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java index 2902ed660..51b33bc44 100644 --- a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java +++ b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java @@ -37,8 +37,8 @@ public void onResourceManagerReload(final IResourceManager manager) { sheets.clear(); try { for(Map.Entry entry : sheetLocations.entrySet()){ - ResourceLocation location = entry.getValue(); - StyleSheet styleSheet = StyleSheetParser.parseSheet(manager, location); + final ResourceLocation location = entry.getValue(); + final StyleSheet styleSheet = StyleSheetParser.parseSheet(manager, location); sheets.put(entry.getKey(), styleSheet); } } catch (Exception e) { @@ -48,7 +48,7 @@ public void onResourceManagerReload(final IResourceManager manager) { @SideOnly(Side.CLIENT) public static Texture getDefaultTexture(Object key) { - StyleSheet styleSheet = getDefaultSheet(); + final StyleSheet styleSheet = getDefaultSheet(); return styleSheet.getTexture(key); } diff --git a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java index eb37c1f39..8b2b72854 100644 --- a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java +++ b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java @@ -43,14 +43,14 @@ public class StyleSheetParser { @SideOnly(Side.CLIENT) public static StyleSheet parseSheet(IResourceManager manager, ResourceLocation location) { try { - IResource res = manager.getResource(location); - BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(res.getInputStream(), Charsets.UTF_8)); + final IResource res = manager.getResource(location); + final BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(res.getInputStream(), Charsets.UTF_8)); - JsonParser jsonParser = new JsonParser(); - JsonObject jsonObject = jsonParser.parse(bufferedreader).getAsJsonObject(); + final JsonParser jsonParser = new JsonParser(); + final JsonObject jsonObject = jsonParser.parse(bufferedreader).getAsJsonObject(); - Map textureSheets = parseTextureSheets(jsonObject); - Map textures = parseTextures(jsonObject, textureSheets); + final Map textureSheets = parseTextureSheets(jsonObject); + final Map textures = parseTextures(jsonObject, textureSheets); IOUtils.closeQuietly(bufferedreader); return new StyleSheet(textures); @@ -60,21 +60,21 @@ public static StyleSheet parseSheet(IResourceManager manager, ResourceLocation l } private static Map parseTextureSheets(JsonObject jsonObject){ - JsonArray textureSheetsArray = JsonUtils.getJsonArray(jsonObject, SHEETS_KEY); + final JsonArray textureSheetsArray = JsonUtils.getJsonArray(jsonObject, SHEETS_KEY); if(textureSheetsArray == null){ return Collections.emptyMap(); } - Map textureSheets = new HashMap<>(); - for (JsonElement element : textureSheetsArray) { + final Map textureSheets = new HashMap<>(); + for (final JsonElement element : textureSheetsArray) { if(!element.isJsonObject()){ continue; } try { - JsonObject sheetJson = (JsonObject) element; - String name = JsonUtils.getString(sheetJson, NAME_KEY); - String modid = JsonUtils.getString(sheetJson, MODID_KEY); - String path = JsonUtils.getString(sheetJson, PATH_KEY); - ParsedTextureSheet textureSheet = new ParsedTextureSheet(modid, path); + final JsonObject sheetJson = (JsonObject) element; + final String name = JsonUtils.getString(sheetJson, NAME_KEY); + final String modid = JsonUtils.getString(sheetJson, MODID_KEY); + final String path = JsonUtils.getString(sheetJson, PATH_KEY); + final ParsedTextureSheet textureSheet = new ParsedTextureSheet(modid, path); textureSheets.put(name, textureSheet); }catch(Exception e){ Log.warning("Failed to load stylesheet for Binnie's Mods.", e); @@ -84,22 +84,22 @@ private static Map parseTextureSheets(JsonObject jso } private static Map parseTextures(JsonObject jsonObject, Map textureSheets){ - JsonArray texturesJson = JsonUtils.getJsonArray(jsonObject, TEXTURES_KEY); + final JsonArray texturesJson = JsonUtils.getJsonArray(jsonObject, TEXTURES_KEY); if(texturesJson == null){ return Collections.emptyMap(); } - Map textures = new HashMap<>(); + final Map textures = new HashMap<>(); for (JsonElement element : texturesJson) { if(!element.isJsonObject()){ continue; } try { - JsonObject sheetJson = element.getAsJsonObject(); - String name = JsonUtils.getString(sheetJson, NAME_KEY); - String sheet = JsonUtils.getString(sheetJson, SHEET_KEY); - JsonArray uvArray = JsonUtils.getJsonArray(sheetJson, UV_KEY); - IBinnieTexture textureSheet = textureSheets.get(sheet); - Area uv = parseArea(uvArray); + final JsonObject sheetJson = element.getAsJsonObject(); + final String name = JsonUtils.getString(sheetJson, NAME_KEY); + final String sheet = JsonUtils.getString(sheetJson, SHEET_KEY); + final JsonArray uvArray = JsonUtils.getJsonArray(sheetJson, UV_KEY); + final IBinnieTexture textureSheet = textureSheets.get(sheet); + final Area uv = parseArea(uvArray); Border border = Border.ZERO; Border padding = Border.ZERO; if (sheetJson.has(BORDER_KEY)) { @@ -110,7 +110,7 @@ private static Map parseTextures(JsonObject jsonObject, Map parseTextures(JsonObject jsonObject, Map 4) { throw new JsonParseException("Parameter must have between one and four numbers"); } for(int i = 0;i < uvArray.size();i++){ - JsonElement object = uvArray.get(i); + final JsonElement object = uvArray.get(i); ints[i] = JsonUtils.getInt(object, "uv" + i); } if (ints.length == 1) { @@ -141,12 +141,12 @@ private static Area parseArea(JsonArray uvArray) { } private static Border parseBorder(JsonArray array) { - int[] ints = new int[array.size()]; + final int[] ints = new int[array.size()]; if (ints.length < 1 || ints.length > 4) { throw new JsonParseException("Parameter must have between one and four numbers"); } for(int i = 0;i < array.size();i++){ - JsonElement object = array.get(i); + final JsonElement object = array.get(i); ints[i] = JsonUtils.getInt(object, UV_KEY + i); } if (ints.length == 1) { diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index cb56c2826..29d787021 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -376,9 +376,9 @@ binniecore.gui.progress.title=Прогресс binniecore.gui.progress.no.progress=Не выполняется binniecore.gui.progress.in.progress=Выполняется binniecore.gui.progress.time.minute=%d минута -binniecore.gui.progress.time.minutes=%d минут +binniecore.gui.progress.time.minutes=%d мин. binniecore.gui.progress.time.second=%d секунда -binniecore.gui.progress.time.seconds=%d секунд +binniecore.gui.progress.time.seconds=%d сек. binniecore.gui.progress.time.left=Осталось времени: %s binniecore.gui.progress.time.total=Общее время: %s binniecore.gui.progress.energy.cost.total=Энергетические затраты: %s RF From fa368b1319f2c52bcfcd325809560b1183733533 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 16:35:28 +1000 Subject: [PATCH 50/99] Refactor getWidget() Remove: ``` //TODO: Why not use "this" ? public IWidget getWidget() { return this; } ``` --- core/src/main/java/binnie/core/gui/Widget.java | 5 ----- .../java/binnie/core/gui/controls/button/ControlButton.java | 2 +- .../main/java/binnie/core/gui/controls/tab/ControlTab.java | 2 +- .../java/binnie/core/gui/fieldkit/ControlChromoPicker.java | 4 ++-- .../binnie/core/gui/minecraft/control/ControlLiquidTank.java | 2 +- .../java/binnie/core/gui/minecraft/control/ControlSlot.java | 2 +- .../src/main/java/binnie/design/gui/ControlRecipeSlot.java | 4 ++-- .../src/main/java/binnie/design/gui/ControlTileSelect.java | 4 ++-- .../binnie/extratrees/kitchen/craftgui/ControlTankSlot.java | 2 +- .../distillery/window/ControlDistilleryProgress.java | 2 +- .../fruitpress/window/ControlFruitPressProgress.java | 4 ++-- .../java/binnie/genetics/machine/craftgui/ControlGene.java | 4 ++-- 12 files changed, 16 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/Widget.java b/core/src/main/java/binnie/core/gui/Widget.java index 73178e971..f62427d44 100644 --- a/core/src/main/java/binnie/core/gui/Widget.java +++ b/core/src/main/java/binnie/core/gui/Widget.java @@ -450,9 +450,4 @@ public final void updateClient() { public final void delete() { this.getTopParent().widgetDeleted(this); } - - //TODO: Why not use "this" ? - public IWidget getWidget() { - return this; - } } diff --git a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java index 1f514d752..9d27226af 100644 --- a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java +++ b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java @@ -25,7 +25,7 @@ public ControlButton(final IWidget parent, final int x, final int y, final int w super(parent, x, y, width, height); this.addAttribute(Attribute.MOUSE_OVER); this.addSelfEventHandler(EventMouse.Down.class, event -> { - ControlButton.this.callEvent(new EventButtonClicked(ControlButton.this.getWidget())); + ControlButton.this.callEvent(new EventButtonClicked(ControlButton.this)); ControlButton.this.onMouseClick(event); }); } diff --git a/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java b/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java index 577bc040b..d452891b2 100644 --- a/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java +++ b/core/src/main/java/binnie/core/gui/controls/tab/ControlTab.java @@ -31,7 +31,7 @@ public ControlTab(final int x, final int y, final int w, final int h, final T va this.value = value; this.addAttribute(Attribute.MOUSE_OVER); this.addSelfEventHandler(EventMouse.Down.class, event -> { - ControlTab.this.callEvent(new EventValueChanged(ControlTab.this.getWidget(), ControlTab.this.getValue())); + ControlTab.this.callEvent(new EventValueChanged(ControlTab.this, ControlTab.this.getValue())); }); } diff --git a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java index 8392e6fdf..f57fe421b 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java @@ -33,10 +33,10 @@ public ControlChromoPicker(ControlChromosome parent, int x, int y, IChromosomeTy addAttribute(Attribute.MOUSE_OVER); this.parent = parent; addSelfEventHandler(EventWidget.StartMouseOver.class, event -> { - callEvent(new EventValueChanged(getWidget(), type)); + callEvent(new EventValueChanged(this, type)); }); addSelfEventHandler(EventWidget.EndMouseOver.class, event -> { - callEvent(new EventValueChanged<>(getWidget(), null)); + callEvent(new EventValueChanged<>(this, null)); }); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java index 4fa065592..5c86efb0f 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java @@ -65,7 +65,7 @@ public ControlLiquidTank(IWidget parent, int x, int y, int tankID, boolean horiz if (event.getButton() == 0) { final NBTTagCompound nbt = new NBTTagCompound(); nbt.setByte("id", (byte) ControlLiquidTank.this.tankID); - Window.get(ControlLiquidTank.this.getWidget()).sendClientAction("tank-click", nbt); + Window.get(ControlLiquidTank.this).sendClientAction("tank-click", nbt); } }); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java index a032065a7..d1eaaacdd 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java @@ -65,7 +65,7 @@ public ControlSlot(final IWidget parent, final int x, final int y, final Slot sl final int windowId = superParent.getContainer().windowId; final int slotNumber = this.slot.slotNumber; final int button = event.getButton(); - Window.get(this.getWidget()).getGui(); + Window.get(this).getGui(); if (playerController != null) { boolean clone = mc.gameSettings.keyBindPickBlock.isActiveAndMatches(button - 100); ClickType clickType; diff --git a/design/src/main/java/binnie/design/gui/ControlRecipeSlot.java b/design/src/main/java/binnie/design/gui/ControlRecipeSlot.java index 9f8a6fcab..e2e400151 100644 --- a/design/src/main/java/binnie/design/gui/ControlRecipeSlot.java +++ b/design/src/main/java/binnie/design/gui/ControlRecipeSlot.java @@ -16,12 +16,12 @@ public class ControlRecipeSlot extends ControlSlotBase { public ControlRecipeSlot(final IWidget parent, final int x, final int y) { super(parent, x, y, 50); this.addSelfEventHandler(EventMouse.Down.class, event -> { - final TileEntity tile = (TileEntity) Window.get(ControlRecipeSlot.this.getWidget()).getInventory(); + final TileEntity tile = (TileEntity) Window.get(ControlRecipeSlot.this).getInventory(); if (!(tile instanceof TileEntityMachine)) { return; } final NBTTagCompound nbt = new NBTTagCompound(); - Window.get(ControlRecipeSlot.this.getWidget()).sendClientAction("recipe", nbt); + Window.get(ControlRecipeSlot.this).sendClientAction("recipe", nbt); }); this.setRotating(); } diff --git a/design/src/main/java/binnie/design/gui/ControlTileSelect.java b/design/src/main/java/binnie/design/gui/ControlTileSelect.java index b5615923a..9c0b7afc8 100644 --- a/design/src/main/java/binnie/design/gui/ControlTileSelect.java +++ b/design/src/main/java/binnie/design/gui/ControlTileSelect.java @@ -135,7 +135,7 @@ protected ControlTile(final IWidget parent, final int x, final int y, final IDes this.value = value; this.addAttribute(Attribute.MOUSE_OVER); this.addSelfEventHandler(EventMouse.Down.class, event -> { - final TileEntityMachine tile = (TileEntityMachine) Window.get(ControlTile.this.getWidget()).getInventory(); + final TileEntityMachine tile = (TileEntityMachine) Window.get(ControlTile.this).getInventory(); if (tile == null) { return; } @@ -143,7 +143,7 @@ protected ControlTile(final IWidget parent, final int x, final int y, final IDes ComponentDesignerRecipe recipe = tile.getMachine().getComponent(ComponentDesignerRecipe.class); final NBTTagCompound nbt = new NBTTagCompound(); nbt.setShort("d", (short) DesignAPI.manager.getDesignIndex(ControlTile.this.getValue())); - Window.get(ControlTile.this.getWidget()).sendClientAction("design", nbt); + Window.get(ControlTile.this).sendClientAction("design", nbt); }); } diff --git a/extratrees/src/main/java/binnie/extratrees/kitchen/craftgui/ControlTankSlot.java b/extratrees/src/main/java/binnie/extratrees/kitchen/craftgui/ControlTankSlot.java index 0c3699481..df2ab8438 100644 --- a/extratrees/src/main/java/binnie/extratrees/kitchen/craftgui/ControlTankSlot.java +++ b/extratrees/src/main/java/binnie/extratrees/kitchen/craftgui/ControlTankSlot.java @@ -20,7 +20,7 @@ public ControlTankSlot(final IWidget parent, final int x, final int y, final int if (event.getButton() == 0) { final NBTTagCompound nbt = new NBTTagCompound(); nbt.setByte("id", (byte) ControlTankSlot.this.tankID); - Window.get(ControlTankSlot.this.getWidget()).sendClientAction("tank-click", nbt); + Window.get(ControlTankSlot.this).sendClientAction("tank-click", nbt); } }); } diff --git a/extratrees/src/main/java/binnie/extratrees/machines/distillery/window/ControlDistilleryProgress.java b/extratrees/src/main/java/binnie/extratrees/machines/distillery/window/ControlDistilleryProgress.java index 0414dc685..9a5c3b0dd 100644 --- a/extratrees/src/main/java/binnie/extratrees/machines/distillery/window/ControlDistilleryProgress.java +++ b/extratrees/src/main/java/binnie/extratrees/machines/distillery/window/ControlDistilleryProgress.java @@ -43,7 +43,7 @@ protected ControlDistilleryProgress(final IWidget parent, final int x, final int if (distillationLevel >= 0) { final NBTTagCompound nbt = new NBTTagCompound(); nbt.setByte("i", (byte) distillationLevel); - Window.get(ControlDistilleryProgress.this.getWidget()).sendClientAction("still-level", nbt); + Window.get(ControlDistilleryProgress.this).sendClientAction("still-level", nbt); } }); } diff --git a/extratrees/src/main/java/binnie/extratrees/machines/fruitpress/window/ControlFruitPressProgress.java b/extratrees/src/main/java/binnie/extratrees/machines/fruitpress/window/ControlFruitPressProgress.java index e54da999e..c86d7875b 100644 --- a/extratrees/src/main/java/binnie/extratrees/machines/fruitpress/window/ControlFruitPressProgress.java +++ b/extratrees/src/main/java/binnie/extratrees/machines/fruitpress/window/ControlFruitPressProgress.java @@ -36,10 +36,10 @@ protected ControlFruitPressProgress(final IWidget parent, final int x, final int this.addSelfEventHandler(EventMouse.Down.class, event -> { if (event.getY() - event.getOrigin().getAbsolutePosition().yPos() > 52 + Math.round(16 * progress)) { final NBTTagCompound action = new NBTTagCompound(); - Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("clear-fruit", action); + Window.get(ControlFruitPressProgress.this).sendClientAction("clear-fruit", action); } else { final NBTTagCompound action = new NBTTagCompound(); - Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("fruitpress-click", action); + Window.get(ControlFruitPressProgress.this).sendClientAction("fruitpress-click", action); } }); } diff --git a/genetics/src/main/java/binnie/genetics/machine/craftgui/ControlGene.java b/genetics/src/main/java/binnie/genetics/machine/craftgui/ControlGene.java index 8b4e45050..7ff45dbef 100644 --- a/genetics/src/main/java/binnie/genetics/machine/craftgui/ControlGene.java +++ b/genetics/src/main/java/binnie/genetics/machine/craftgui/ControlGene.java @@ -31,12 +31,12 @@ protected ControlGene(final IWidget parent, final int x, final int y, final IGen this.gene = gene; this.addAttribute(Attribute.MOUSE_OVER); this.addSelfEventHandler(EventMouse.Down.class, event -> { - if (ControlGene.this.canFill(Window.get(ControlGene.this.getWidget()).getHeldItemStack())) { + if (ControlGene.this.canFill(Window.get(ControlGene.this).getHeldItemStack())) { final NBTTagCompound action = new NBTTagCompound(); final NBTTagCompound geneNBT = new NBTTagCompound(); ControlGene.this.getValue().writeToNBT(geneNBT); action.setTag("gene", geneNBT); - Window.get(ControlGene.this.getWidget()).sendClientAction("gene-select", action); + Window.get(ControlGene.this).sendClientAction("gene-select", action); } }); } From 64ed74f2ba0422290c07875a863f3ce3db908fa2 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 17:13:16 +1000 Subject: [PATCH 51/99] Use Constants.EXTRA_BEES_MOD_ID in ExtraBeesIntegration.java --- .../core/integration/extrabees/ExtraBeesIntegration.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/integration/extrabees/ExtraBeesIntegration.java b/core/src/main/java/binnie/core/integration/extrabees/ExtraBeesIntegration.java index 48ab91860..118283490 100644 --- a/core/src/main/java/binnie/core/integration/extrabees/ExtraBeesIntegration.java +++ b/core/src/main/java/binnie/core/integration/extrabees/ExtraBeesIntegration.java @@ -13,6 +13,7 @@ import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleSpecies; +import binnie.core.Constants; import binnie.core.IInitializable; public class ExtraBeesIntegration implements IInitializable { @@ -25,7 +26,7 @@ public class ExtraBeesIntegration implements IInitializable { private static Block hive; static { - loaded = Loader.isModLoaded("extrabees"); + loaded = Loader.isModLoaded(Constants.EXTRA_BEES_MOD_ID); } public static boolean isLoaded() { @@ -39,7 +40,7 @@ public void preInit() { @Override public void init() { - hive = Preconditions.checkNotNull(ForgeRegistries.BLOCKS.getValue(new ResourceLocation("extrabees", "hive"))); + hive = Preconditions.checkNotNull(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Constants.EXTRA_BEES_MOD_ID, "hive"))); } @Override From f06f9d44e09ae73d20f6caa8fb6593354c8ef749 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 17:41:41 +1000 Subject: [PATCH 52/99] Remove this.setUnlocalizedName("genesis"); already invoked in super --- core/src/main/java/binnie/core/item/ItemGenesis.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/item/ItemGenesis.java b/core/src/main/java/binnie/core/item/ItemGenesis.java index 414d85eb4..b0fcdb9b7 100644 --- a/core/src/main/java/binnie/core/item/ItemGenesis.java +++ b/core/src/main/java/binnie/core/item/ItemGenesis.java @@ -18,13 +18,12 @@ public class ItemGenesis extends ItemCore implements IGuiItem { public ItemGenesis() { super("genesis"); this.setCreativeTab(Tabs.tabApiculture); - this.setUnlocalizedName("genesis"); this.setMaxStackSize(1); } @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { - ItemStack itemStack = playerIn.getHeldItem(handIn); + final ItemStack itemStack = playerIn.getHeldItem(handIn); openGuiOnRightClick(itemStack, worldIn, playerIn); return new ActionResult<>(EnumActionResult.SUCCESS, itemStack); } From 555847fbf239a1b0b3b1fa910d3ecf84293f88e9 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 17:42:36 +1000 Subject: [PATCH 53/99] Remove this.setUnlocalizedName("field_kit"); already invoked in super --- core/src/main/java/binnie/core/item/ItemFieldKit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/binnie/core/item/ItemFieldKit.java b/core/src/main/java/binnie/core/item/ItemFieldKit.java index aef41cb34..886b9b3ff 100644 --- a/core/src/main/java/binnie/core/item/ItemFieldKit.java +++ b/core/src/main/java/binnie/core/item/ItemFieldKit.java @@ -32,7 +32,6 @@ public class ItemFieldKit extends ItemCore { public ItemFieldKit() { super("field_kit"); - this.setUnlocalizedName("field_kit"); this.setCreativeTab(CreativeTabs.TOOLS); this.setMaxStackSize(1); this.setMaxDamage(64); From 02f81faf991c374bd185731266300a6cf323d947 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 17:43:17 +1000 Subject: [PATCH 54/99] Remove this.setUnlocalizedName(name); already invoked in super --- core/src/main/java/binnie/core/item/ItemMisc.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/binnie/core/item/ItemMisc.java b/core/src/main/java/binnie/core/item/ItemMisc.java index 86cc9ed7f..3d8e66ee5 100644 --- a/core/src/main/java/binnie/core/item/ItemMisc.java +++ b/core/src/main/java/binnie/core/item/ItemMisc.java @@ -22,7 +22,6 @@ public ItemMisc(final CreativeTabs tab, final IItemMiscProvider[] items, String super(name); this.setCreativeTab(tab); this.setHasSubtypes(true); - this.setUnlocalizedName(name); this.items = items; } From c948c9e540dd8f25d4c3188b9c7460e7786b53ee Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 17:46:52 +1000 Subject: [PATCH 55/99] Add final to vars. --- core/src/main/java/binnie/core/item/ItemMisc.java | 8 ++++---- core/src/main/java/binnie/core/item/ModuleItems.java | 8 +++++--- core/src/main/java/binnie/core/liquid/AlcoholEffect.java | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/binnie/core/item/ItemMisc.java b/core/src/main/java/binnie/core/item/ItemMisc.java index 3d8e66ee5..5ed9f6da6 100644 --- a/core/src/main/java/binnie/core/item/ItemMisc.java +++ b/core/src/main/java/binnie/core/item/ItemMisc.java @@ -32,7 +32,7 @@ public ItemMisc(CreativeTabs tab, final IItemMiscProvider[] items) { @Override public void getSubItems(CreativeTabs tab, NonNullList items) { if (this.isInCreativeTab(tab)) { - for (IItemMiscProvider item : this.items) { + for (final IItemMiscProvider item : this.items) { if (item.isActive()) { items.add(this.getStack(item, 1)); } @@ -52,21 +52,21 @@ public ItemStack getStack(IItemMiscProvider type, int size) { @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); - IItemMiscProvider item = this.getItem(stack.getItemDamage()); + final IItemMiscProvider item = this.getItem(stack.getItemDamage()); item.addInformation(tooltip); } @SideOnly(Side.CLIENT) @Override public void registerModel(Item item, IModelManager manager) { - for (IItemMiscProvider type : items) { + for (final IItemMiscProvider type : items) { manager.registerItemModel(item, type.ordinal(), "misc/" + type.getModelPath()); } } @Override public String getItemStackDisplayName(final ItemStack stack) { - IItemMiscProvider item = this.getItem(stack.getItemDamage()); + final IItemMiscProvider item = this.getItem(stack.getItemDamage()); return item.getDisplayName(stack); } } diff --git a/core/src/main/java/binnie/core/item/ModuleItems.java b/core/src/main/java/binnie/core/item/ModuleItems.java index 7e491070b..d8b97b2e7 100644 --- a/core/src/main/java/binnie/core/item/ModuleItems.java +++ b/core/src/main/java/binnie/core/item/ModuleItems.java @@ -1,6 +1,7 @@ package binnie.core.item; import binnie.core.Constants; +import binnie.core.proxy.BinnieProxy; import binnie.core.util.RecipeUtil; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -12,10 +13,11 @@ public class ModuleItems implements IInitializable { @Override public void preInit() { + final BinnieProxy proxy = BinnieCore.getBinnieProxy(); BinnieCore.setFieldKit(new ItemFieldKit()); - BinnieCore.getBinnieProxy().registerItem(BinnieCore.getFieldKit()); + proxy.registerItem(BinnieCore.getFieldKit()); BinnieCore.setGenesis(new ItemGenesis()); - BinnieCore.getBinnieProxy().registerItem(BinnieCore.getGenesis()); + proxy.registerItem(BinnieCore.getGenesis()); } @Override @@ -24,7 +26,7 @@ public void init() { @Override public void postInit() { - RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); + final RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); recipeUtil.addRecipe("field_kit", new ItemStack(BinnieCore.getFieldKit(), 1, 63), "g ", " is", " pi", 'g', Blocks.GLASS_PANE, 'i', Items.IRON_INGOT, 'p', Items.PAPER, 's', new ItemStack(Items.DYE, 1)); } } diff --git a/core/src/main/java/binnie/core/liquid/AlcoholEffect.java b/core/src/main/java/binnie/core/liquid/AlcoholEffect.java index 1d43c2488..95be24f0d 100644 --- a/core/src/main/java/binnie/core/liquid/AlcoholEffect.java +++ b/core/src/main/java/binnie/core/liquid/AlcoholEffect.java @@ -6,7 +6,7 @@ public class AlcoholEffect { public static void makeDrunk(final EntityPlayer player, final float strength) { - PotionEffect potionEffect = player.getActivePotionEffect(MobEffects.NAUSEA); + final PotionEffect potionEffect = player.getActivePotionEffect(MobEffects.NAUSEA); final int existingStrength = potionEffect != null ? potionEffect.getAmplifier() : 0; final int existingTime = potionEffect != null ? potionEffect.getDuration() : 0; int time = (int) (100.0 * Math.sqrt(strength)) + existingTime; From 2127146693962ed352556ed5b0d46b4879c47f49 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 18:16:44 +1000 Subject: [PATCH 56/99] Small refactoring in FluidContainerType.java --- .../main/java/binnie/core/liquid/FluidContainerType.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/binnie/core/liquid/FluidContainerType.java b/core/src/main/java/binnie/core/liquid/FluidContainerType.java index 8281452a1..206a778c9 100644 --- a/core/src/main/java/binnie/core/liquid/FluidContainerType.java +++ b/core/src/main/java/binnie/core/liquid/FluidContainerType.java @@ -35,7 +35,7 @@ public String getName() { } public String getDisplayName() { - return I18N.localise("binniecore.item.container." + this.name().toLowerCase()); + return I18N.localise("binniecore.item.container." + this.getName()); } public void setItem(ItemFluidContainer item) { @@ -75,11 +75,10 @@ public ItemStack getEmpty() { } public ItemStack getFilled(Fluid fluid) { - ItemStack stack = getEmpty(); - stack = stack.copy(); - IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack); + final ItemStack stack = getEmpty(); + final IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack); if (fluidHandler != null) { - int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true); + final int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true); if (fill > 0) { return stack; } From f88d84e803f9ed04b4036f572f0db8ede9280a52 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 18:19:47 +1000 Subject: [PATCH 57/99] Add @Nullable annotation in FluidHandlerItemBinnie.java --- .../binnie/core/liquid/FluidHandlerItemBinnie.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java b/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java index 6d80e00e4..5e9c6237e 100644 --- a/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java +++ b/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java @@ -6,6 +6,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple; +import javax.annotation.Nullable; + public class FluidHandlerItemBinnie extends FluidHandlerItemStackSimple { private final FluidContainerType containerType; @@ -14,12 +16,12 @@ public class FluidHandlerItemBinnie extends FluidHandlerItemStackSimple { this.containerType = containerType; } - private boolean contentsAllowed(FluidStack fluidStack) { + private boolean contentsAllowed(@Nullable FluidStack fluidStack) { if (fluidStack == null) { return false; } - Fluid fluid = fluidStack.getFluid(); + final Fluid fluid = fluidStack.getFluid(); if (fluid == null) { return false; } @@ -33,12 +35,12 @@ private boolean contentsAllowed(FluidStack fluidStack) { } @Override - public boolean canFillFluidType(FluidStack fluid) { + public boolean canFillFluidType(@Nullable FluidStack fluid) { return contentsAllowed(fluid); } @Override - public boolean canDrainFluidType(FluidStack fluid) { + public boolean canDrainFluidType(@Nullable FluidStack fluid) { return contentsAllowed(fluid); } From 7e4bd23a985e4adb7131550ce6e28bb673aed4a6 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 18:21:15 +1000 Subject: [PATCH 58/99] Add final to vars. --- core/src/main/java/binnie/core/liquid/FluidType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/liquid/FluidType.java b/core/src/main/java/binnie/core/liquid/FluidType.java index 97dc3fc48..c9b7bdfe6 100644 --- a/core/src/main/java/binnie/core/liquid/FluidType.java +++ b/core/src/main/java/binnie/core/liquid/FluidType.java @@ -25,7 +25,7 @@ public FluidType(String identifier, String unlocalizedName, int color) { this.unlocalizedName = unlocalizedName.toLowerCase(); this.color = color; this.containerColor = color; - ResourceLocation texture = new ResourceLocation(Constants.CORE_MOD_ID, "blocks/liquids/blank"); + final ResourceLocation texture = new ResourceLocation(Constants.CORE_MOD_ID, "blocks/liquids/blank"); this.textureFlowing = texture; this.textureStill = texture; } From f1b0babb47ece55c3f63607f6a59c71ef788cfb0 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sun, 8 Apr 2018 18:32:33 +1000 Subject: [PATCH 59/99] Improve FluidContainerType.java and ItemFluidContainer.java localizing. --- .../main/java/binnie/core/liquid/FluidContainerType.java | 3 ++- .../main/java/binnie/core/liquid/ItemFluidContainer.java | 6 ++++-- core/src/main/resources/assets/binniecore/lang/en_US.lang | 1 + core/src/main/resources/assets/binniecore/lang/ru_RU.lang | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/liquid/FluidContainerType.java b/core/src/main/java/binnie/core/liquid/FluidContainerType.java index 206a778c9..babd9ea72 100644 --- a/core/src/main/java/binnie/core/liquid/FluidContainerType.java +++ b/core/src/main/java/binnie/core/liquid/FluidContainerType.java @@ -10,6 +10,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import binnie.core.Mods; +import binnie.core.ModId; import binnie.core.util.I18N; public enum FluidContainerType { @@ -35,7 +36,7 @@ public String getName() { } public String getDisplayName() { - return I18N.localise("binniecore.item.container." + this.getName()); + return I18N.localise( ModId.CORE, "item.container." + this.getName()); } public void setItem(ItemFluidContainer item) { diff --git a/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java b/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java index 732d5d20d..45e3b45c7 100644 --- a/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java +++ b/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java @@ -34,6 +34,8 @@ import forestry.api.core.IModelManager; import binnie.core.Binnie; +import binnie.core.ModId; +import binnie.core.util.I18N; public class ItemFluidContainer extends ItemFood implements IItemModelRegister { private final FluidContainerType container; @@ -51,9 +53,9 @@ public ItemFluidContainer(FluidContainerType container) { @Override public String getItemStackDisplayName(final ItemStack itemstack) { - FluidStack fluid = getContained(itemstack); + final FluidStack fluid = getContained(itemstack); if (fluid == null) { - return "Empty " + container.getDisplayName(); + return I18N.localise(ModId.CORE, "item.container.empty", container.getDisplayName()); } return fluid.getFluid().getLocalizedName(fluid) + ' ' + this.container.getDisplayName(); } diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index 89b9b5dea..b6aa76f55 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -182,6 +182,7 @@ binniecore.gui.breedingmessage.species=Species Discovered binniecore.gui.breedingmessage.branch=Branch Discovered binniecore.gui.breedingmessage.epithet=Epithet Gained +binniecore.item.container.empty=Empty %s binniecore.item.container.capsule=Capsule binniecore.item.container.refractory=Capsule binniecore.item.container.can=Can diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 29d787021..c537296eb 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -182,6 +182,7 @@ binniecore.gui.breedingmessage.species=Обнаруженные виды binniecore.gui.breedingmessage.branch=Обнаруженные ветви binniecore.gui.breedingmessage.epithet=Эпитет получен +binniecore.item.container.empty=%s без жидкости binniecore.item.container.capsule=Капсула binniecore.item.container.refractory=Капсула binniecore.item.container.can=Капсула From 96bd7d89d039e7132098e070d108d067810c2d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 09:25:59 +1000 Subject: [PATCH 60/99] Add final and some refactoring in ManagerLiquid.java --- .../core/integration/jei/CoreJeiPlugin.java | 2 +- .../core/liquid/FluidHandlerItemBinnie.java | 4 ++-- .../binnie/core/liquid/ManagerLiquid.java | 20 +++++++++---------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java b/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java index 45958f2e4..151eab4f0 100644 --- a/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java +++ b/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java @@ -28,7 +28,7 @@ public Class getGuiContainerClass() { @Nullable @Override public Object getIngredientUnderMouse(GuiCraftGUI guiContainer, int mouseX, int mouseY) { - IWidget widgetUnderMouse = guiContainer.getWidgetUnderMouse(); + final IWidget widgetUnderMouse = guiContainer.getWidgetUnderMouse(); if (widgetUnderMouse != null) { return widgetUnderMouse.getIngredient(); } diff --git a/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java b/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java index 5e9c6237e..eb43fdb00 100644 --- a/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java +++ b/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java @@ -27,8 +27,8 @@ private boolean contentsAllowed(@Nullable FluidStack fluidStack) { } if (fluid instanceof BinnieFluid) { - BinnieFluid binnieFluid = (BinnieFluid) fluid; - FluidType definition = binnieFluid.getType(); + final BinnieFluid binnieFluid = (BinnieFluid) fluid; + final FluidType definition = binnieFluid.getType(); return definition.canPlaceIn(containerType); } return false; diff --git a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java index becc8759f..02f7211b1 100644 --- a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java +++ b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java @@ -37,20 +37,18 @@ public ManagerLiquid() { } public void createLiquids(IFluidDefinition[] liquids) { - for (IFluidDefinition liquid : liquids) { - FluidType type = liquid.getType(); + for (final IFluidDefinition liquid : liquids) { + final FluidType type = liquid.getType(); final BinnieFluid fluid = this.createLiquid(type); - if (fluid == null) { - Log.error("Liquid registered incorrectly - {} ", type.getIdentifier()); - } } } - private BinnieFluid createLiquid(FluidType fluid) { + private BinnieFluid createLiquid(final FluidType fluid) { this.fluids.put(fluid.getIdentifier().toLowerCase(), fluid); final BinnieFluid bFluid = new BinnieFluid(fluid); - FluidRegistry.registerFluid(bFluid); - FluidRegistry.addBucketForFluid(bFluid); + if ((!FluidRegistry.registerFluid(bFluid)) || (FluidRegistry.addBucketForFluid(bFluid))) { + Log.error("Liquid registered incorrectly - {} ", fluid.getIdentifier()); + } return bFluid; } @@ -70,7 +68,7 @@ public void init() { @Override public void postInit() { - RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); + final RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); recipeUtil.addShapelessRecipe("glass_container_conversion", FluidContainerType.GLASS.get(1), Items.GLASS_BOTTLE); recipeUtil.addShapelessRecipe("glass_bottle_conversion", new ItemStack(Items.GLASS_BOTTLE), FluidContainerType.GLASS.get(1)); recipeUtil.addRecipe("glass_container", FluidContainerType.GLASS.get(3), @@ -82,8 +80,8 @@ public void postInit() { @SubscribeEvent @SideOnly(Side.CLIENT) public void registerSprites(TextureStitchEvent event) { - TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); - for (FluidType definition : fluids.values()) { + final TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); + for (final FluidType definition : fluids.values()) { textureMap.registerSprite(definition.getFlowing()); textureMap.registerSprite(definition.getStill()); } From a8b4f61d15ae3e2144bb55a1fd172bbdf58b166e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 09:27:56 +1000 Subject: [PATCH 61/99] ManagerLiquid.java --- core/src/main/java/binnie/core/liquid/ManagerLiquid.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java index 02f7211b1..bde6251f2 100644 --- a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java +++ b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java @@ -39,18 +39,17 @@ public ManagerLiquid() { public void createLiquids(IFluidDefinition[] liquids) { for (final IFluidDefinition liquid : liquids) { final FluidType type = liquid.getType(); - final BinnieFluid fluid = this.createLiquid(type); + this.createLiquid(type); } } - private BinnieFluid createLiquid(final FluidType fluid) { + private void createLiquid(final FluidType fluid) { this.fluids.put(fluid.getIdentifier().toLowerCase(), fluid); final BinnieFluid bFluid = new BinnieFluid(fluid); if ((!FluidRegistry.registerFluid(bFluid)) || (FluidRegistry.addBucketForFluid(bFluid))) { Log.error("Liquid registered incorrectly - {} ", fluid.getIdentifier()); } - return bFluid; - } + } @Nullable public FluidStack getFluidStack(final String name, final int amount) { From d91181d64c856d284e4b3ae44d4b5fccc4b514dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 09:57:42 +1000 Subject: [PATCH 62/99] Add @Nullable annotation in ITankMachine.java --- .../src/main/java/binnie/core/machines/power/ITankMachine.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/binnie/core/machines/power/ITankMachine.java b/core/src/main/java/binnie/core/machines/power/ITankMachine.java index b3212abe2..8924722fa 100644 --- a/core/src/main/java/binnie/core/machines/power/ITankMachine.java +++ b/core/src/main/java/binnie/core/machines/power/ITankMachine.java @@ -20,10 +20,13 @@ public interface ITankMachine extends IValidatedTankContainer { * @deprecated use {@link #addTank(int, ResourceLocation, int)} */ @Deprecated + @Nullable TankSlot addTank(final int index, final String name, final int capacity); + @Nullable TankSlot addTank(final int index, final ResourceLocation name, final int capacity); + @Nullable IFluidTank getTank(final int index); @Nullable From 5a0ba07dc5ee07799c38019951bf0fac188501f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 09:59:41 +1000 Subject: [PATCH 63/99] Add final to vars in TileEntityMachineBase.java --- .../java/binnie/core/machines/base/TileEntityMachineBase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java b/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java index 69645c12d..1c865438a 100644 --- a/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java +++ b/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java @@ -196,10 +196,10 @@ public T getCapability(Capability capability, @Nullable EnumFacing facing return CapabilityEnergy.ENERGY.cast(this); } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (facing != null) { - SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(getInventory(), facing); + final SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(getInventory(), facing); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(sidedInvWrapper); } else { - InvWrapper invWrapper = new InvWrapper(getInventory()); + final InvWrapper invWrapper = new InvWrapper(getInventory()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(invWrapper); } } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { From 989164b8113e20745bb2ab2db51112d0848bbf59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 10:03:25 +1000 Subject: [PATCH 64/99] Add final to vars in ErrorState.java --- .../core/machines/errors/ErrorState.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/errors/ErrorState.java b/core/src/main/java/binnie/core/machines/errors/ErrorState.java index ad99ef276..483ec7b69 100644 --- a/core/src/main/java/binnie/core/machines/errors/ErrorState.java +++ b/core/src/main/java/binnie/core/machines/errors/ErrorState.java @@ -29,24 +29,24 @@ public class ErrorState implements INbtReadable, INbtWritable { private boolean tankError; private boolean powerError; - public ErrorState(IErrorStateDefinition definition) { + public ErrorState(final IErrorStateDefinition definition) { this(definition, definition); } - public ErrorState(IErrorStateDefinition definition, int[] data) { + public ErrorState(final IErrorStateDefinition definition, final int[] data) { this(definition, definition, data); } - public ErrorState(IErrorStateDefinition definition, int data) { + public ErrorState(final IErrorStateDefinition definition, final int data) { this(definition, definition, new int[]{data}); } - public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition) { + public ErrorState(final IErrorStateDefinition nameDefinition, final IErrorStateDefinition definition) { this(nameDefinition, definition, EmptyHelper.INT_ARRAY_EMPTY); } - public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition, int[] data) { - EnumErrorType type = definition.getType(); + public ErrorState(final IErrorStateDefinition nameDefinition, final IErrorStateDefinition definition, final int[] data) { + final EnumErrorType type = definition.getType(); this.data = data; this.itemError = type.isItemError(); this.tankError = type.isTankError(); @@ -75,12 +75,12 @@ public String getTooltip() { } public String getTooltip(ContainerCraftGUI container) { - Collection slots = getCustomSlots(container); - Set> validators = new HashSet<>(); - for (CustomSlot slot : slots) { - InventorySlot inventorySlot = slot.getInventorySlot(); + final Collection slots = getCustomSlots(container); + final Set> validators = new HashSet<>(); + for (final CustomSlot slot : slots) { + final InventorySlot inventorySlot = slot.getInventorySlot(); if (inventorySlot != null) { - SlotValidator validator = inventorySlot.getValidator(); + final SlotValidator validator = inventorySlot.getValidator(); if (validator != null) { validators.add(validator); } @@ -133,9 +133,9 @@ public boolean isPowerError() { } public Collection getCustomSlots(ContainerCraftGUI container) { - Collection slots = new ArrayList<>(); + final Collection slots = new ArrayList<>(); if (isItemError()) { - IntSet slotNumbers = new IntArraySet(getData()); + final IntSet slotNumbers = new IntArraySet(getData()); for (final CustomSlot cslot : container.getCustomSlots()) { if (!(cslot.inventory instanceof InventoryPlayer) && slotNumbers.contains(cslot.getSlotIndex())) { slots.add(cslot); From cd1f24e333d0b975e383b9fc103eb25ce955d368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 10:08:03 +1000 Subject: [PATCH 65/99] Remove unused anymore setOutputSides in BaseSlot.java --- .../binnie/core/machines/errors/ErrorStateRegistry.java | 2 +- .../main/java/binnie/core/machines/inventory/BaseSlot.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java b/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java index f59323d3f..f7dfdca0c 100644 --- a/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java +++ b/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java @@ -7,7 +7,7 @@ public class ErrorStateRegistry { private static final Map states = new HashMap<>(); public static void registerErrorState(IErrorStateDefinition state) { - String uid = state.getUID(); + final String uid = state.getUID(); if (!uid.contains(":")) { throw new RuntimeException("Binnie Error State name must be in the format :."); } diff --git a/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java b/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java index 6c39dd987..297699cb4 100644 --- a/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java @@ -91,12 +91,6 @@ public Collection getOutputSides() { return this.access.getExtractionSides(); } - public void setOutputSides(final EnumSet sides) { - for (final EnumFacing side : EnumSet.complementOf(sides)) { - this.access.setExtract(side, false); - } - } - public abstract String getName(); @Nullable From 389c08aff2c06a7caea6ace9d6f7c8a551ad1b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 10:47:58 +1000 Subject: [PATCH 66/99] Add final to vars and StringUtils.Empty for "" --- .../core/machines/base/DefaultInventory.java | 6 ++- .../inventory/ComponentChargedSlots.java | 2 +- .../inventory/ComponentInventory.java | 2 +- .../inventory/ComponentInventorySlots.java | 40 ++++++++++--------- .../machines/inventory/InventorySlot.java | 4 +- .../core/machines/inventory/TankSlot.java | 3 +- .../binnie/core/machines/power/TankInfo.java | 3 +- .../core/machines/storage/SearchDialog.java | 3 +- .../binnie/core/models/AABBModelBaker.java | 3 +- .../binnie/core/modules/BinnieModule.java | 6 ++- .../main/java/binnie/core/modules/Module.java | 4 +- .../java/binnie/core/proxy/I18NClient.java | 3 +- .../java/binnie/core/proxy/I18NServer.java | 3 +- .../java/binnie/core/util/FluidStackUtil.java | 29 ++++++++------ 14 files changed, 65 insertions(+), 46 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/base/DefaultInventory.java b/core/src/main/java/binnie/core/machines/base/DefaultInventory.java index 38182de6d..2b68cd65b 100644 --- a/core/src/main/java/binnie/core/machines/base/DefaultInventory.java +++ b/core/src/main/java/binnie/core/machines/base/DefaultInventory.java @@ -6,6 +6,8 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; +import org.apache.commons.lang3.StringUtils; + class DefaultInventory implements IInventory { @Override public int getSizeInventory() { @@ -88,7 +90,7 @@ public void clear() { @Override public String getName() { - return ""; + return StringUtils.EMPTY; } @Override @@ -98,6 +100,6 @@ public boolean hasCustomName() { @Override public ITextComponent getDisplayName() { - return new TextComponentString(""); + return new TextComponentString(StringUtils.EMPTY); } } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java b/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java index 0ad480031..462f71c1a 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java @@ -32,7 +32,7 @@ public void readFromNBT(final NBTTagCompound nbttagcompound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) { - NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); + final NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); final NBTTagList chargeList = new NBTTagList(); for (final Map.Entry entry : this.charges.entrySet()) { final NBTTagCompound chargesNBT = new NBTTagCompound(); diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java index 7eb69c9d4..85a2ef1fa 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java @@ -12,7 +12,7 @@ public ComponentInventory(final IMachine machine) { @Override public void markDirty() { - IMachine machine = this.getMachine(); + final IMachine machine = this.getMachine(); machine.markDirty(); } } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java index 4d8aca1de..c42321cd5 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java @@ -1,5 +1,7 @@ package binnie.core.machines.inventory; +import org.apache.commons.lang3.StringUtils; + import javax.annotation.Nullable; import java.util.Arrays; import java.util.LinkedHashMap; @@ -34,12 +36,12 @@ public ComponentInventorySlots(final IMachine machine) { } @Override - public ItemStack removeStackFromSlot(int index) { - InventorySlot slot = getInternalSlot(index); + public ItemStack removeStackFromSlot(final int index) { + final InventorySlot slot = getInternalSlot(index); if(slot.isFake()){ return ItemStack.EMPTY; } - ItemStack content = slot.getItemStack(); + final ItemStack content = slot.getItemStack(); slot.setContent(ItemStack.EMPTY); this.markDirty(); return content; @@ -69,8 +71,8 @@ public ItemStack getStackInSlot(final int index) { @Override public ItemStack decrStackSize(final int index, final int amount) { - InventorySlot slot = getInternalSlot(index); - ItemStack stack = slot.decrStackSize(amount); + final InventorySlot slot = getInternalSlot(index); + final ItemStack stack = slot.decrStackSize(amount); if (!stack.isEmpty()) { this.markDirty(); } @@ -79,7 +81,7 @@ public ItemStack decrStackSize(final int index, final int amount) { @Override public void setInventorySlotContents(int index, ItemStack itemStack) { - InventorySlot slot = getInternalSlot(index); + final InventorySlot slot = getInternalSlot(index); if (!slot.isFake() && (itemStack.isEmpty() || slot.isValid(itemStack))) { slot.setContent(itemStack); this.markDirty(); @@ -95,7 +97,7 @@ public boolean isEmpty() { public void readFromNBT(final NBTTagCompound compound) { super.readFromNBT(compound); NBTUtil.readFromList(compound, INVENTORY_KEY, (slotNBT) -> { - int index = slotNBT.getInteger(INDEX_KEY); + final int index = slotNBT.getInteger(INDEX_KEY); InventorySlot slot = getInternalSlot(index); slot.readFromNBT(slotNBT); }); @@ -115,7 +117,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound compound) { } public final InventorySlot addSlot(final int index, final ResourceLocation unlocLocation) { - InventorySlot slot = new InventorySlot(index, unlocLocation); + final InventorySlot slot = new InventorySlot(index, unlocLocation); this.inventory.put(index, slot); return slot; } @@ -125,7 +127,7 @@ public final InventorySlot addSlot(final int index, final ResourceLocation unloc */ @Deprecated public final InventorySlot addSlot(final int index, final String unlocName) { - ResourceLocation unlocLocation = new ResourceLocation(Constants.CORE_MOD_ID, "gui.slot." + unlocName); + final ResourceLocation unlocLocation = new ResourceLocation(Constants.CORE_MOD_ID, "gui.slot." + unlocName); return addSlot(index, unlocLocation); } @@ -170,18 +172,18 @@ public boolean hasCustomName() { @Override public boolean isItemValidForSlot(final int index, final ItemStack itemStack) { - InventorySlot slot = this.getSlot(index); + final InventorySlot slot = this.getSlot(index); return slot != null && (slot.isValid(itemStack) && !this.isReadOnly(index)); } @Override public void onDestruction() { - IMachine machine = getMachine(); - World world = machine.getWorld(); - Random rand = world.rand; - BlockPos pos = machine.getTileEntity().getPos(); - for (InventorySlot slot : this.inventory.values()) { - ItemStack stack = slot.getItemStack(); + final IMachine machine = getMachine(); + final World world = machine.getWorld(); + final Random rand = world.rand; + final BlockPos pos = machine.getTileEntity().getPos(); + for (final InventorySlot slot : this.inventory.values()) { + final ItemStack stack = slot.getItemStack(); if (slot.isRecipe() || stack.isEmpty()) { continue; } @@ -211,19 +213,19 @@ public boolean canInsertItem(final int index, final ItemStack itemstack, final E if (!isItemValidForSlot(index, itemstack)) { return false; } - InventorySlot slot = this.getSlot(index); + final InventorySlot slot = this.getSlot(index); return slot != null && slot.canInsert(direction); } @Override public boolean canExtractItem(final int index, final ItemStack itemstack, final EnumFacing direction) { - InventorySlot slot = this.getSlot(index); + final InventorySlot slot = this.getSlot(index); return slot != null && slot.canExtract(direction); } @Override public String getName() { - return ""; + return StringUtils.EMPTY; } @Override diff --git a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java index 1554b72b2..ef29315fc 100644 --- a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java @@ -1,5 +1,7 @@ package binnie.core.machines.inventory; +import org.apache.commons.lang3.StringUtils; + import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; @@ -96,7 +98,7 @@ public String getName() { return I18N.localise(ModId.CORE, "gui.slot.validated", validator.getTooltip()); } if (this.unlocLocation == null) { - return ""; + return StringUtils.EMPTY; } return I18N.localise(this.unlocLocation); } diff --git a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java index 4f76354c3..acf729c49 100644 --- a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java @@ -1,6 +1,7 @@ package binnie.core.machines.inventory; import javax.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; @@ -59,7 +60,7 @@ public String getName() { return I18N.localise(ModId.CORE, "gui.tank.validated", validator.getTooltip()); } if (this.unlocLocation == null) { - return ""; + return StringUtils.EMPTY; } return I18N.localise(this.unlocLocation); } diff --git a/core/src/main/java/binnie/core/machines/power/TankInfo.java b/core/src/main/java/binnie/core/machines/power/TankInfo.java index 6e56edf6e..746148568 100644 --- a/core/src/main/java/binnie/core/machines/power/TankInfo.java +++ b/core/src/main/java/binnie/core/machines/power/TankInfo.java @@ -1,6 +1,7 @@ package binnie.core.machines.power; import javax.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; import net.minecraft.nbt.NBTTagCompound; @@ -46,7 +47,7 @@ public boolean isEmpty() { } public String getName() { - return (this.liquid == null) ? "" : this.liquid.getFluid().getLocalizedName(this.liquid); + return (this.liquid == null) ? StringUtils.EMPTY : this.liquid.getFluid().getLocalizedName(this.liquid); } @Override diff --git a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java index 3fac57df3..6fff57831 100644 --- a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java +++ b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java @@ -26,12 +26,13 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.StringUtils; @SideOnly(Side.CLIENT) public class SearchDialog extends Dialog { private final Control slotGrid; private final WindowCompartment windowCompartment; - private String textSearch = ""; + private String textSearch = StringUtils.EMPTY; private boolean sortByName; private boolean includeItems; private boolean includeBlocks; diff --git a/core/src/main/java/binnie/core/models/AABBModelBaker.java b/core/src/main/java/binnie/core/models/AABBModelBaker.java index 3be231457..1593c44dd 100644 --- a/core/src/main/java/binnie/core/models/AABBModelBaker.java +++ b/core/src/main/java/binnie/core/models/AABBModelBaker.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import net.minecraft.block.Block; @@ -223,7 +224,7 @@ public IModelBakerModel bakeModel(boolean flip) { final float[] uvs = getFaceUvs(myFace, to, from); final BlockFaceUV uv = new BlockFaceUV(uvs, 0); - final BlockPartFace bpf = new BlockPartFace(myFace, face.colorIndex, "", uv); + final BlockPartFace bpf = new BlockPartFace(myFace, face.colorIndex, StringUtils.EMPTY, uv); BakedQuad bf = faceBakery.makeBakedQuad(from, to, bpf, face.spite, myFace, mr, null, true, true); diff --git a/core/src/main/java/binnie/core/modules/BinnieModule.java b/core/src/main/java/binnie/core/modules/BinnieModule.java index cacec4efa..6a383f37a 100644 --- a/core/src/main/java/binnie/core/modules/BinnieModule.java +++ b/core/src/main/java/binnie/core/modules/BinnieModule.java @@ -1,5 +1,7 @@ package binnie.core.modules; +import org.apache.commons.lang3.StringUtils; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -29,11 +31,11 @@ /** * @return Version of the module, if any. */ - String version() default ""; + String version() default StringUtils.EMPTY; /** * @return Localization key for a short description what the module does. */ - String unlocalizedDescription() default ""; + String unlocalizedDescription() default StringUtils.EMPTY; } diff --git a/core/src/main/java/binnie/core/modules/Module.java b/core/src/main/java/binnie/core/modules/Module.java index 6b8c8ae85..21f784822 100644 --- a/core/src/main/java/binnie/core/modules/Module.java +++ b/core/src/main/java/binnie/core/modules/Module.java @@ -1,11 +1,13 @@ package binnie.core.modules; +import org.apache.commons.lang3.StringUtils; + import java.util.Collections; import java.util.Set; public interface Module { default String getFailMessage(){ - return ""; + return StringUtils.EMPTY; } default Set getDependencyUids(){ diff --git a/core/src/main/java/binnie/core/proxy/I18NClient.java b/core/src/main/java/binnie/core/proxy/I18NClient.java index c931a1d3a..f7adb1269 100644 --- a/core/src/main/java/binnie/core/proxy/I18NClient.java +++ b/core/src/main/java/binnie/core/proxy/I18NClient.java @@ -7,6 +7,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.StringUtils; @SideOnly(Side.CLIENT) public class I18NClient implements I18NProxy { @@ -15,7 +16,7 @@ public class I18NClient implements I18NProxy { public String localiseOrBlank(String key) { String trans = localise(key); - return trans.equals(key) ? "" : trans; + return trans.equals(key) ? StringUtils.EMPTY : trans; } public String localise(String key) { diff --git a/core/src/main/java/binnie/core/proxy/I18NServer.java b/core/src/main/java/binnie/core/proxy/I18NServer.java index d8c3f60ab..4e054f470 100644 --- a/core/src/main/java/binnie/core/proxy/I18NServer.java +++ b/core/src/main/java/binnie/core/proxy/I18NServer.java @@ -6,6 +6,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.StringUtils; import java.util.IllegalFormatException; @@ -14,7 +15,7 @@ public class I18NServer implements I18NProxy { public String localiseOrBlank(String key) { String trans = localise(key); - return trans.equals(key) ? "" : trans; + return trans.equals(key) ? StringUtils.EMPTY : trans; } public String localise(String key) { diff --git a/core/src/main/java/binnie/core/util/FluidStackUtil.java b/core/src/main/java/binnie/core/util/FluidStackUtil.java index 42086d0fb..fffb3f413 100644 --- a/core/src/main/java/binnie/core/util/FluidStackUtil.java +++ b/core/src/main/java/binnie/core/util/FluidStackUtil.java @@ -1,5 +1,7 @@ package binnie.core.util; +import org.apache.commons.lang3.StringUtils; + import javax.annotation.Nullable; import java.util.Collection; @@ -14,17 +16,18 @@ public class FluidStackUtil { - public static String toString(FluidStack fluidStack){ - if(fluidStack == null){ + public static String toString(@Nullable final FluidStack fluidStack) { + if (fluidStack == null) { return "null"; } - NBTTagCompound tag = fluidStack.tag; - return fluidStack.getFluid().getName() + ':' + fluidStack.amount + (tag != null ? ":" + fluidStack.tag : ""); + final NBTTagCompound tag = fluidStack.tag; + return fluidStack.getFluid().getName() + ':' + fluidStack.amount + + (tag != null ? ":" + fluidStack.tag : StringUtils.EMPTY); } - public static NonNullList removeEqualFluids(Collection fluidsStacks) { - NonNullList dedupedFluidStacks = NonNullList.create(); - for (FluidStack fluidStack : fluidsStacks) { + public static NonNullList removeEqualFluids(final Collection fluidsStacks) { + final NonNullList dedupedFluidStacks = NonNullList.create(); + for (final FluidStack fluidStack : fluidsStacks) { if (!containsEqualFluid(dedupedFluidStacks, fluidStack)) { dedupedFluidStacks.add(fluidStack); } @@ -32,8 +35,8 @@ public static NonNullList removeEqualFluids(Collection f return dedupedFluidStacks; } - public static boolean containsEqualFluid(NonNullList fluidStacks, FluidStack query) { - for (FluidStack fluidStack : fluidStacks) { + public static boolean containsEqualFluid(final NonNullList fluidStacks, final FluidStack query) { + for (final FluidStack fluidStack : fluidStacks) { if (fluidStack.isFluidEqual(query)) { return true; } @@ -42,14 +45,14 @@ public static boolean containsEqualFluid(NonNullList fluidStacks, Fl } @Nullable - public static ItemStack getContainer(FluidStack fluidStack) { - ItemStack[] containers = { + public static ItemStack getContainer(final FluidStack fluidStack) { + final ItemStack[] containers = { new ItemStack(Items.GLASS_BOTTLE), new ItemStack(Items.BUCKET) }; - for (ItemStack container : containers) { - IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(container); + for (final ItemStack container : containers) { + final IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler != null && fluidHandler.fill(fluidStack, true) > 0) { return fluidHandler.getContainer(); } From 7d6c42af1bfaf719dfb8ded440ae59812b6e2256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 11:35:17 +1000 Subject: [PATCH 67/99] Refactor duplication code in ComponentInventorySlots.java, ComponentTankContainer.java --- .../machines/inventory/ComponentInventorySlots.java | 7 +------ .../machines/inventory/ComponentTankContainer.java | 7 +------ core/src/main/java/binnie/core/util/NBTUtil.java | 10 ++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java index c42321cd5..5601c5498 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java @@ -107,12 +107,7 @@ public void readFromNBT(final NBTTagCompound compound) { @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); - NBTUtil.writeToList(compound, INVENTORY_KEY, inventory, (index, slot) -> { - NBTTagCompound slotTag = new NBTTagCompound(); - slotTag.setInteger(INDEX_KEY, index); - slot.writeToNBT(slotTag); - return slotTag; - }); + NBTUtil.writeToList(compound, INVENTORY_KEY, inventory, NBTUtil.writeToListConsumer(INDEX_KEY)); return compound; } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java index 0b1010815..fed91c415 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java @@ -100,12 +100,7 @@ public void readFromNBT(NBTTagCompound compound) { @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); - NBTUtil.writeToList(compound, TANKS_KEY, tanks, (index, tank)->{ - NBTTagCompound tankNBT = new NBTTagCompound(); - tankNBT.setInteger(TANK_INDEX_KEY, index); - tank.writeToNBT(tankNBT); - return tankNBT; - }); + NBTUtil.writeToList(compound, TANKS_KEY, tanks, NBTUtil.writeToListConsumer(TANK_INDEX_KEY)); return compound; } diff --git a/core/src/main/java/binnie/core/util/NBTUtil.java b/core/src/main/java/binnie/core/util/NBTUtil.java index e9424764e..d3299df50 100644 --- a/core/src/main/java/binnie/core/util/NBTUtil.java +++ b/core/src/main/java/binnie/core/util/NBTUtil.java @@ -4,6 +4,7 @@ import java.util.function.BiFunction; import java.util.function.Consumer; +import forestry.api.core.INbtWritable; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -16,6 +17,15 @@ public class NBTUtil { private NBTUtil() { } + public static BiFunction writeToListConsumer(final String Key) { + return (index, slot) -> { + NBTTagCompound nbtTagCompound = new NBTTagCompound(); + nbtTagCompound.setInteger(Key, index); + slot.writeToNBT(nbtTagCompound); + return nbtTagCompound; + }; + } + public static void readFromList(NBTTagCompound compound, String listKey, Consumer consumer){ if(!compound.hasKey(listKey, 9)){ return; From 888c4f71ff95bb4507975433417682e1d8fffc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 13:51:14 +1000 Subject: [PATCH 68/99] Various final and annotations. --- .../core/machines/inventory/BaseSlot.java | 2 +- .../inventory/ComponentInventoryTransfer.java | 18 ++++++------- .../inventory/ComponentTankContainer.java | 26 +++++++++---------- .../core/machines/inventory/FakeSlot.java | 3 ++- .../machines/inventory/InventorySlot.java | 3 ++- .../core/machines/inventory/MachineSide.java | 8 +++--- .../core/machines/inventory/SidedAccess.java | 16 ++++++------ .../core/machines/inventory/TankSlot.java | 4 +-- .../main/java/binnie/core/util/NBTUtil.java | 10 +++---- 9 files changed, 46 insertions(+), 44 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java b/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java index 297699cb4..ffbfce401 100644 --- a/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/BaseSlot.java @@ -20,7 +20,7 @@ public abstract class BaseSlot implements INbtWritable, INbtReadable, IValida private boolean readOnly; private int index; - public BaseSlot(final int index, final ResourceLocation unlocLocation) { + public BaseSlot(final int index, @Nullable final ResourceLocation unlocLocation) { this.access = new SidedAccess(); this.setIndex(index); this.unlocLocation = unlocLocation; diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java index a7c770d06..a081c6e77 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java @@ -22,17 +22,17 @@ public ComponentInventoryTransfer(final IMachine machine) { } public void addRestock(final int[] buffer, final int destination, final int limit) { - Restock restock = new Restock(this.getMachine(), buffer, destination, limit); + final Restock restock = new Restock(this.getMachine(), buffer, destination, limit); this.transfers.add(restock); } public void addRestock(final int[] buffer, final int destination) { - Restock restock = new Restock(this.getMachine(), buffer, destination); + final Restock restock = new Restock(this.getMachine(), buffer, destination); this.transfers.add(restock); } public void addStorage(final int source, final int[] destination) { - Storage storage = new Storage(this.getMachine(), source, destination); + final Storage storage = new Storage(this.getMachine(), source, destination); this.transfers.add(storage); } @@ -44,8 +44,8 @@ public void onUpdate() { } public void addStorage(final int source, final int[] destination, final Condition condition) { - Storage storage = new Storage(this.getMachine(), source, destination); - Transfer transfer = storage.setCondition(condition); + final Storage storage = new Storage(this.getMachine(), source, destination); + final Transfer transfer = storage.setCondition(condition); this.transfers.add(transfer); } @@ -130,12 +130,12 @@ private Storage(final IMachine machine, final int source, final int[] destinatio @Override protected void doTransfer(final IInventory inv) { - ItemStack stackInSlot = inv.getStackInSlot(this.source); + final ItemStack stackInSlot = inv.getStackInSlot(this.source); if (!stackInSlot.isEmpty()) { - TransferRequest transferRequest = new TransferRequest(stackInSlot, inv).setTargetSlots(this.destination).ignoreValidation(); - TransferResult transferResult = transferRequest.transfer(null, true); + final TransferRequest transferRequest = new TransferRequest(stackInSlot, inv).setTargetSlots(this.destination).ignoreValidation(); + final TransferResult transferResult = transferRequest.transfer(null, true); if (transferResult.isSuccess()) { - NonNullList results = transferResult.getRemaining(); + final NonNullList results = transferResult.getRemaining(); if (results.size() == 1) { inv.setInventorySlotContents(this.source, results.get(0)); } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java index fed91c415..7013e49ac 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java @@ -45,14 +45,14 @@ public ComponentTankContainer(final IMachine machine) { @Override public final TankSlot addTank(final int index, final String name, final int capacity) { - TankSlot tank = new TankSlot(index, name, capacity); + final TankSlot tank = new TankSlot(index, name, capacity); this.tanks.put(index, tank); return tank; } @Override public final TankSlot addTank(final int index, final ResourceLocation name, final int capacity) { - TankSlot tank = new TankSlot(index, name, capacity); + final TankSlot tank = new TankSlot(index, name, capacity); this.tanks.put(index, tank); return tank; } @@ -86,10 +86,10 @@ private FluidStack drain(final int tankIndex, final int maxDrain, final boolean } @Override - public void readFromNBT(NBTTagCompound compound) { + public void readFromNBT(final NBTTagCompound compound) { super.readFromNBT(compound); NBTUtil.readFromList(compound, TANKS_KEY, (tankNBT)->{ - int index = tankNBT.getInteger(TANK_INDEX_KEY); + final int index = tankNBT.getInteger(TANK_INDEX_KEY); if (this.tanks.containsKey(index)) { TankSlot tank = tanks.get(index); tank.readFromNBT(tankNBT); @@ -146,7 +146,7 @@ public void markDirty() { @Override @Nullable - public IFluidHandler getHandler(@Nullable EnumFacing from) { + public IFluidHandler getHandler(@Nullable final EnumFacing from) { if (from == null) { return noFacingHandler; } @@ -155,10 +155,10 @@ public IFluidHandler getHandler(@Nullable EnumFacing from) { @Nullable @Override - public IFluidHandler getHandler(int[] targetTanks) { - Map tanks = new HashMap<>(); - for (int index : targetTanks) { - TankSlot tankSlot = this.tanks.get(index); + public IFluidHandler getHandler(final int[] targetTanks) { + final Map tanks = new HashMap<>(); + for (final int index : targetTanks) { + final TankSlot tankSlot = this.tanks.get(index); if (tankSlot != null) { tanks.put(index, tankSlot); } @@ -175,7 +175,7 @@ private static class TankContainer implements IFluidHandler { @Nullable private final EnumFacing from; - private TankContainer(ComponentTankContainer tankContainer, Map tanks, @Nullable EnumFacing from) { + private TankContainer(final ComponentTankContainer tankContainer, final Map tanks, @Nullable final EnumFacing from) { this.tankContainer = tankContainer; this.tanks = tanks; this.from = from; @@ -214,7 +214,7 @@ public final FluidStack drain(final int maxDrain, final boolean doDrain) { public IFluidTankProperties[] getTankProperties() { final IFluidTankProperties[] properties = new IFluidTankProperties[getTanks().length]; for (int i = 0; i < properties.length; ++i) { - IFluidTank tank = getTanks()[i]; + final IFluidTank tank = getTanks()[i]; properties[i] = new FluidTankProperties(tank.getFluid(), tank.getCapacity()); } return properties; @@ -228,7 +228,7 @@ private IFluidTank[] getTanks() { return ltanks.toArray(EmptyHelper.FLUID_TANKS_EMPTY); } - private static int getTankIndexToFill(Map tanks, @Nullable EnumFacing from, final FluidStack resource) { + private static int getTankIndexToFill(final Map tanks, @Nullable final EnumFacing from, final FluidStack resource) { for (final TankSlot tank : tanks.values()) { if (tank.isValid(resource) && tank.canInsert(from) && (tank.getContent() == null || tank.getContent().isFluidEqual(resource))) { return tank.getIndex(); @@ -237,7 +237,7 @@ private static int getTankIndexToFill(Map tanks, @Nullable En return -1; } - private static int getTankIndexToDrain(Map tanks, @Nullable EnumFacing from, @Nullable final FluidStack resource) { + private static int getTankIndexToDrain(final Map tanks, @Nullable final EnumFacing from, @Nullable final FluidStack resource) { for (final TankSlot tank : tanks.values()) { if (tank.getContent() != null && tank.canExtract(from) && (resource == null || resource.isFluidEqual(tank.getContent()))) { return tank.getIndex(); diff --git a/core/src/main/java/binnie/core/machines/inventory/FakeSlot.java b/core/src/main/java/binnie/core/machines/inventory/FakeSlot.java index 4913818d2..c571b835d 100644 --- a/core/src/main/java/binnie/core/machines/inventory/FakeSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/FakeSlot.java @@ -5,6 +5,7 @@ public final class FakeSlot extends InventorySlot { public static final FakeSlot INSTANCE = new FakeSlot(); + private static final String FAKE_SLOT = "Fake Slot!"; private FakeSlot() { super(0, null); @@ -40,7 +41,7 @@ public ItemStack getItemStack() { @Override public String getName() { - return "Fake Slot!"; + return FAKE_SLOT; } @Override diff --git a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java index ef29315fc..cadae3a49 100644 --- a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java @@ -3,6 +3,7 @@ import org.apache.commons.lang3.StringUtils; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -15,7 +16,7 @@ public class InventorySlot extends BaseSlot { private ItemStack content; private Type type; - public InventorySlot(final int index, final ResourceLocation unlocLocation) { + public InventorySlot(final int index, @Nullable final ResourceLocation unlocLocation) { super(index, unlocLocation); this.content = ItemStack.EMPTY; this.type = Type.Standard; diff --git a/core/src/main/java/binnie/core/machines/inventory/MachineSide.java b/core/src/main/java/binnie/core/machines/inventory/MachineSide.java index d2753d0ce..9ef3f472a 100644 --- a/core/src/main/java/binnie/core/machines/inventory/MachineSide.java +++ b/core/src/main/java/binnie/core/machines/inventory/MachineSide.java @@ -30,12 +30,12 @@ public static String asString(final Collection sides) { return I18N.localise(ModId.CORE, "side.sides"); } - StringBuilder text = new StringBuilder(); + final StringBuilder text = new StringBuilder(); boolean firstSide = true; - List sortedSides = new ArrayList<>(sides); + final List sortedSides = new ArrayList<>(sides); sortedSides.sort(Comparator.comparing(ALL::indexOf)); - for (EnumFacing side : sortedSides) { - String localized = I18N.localise(ModId.CORE, "side." + side.getName()); + for (final EnumFacing side : sortedSides) { + final String localized = I18N.localise(ModId.CORE, "side." + side.getName()); if (firstSide) { firstSide = false; } else { diff --git a/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java b/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java index d17537169..13efa23f5 100644 --- a/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java +++ b/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java @@ -55,9 +55,9 @@ public void forbidExtractChange() { } public Collection getInsertionSides() { - List dirs = new ArrayList<>(); - for (EnumFacing side : EnumFacing.VALUES) { - AccessDirection direction = getAccess(side); + final List dirs = new ArrayList<>(); + for (final EnumFacing side : EnumFacing.VALUES) { + final AccessDirection direction = getAccess(side); if (direction.canInsert()) { dirs.add(side); } @@ -66,9 +66,9 @@ public Collection getInsertionSides() { } public Collection getExtractionSides() { - List dirs = new ArrayList<>(); - for (EnumFacing side : EnumFacing.VALUES) { - AccessDirection direction = getAccess(side); + final List dirs = new ArrayList<>(); + for (final EnumFacing side : EnumFacing.VALUES) { + final AccessDirection direction = getAccess(side); if (direction.canExtract()) { dirs.add(side); } @@ -77,14 +77,14 @@ public Collection getExtractionSides() { } public void setInsert(EnumFacing side, boolean value) { - AccessDirection direction = getAccess(side); + final AccessDirection direction = getAccess(side); if (direction.canInsert() != value) { this.accesses.put(side, direction.changeInsert(value)); } } public void setExtract(EnumFacing side, boolean value) { - AccessDirection direction = getAccess(side); + final AccessDirection direction = getAccess(side); if (direction.canExtract() != value) { this.accesses.put(side, direction.changeExtract(value)); } diff --git a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java index acf729c49..c595121f8 100644 --- a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java @@ -45,7 +45,7 @@ public FluidStack getContent() { return this.tank.getFluid(); } - private void setContent(@Nullable FluidStack stack) { + private void setContent(@Nullable final FluidStack stack) { this.tank.setFluid(stack); } @@ -55,7 +55,7 @@ public FluidTank getTank() { @Override public String getName() { - Validator validator = getValidator(); + final Validator validator = getValidator(); if (validator != null) { return I18N.localise(ModId.CORE, "gui.tank.validated", validator.getTooltip()); } diff --git a/core/src/main/java/binnie/core/util/NBTUtil.java b/core/src/main/java/binnie/core/util/NBTUtil.java index d3299df50..b499249a0 100644 --- a/core/src/main/java/binnie/core/util/NBTUtil.java +++ b/core/src/main/java/binnie/core/util/NBTUtil.java @@ -19,7 +19,7 @@ private NBTUtil() { public static BiFunction writeToListConsumer(final String Key) { return (index, slot) -> { - NBTTagCompound nbtTagCompound = new NBTTagCompound(); + final NBTTagCompound nbtTagCompound = new NBTTagCompound(); nbtTagCompound.setInteger(Key, index); slot.writeToNBT(nbtTagCompound); return nbtTagCompound; @@ -30,15 +30,15 @@ public static void readFromList(NBTTagCompound compound, String listKey, Consume if(!compound.hasKey(listKey, 9)){ return; } - NBTTagList tagList = compound.getTagList(listKey, 10); + final NBTTagList tagList = compound.getTagList(listKey, 10); for (int i = 0; i < tagList.tagCount(); ++i) { consumer.accept(tagList.getCompoundTagAt(i)); } } public static void writeToList(NBTTagCompound compound, String listKey, Map content, BiFunction consumer){ - NBTTagList tagList = new NBTTagList(); - for(Map.Entry entry : content.entrySet()){ + final NBTTagList tagList = new NBTTagList(); + for(final Map.Entry entry : content.entrySet()){ tagList.appendTag(consumer.apply(entry.getKey(), entry.getValue())); } compound.setTag(listKey, tagList); @@ -52,7 +52,7 @@ public static void readFromNBT(IEnergyStorage storage, String key, NBTTagCompoun public static void writeToNBT(IEnergyStorage storage, String key, NBTTagCompound nbt) { - NBTBase nbtBase = CapabilityEnergy.ENERGY.writeNBT(storage, null); + final NBTBase nbtBase = CapabilityEnergy.ENERGY.writeNBT(storage, null); if(nbtBase != null) { nbt.setTag(key, nbtBase); } From b82624eabc61f681ffa4b735eedca9e8cc743559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 14:04:50 +1000 Subject: [PATCH 69/99] Improve localize SlotValidator.java --- .../java/binnie/core/machines/inventory/InventorySlot.java | 2 +- .../java/binnie/core/machines/inventory/SlotValidator.java | 4 +++- core/src/main/resources/assets/binniecore/lang/en_US.lang | 2 ++ core/src/main/resources/assets/binniecore/lang/ru_RU.lang | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java index cadae3a49..44a30b681 100644 --- a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java @@ -94,7 +94,7 @@ public boolean isRecipe() { @Override public String getName() { - SlotValidator validator = getValidator(); + final SlotValidator validator = getValidator(); if (validator != null) { return I18N.localise(ModId.CORE, "gui.slot.validated", validator.getTooltip()); } diff --git a/core/src/main/java/binnie/core/machines/inventory/SlotValidator.java b/core/src/main/java/binnie/core/machines/inventory/SlotValidator.java index 21409c483..f8df70df8 100644 --- a/core/src/main/java/binnie/core/machines/inventory/SlotValidator.java +++ b/core/src/main/java/binnie/core/machines/inventory/SlotValidator.java @@ -2,6 +2,8 @@ import javax.annotation.Nullable; +import binnie.core.ModId; +import binnie.core.util.I18N; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; @@ -56,7 +58,7 @@ public boolean isValid(final ItemStack itemStack) { @Override public String getTooltip() { - return "Breedable Individual"; + return I18N.localise(ModId.CORE, "gui.slotvalidator.individual"); } } } diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index b6aa76f55..f49241d6b 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -356,6 +356,8 @@ binniecore.gui.slot.inventory=Machine Inventory binniecore.gui.slot.player.inventory=Player Inventory binniecore.gui.slot.pickup.only=Pickup Only Slot +binniecore.gui.slotvalidator.individual=Breedable Individual + binniecore.gui.tank.validated=%s Tank binniecore.gui.tank.input=Input Tank binniecore.gui.tank.process=Process Tank diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index c537296eb..7da7f0301 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -355,6 +355,8 @@ binniecore.gui.slot.inventory=Инвентарь машины binniecore.gui.slot.player.inventory=Инвентарь игрока binniecore.gui.slot.pickup.only=Можно положить только в слот +binniecore.gui.slotvalidator.individual=Разводимая особь + binniecore.gui.tank.validated=%s резервуар binniecore.gui.tank.input=Входной резервуар binniecore.gui.tank.process=Технологический резервуар From 2dee6f853f794f4eff34414bba3e663f8dd9ea61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 14:25:48 +1000 Subject: [PATCH 70/99] ControlSlot.java tooltip loc improve --- .../java/binnie/core/gui/minecraft/control/ControlSlot.java | 3 ++- core/src/main/resources/assets/binniecore/lang/en_US.lang | 2 ++ core/src/main/resources/assets/binniecore/lang/ru_RU.lang | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java index d1eaaacdd..69048cb3f 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java @@ -208,7 +208,8 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { } else if (this.slot.inventory instanceof WindowInventory) { if (tooltipFlag.isAdvanced()) { final SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex()); - tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip())); + final String itemDescription = (s == null) ? I18N.localise(ModId.CORE, "gui.slot.window.inventory.any") : s.getTooltip(); + tooltip.add(I18N.localise(ModId.CORE, "gui.slot.window.inventory", itemDescription)); } } else if (this.slot.inventory instanceof InventoryPlayer) { if (tooltipFlag.isAdvanced()) { diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index f49241d6b..e1e0bdbc6 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -353,6 +353,8 @@ binniecore.gui.slot.serum.output=Serum Output Slot binniecore.gui.slot.serum.active=Active Serum Slot binniecore.gui.slot.yeast=Yeast Slot binniecore.gui.slot.inventory=Machine Inventory +binniecore.gui.slot.window.inventory.any=Any Item +binniecore.gui.slot.window.inventory=Accepts: %s binniecore.gui.slot.player.inventory=Player Inventory binniecore.gui.slot.pickup.only=Pickup Only Slot diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 7da7f0301..3270ee690 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -351,6 +351,8 @@ binniecore.gui.slot.serum.input=Входящая сыворотка binniecore.gui.slot.serum.output=Выходящая сыворотка binniecore.gui.slot.serum.active=Активная сыворотка binniecore.gui.slot.yeast=Слот для дрожжей +binniecore.gui.slot.window.inventory.any=Любой предмет +binniecore.gui.slot.window.inventory=Принимает: %s binniecore.gui.slot.inventory=Инвентарь машины binniecore.gui.slot.player.inventory=Инвентарь игрока binniecore.gui.slot.pickup.only=Можно положить только в слот From b050ceef6d90de7f665b64f6e4ad7ef273acdd1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 14:44:05 +1000 Subject: [PATCH 71/99] Small refactor TankSlot.java --- .../main/java/binnie/core/machines/inventory/TankSlot.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java index c595121f8..8f1ed5ee9 100644 --- a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java @@ -34,8 +34,9 @@ public void readFromNBT(final NBTTagCompound compound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound compound) { - if (this.getContent() != null) { - this.getContent().writeToNBT(compound); + final FluidStack fluidStack = this.getContent(); + if (fluidStack != null) { + fluidStack.writeToNBT(compound); } return compound; } From 6fa260bba59d273ea60f31bc5e502529e4453b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 14:45:09 +1000 Subject: [PATCH 72/99] ComponentPowerReceptor.java - remove null checks from world var. But need deep testing. --- .../machines/power/ComponentPowerReceptor.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java index 1a457457a..5826f8268 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java @@ -21,7 +21,7 @@ //@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 { - private static final int inputAverageTicks = 20; + private static final int INPUT_AVERAGE_TICKS = 20; private final float previousPower; private final LinkedList inputs; private boolean registeredToIC2EnergyNet; @@ -43,7 +43,7 @@ public ComponentPowerReceptor(final IMachine machine, final int storage) { } public static int getInputAverageTicks() { - return inputAverageTicks; + return INPUT_AVERAGE_TICKS; } @Override @@ -57,7 +57,7 @@ public void readFromNBT(final NBTTagCompound nbttagcompound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) { - NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); + final NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); this.container.writeToNBT(nbttagcompound); return nbttagcompound; } @@ -98,14 +98,14 @@ public int getSinkTier() { @Override @Optional.Method(modid = "ic2") - public double injectEnergy(EnumFacing directionFrom, final double amount, final double voltage) { + public double injectEnergy(final EnumFacing directionFrom, final double amount, final double voltage) { this.container.addEnergy(PowerSystem.EU, amount, true); return 0.0; } @Override @Optional.Method(modid = "ic2") - public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { + public boolean acceptsEnergyFrom(final IEnergyEmitter emitter, final EnumFacing direction) { return this.acceptsPowerSystem(PowerSystem.EU); } @@ -159,8 +159,8 @@ public void onChunkUnload() { } private void addToEnergyNet() { - World world = this.getMachine().getWorld(); - if (world == null || world.isRemote) { + final World world = this.getMachine().getWorld(); + if (world.isRemote) { return; } if (Mods.IC2.active()) { @@ -169,8 +169,8 @@ private void addToEnergyNet() { } private void removeFromEnergyNet() { - World world = this.getMachine().getWorld(); - if (world == null || world.isRemote) { + final World world = this.getMachine().getWorld(); + if (world.isRemote) { return; } if (Mods.IC2.active()) { From e6976073977ee95356fd0c1ddf71bf0a6afada67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 15:05:45 +1000 Subject: [PATCH 73/99] Various final, NBT keys const. --- .../core/machines/power/ComponentProcess.java | 8 +++--- .../binnie/core/machines/power/PowerInfo.java | 11 +++++--- .../core/machines/power/PowerInterface.java | 6 +++-- .../core/machines/power/ProcessInfo.java | 26 ++++++++++--------- .../binnie/core/machines/power/TankInfo.java | 19 ++++++++------ 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/power/ComponentProcess.java b/core/src/main/java/binnie/core/machines/power/ComponentProcess.java index fcf8995ef..d6d3606e6 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentProcess.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentProcess.java @@ -68,16 +68,18 @@ public void setProgress(final float f) { protected void onFinishTask() { } + private static final String NBT_KEY_PROGRESS = "progress"; + @Override public void readFromNBT(final NBTTagCompound nbt) { super.readFromNBT(nbt); - this.progressAmount = nbt.getFloat("progress"); + this.progressAmount = nbt.getFloat(NBT_KEY_PROGRESS); } @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbt1) { - NBTTagCompound nbt = super.writeToNBT(nbt1); - nbt.setFloat("progress", this.progressAmount); + final NBTTagCompound nbt = super.writeToNBT(nbt1); + nbt.setFloat(NBT_KEY_PROGRESS, this.progressAmount); return nbt; } diff --git a/core/src/main/java/binnie/core/machines/power/PowerInfo.java b/core/src/main/java/binnie/core/machines/power/PowerInfo.java index 0e503cc44..0822be722 100644 --- a/core/src/main/java/binnie/core/machines/power/PowerInfo.java +++ b/core/src/main/java/binnie/core/machines/power/PowerInfo.java @@ -29,16 +29,19 @@ public int getMaxEnergy() { return (int) this.maxEnergy; } + private static final String NBT_KEY_CURRENT = "current"; + private static final String NBT_KEY_MAX = "max"; + @Override public void readFromNBT(final NBTTagCompound nbttagcompound) { - this.currentEnergy = nbttagcompound.getInteger("current"); - this.maxEnergy = nbttagcompound.getInteger("max"); + this.currentEnergy = nbttagcompound.getInteger(NBT_KEY_CURRENT); + this.maxEnergy = nbttagcompound.getInteger(NBT_KEY_MAX); } @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("current", this.getStoredEnergy()); - nbttagcompound.setInteger("max", this.getMaxEnergy()); + nbttagcompound.setInteger(NBT_KEY_CURRENT, this.getStoredEnergy()); + nbttagcompound.setInteger(NBT_KEY_MAX, this.getMaxEnergy()); return nbttagcompound; } } diff --git a/core/src/main/java/binnie/core/machines/power/PowerInterface.java b/core/src/main/java/binnie/core/machines/power/PowerInterface.java index dd618f89b..81877bff7 100644 --- a/core/src/main/java/binnie/core/machines/power/PowerInterface.java +++ b/core/src/main/java/binnie/core/machines/power/PowerInterface.java @@ -62,9 +62,11 @@ public double getEnergySpace(final PowerSystem unit) { return unit.convertTo(this.getEnergySpace()); } + private static final String NBT_KEY_ENERGY = "Energy"; + @Override public void readFromNBT(final NBTTagCompound nbt) { - this.energy = nbt.getInteger("Energy"); + this.energy = nbt.getInteger(NBT_KEY_ENERGY); if (this.energy > this.capacity) { this.energy = this.capacity; } else if (this.energy < 0) { @@ -74,7 +76,7 @@ public void readFromNBT(final NBTTagCompound nbt) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbt) { - nbt.setInteger("Energy", this.getEnergy()); + nbt.setInteger(NBT_KEY_ENERGY, this.getEnergy()); return nbt; } } diff --git a/core/src/main/java/binnie/core/machines/power/ProcessInfo.java b/core/src/main/java/binnie/core/machines/power/ProcessInfo.java index 864324d71..6833c0d70 100644 --- a/core/src/main/java/binnie/core/machines/power/ProcessInfo.java +++ b/core/src/main/java/binnie/core/machines/power/ProcessInfo.java @@ -12,10 +12,7 @@ public class ProcessInfo implements INbtReadable, INbtWritable { private float energyPerTick; public ProcessInfo(final IProcess process) { - this.currentProgress = 0.0f; - this.processEnergy = 0; - this.processTime = 0; - this.energyPerTick = 0.0f; + this(); this.energyPerTick = process.getEnergyPerTick(); if (process instanceof IProcessTimed) { final IProcessTimed time = (IProcessTimed) process; @@ -50,20 +47,25 @@ public float getEnergyPerTick() { return this.energyPerTick; } + private static final String NBT_KEY_ENERGY_PER_TICK = "ept"; + private static final String NBT_KEY_PROCESS_ENERGY = "e"; + private static final String NBT_KEY_PROCESS_TIME = "t"; + private static final String NBT_KEY_CURRENT_PROGRESS = "p"; + @Override public void readFromNBT(final NBTTagCompound nbttagcompound) { - this.energyPerTick = nbttagcompound.getFloat("ept"); - this.processEnergy = nbttagcompound.getInteger("e"); - this.processTime = nbttagcompound.getInteger("t"); - this.currentProgress = nbttagcompound.getFloat("p"); + this.energyPerTick = nbttagcompound.getFloat(NBT_KEY_ENERGY_PER_TICK); + this.processEnergy = nbttagcompound.getInteger(NBT_KEY_PROCESS_ENERGY); + this.processTime = nbttagcompound.getInteger(NBT_KEY_PROCESS_TIME); + this.currentProgress = nbttagcompound.getFloat(NBT_KEY_CURRENT_PROGRESS); } @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound) { - nbttagcompound.setFloat("ept", this.energyPerTick); - nbttagcompound.setFloat("p", this.currentProgress); - nbttagcompound.setInteger("e", this.processEnergy); - nbttagcompound.setInteger("t", this.processTime); + nbttagcompound.setFloat(NBT_KEY_ENERGY_PER_TICK, this.energyPerTick); + nbttagcompound.setInteger(NBT_KEY_PROCESS_ENERGY, this.processEnergy); + nbttagcompound.setInteger(NBT_KEY_PROCESS_TIME, this.processTime); + nbttagcompound.setFloat(NBT_KEY_CURRENT_PROGRESS, this.currentProgress); return nbttagcompound; } } diff --git a/core/src/main/java/binnie/core/machines/power/TankInfo.java b/core/src/main/java/binnie/core/machines/power/TankInfo.java index 746148568..d8a52de5e 100644 --- a/core/src/main/java/binnie/core/machines/power/TankInfo.java +++ b/core/src/main/java/binnie/core/machines/power/TankInfo.java @@ -17,7 +17,6 @@ public class TankInfo implements INbtReadable, INbtWritable { private float capacity; public TankInfo(final IFluidTank tank) { - this.capacity = 0.0f; this.capacity = tank.getCapacity(); this.liquid = tank.getFluid(); } @@ -27,9 +26,10 @@ public TankInfo() { } public static TankInfo[] get(final ITankMachine machine) { - final TankInfo[] info = new TankInfo[machine.getTanks().length]; + final IFluidTank[] fluidTanks = machine.getTanks(); + final TankInfo[] info = new TankInfo[fluidTanks.length]; for (int i = 0; i < info.length; ++i) { - info[i] = new TankInfo(machine.getTanks()[i]); + info[i] = new TankInfo(fluidTanks[i]); } return info; } @@ -50,23 +50,26 @@ public String getName() { return (this.liquid == null) ? StringUtils.EMPTY : this.liquid.getFluid().getLocalizedName(this.liquid); } + private static final String NBT_KEY_CAPACITY = "capacity"; + private static final String NBT_KEY_LIQUID = "liquid"; + @Override public void readFromNBT(final NBTTagCompound nbt) { - this.capacity = nbt.getInteger("capacity"); - if (nbt.hasKey("liquid")) { - this.liquid = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("liquid")); + this.capacity = nbt.getInteger(NBT_KEY_CAPACITY); + if (nbt.hasKey(NBT_KEY_LIQUID)) { + this.liquid = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag(NBT_KEY_LIQUID)); } } @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbt) { - nbt.setInteger("capacity", (int) this.getCapacity()); + nbt.setInteger(NBT_KEY_CAPACITY, (int) this.getCapacity()); if (this.liquid == null) { return nbt; } final NBTTagCompound tag = new NBTTagCompound(); this.liquid.writeToNBT(tag); - nbt.setTag("liquid", tag); + nbt.setTag(NBT_KEY_LIQUID, tag); return nbt; } From ebc62ca6b2e753b118107348a223d105c288fd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 15:12:31 +1000 Subject: [PATCH 74/99] Various final, NBT keys const. --- .../machines/render/RenderTESRMachine.java | 6 ++--- .../core/machines/storage/CompartmentTab.java | 25 ++++++++++++------- .../storage/ComponentBinnieCoreGUI.java | 2 +- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java b/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java index a1008fb5c..510473c10 100644 --- a/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java +++ b/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java @@ -10,10 +10,10 @@ @SideOnly(Side.CLIENT) public class RenderTESRMachine extends TileEntitySpecialRenderer { @Override - public void render(TileEntityTESRMachine te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { - Machine machine = te.getMachine(); + public void render(final TileEntityTESRMachine te, final double x, final double y, final double z, final float partialTicks, final int destroyStage, final float alpha) { + final Machine machine = te.getMachine(); if (machine != null) { - for (IRender.Render renders : machine.getInterfaces(IRender.Render.class)) { + for (final IRender.Render renders : machine.getInterfaces(IRender.Render.class)) { renders.renderInWorld(x, y, z); } } diff --git a/core/src/main/java/binnie/core/machines/storage/CompartmentTab.java b/core/src/main/java/binnie/core/machines/storage/CompartmentTab.java index 0ce176a89..1cce3cc22 100644 --- a/core/src/main/java/binnie/core/machines/storage/CompartmentTab.java +++ b/core/src/main/java/binnie/core/machines/storage/CompartmentTab.java @@ -1,5 +1,7 @@ package binnie.core.machines.storage; +import org.apache.commons.lang3.StringUtils; + import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -15,27 +17,32 @@ class CompartmentTab implements INbtWritable { private final int id; public CompartmentTab(int id) { - this.name = ""; + this.name = StringUtils.EMPTY; this.icon = new ItemStack(Items.PAPER); this.color = EnumColor.WHITE; this.id = id; } + private static final String NBT_KEY_NAME = "name"; + private static final String NBT_KEY_ICON = "icon"; + private static final String NBT_KEY_COLOR = "color"; + private static final String NBT_KEY_ID = "id"; + public CompartmentTab(NBTTagCompound nbt) { - this.name = nbt.getString("name"); - this.icon = new ItemStack(nbt.getCompoundTag("icon")); - this.color = EnumColor.values()[nbt.getByte("color")]; - this.id = nbt.getByte("id"); + this.name = nbt.getString(NBT_KEY_NAME); + this.icon = new ItemStack(nbt.getCompoundTag(NBT_KEY_ICON)); + this.color = EnumColor.values()[nbt.getByte(NBT_KEY_COLOR)]; + this.id = nbt.getByte(NBT_KEY_ID); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setString("name", this.name); + nbt.setString(NBT_KEY_NAME, this.name); final NBTTagCompound n = new NBTTagCompound(); this.icon.writeToNBT(n); - nbt.setTag("icon", n); - nbt.setByte("color", (byte) this.color.ordinal()); - nbt.setByte("id", (byte) this.id); + nbt.setTag(NBT_KEY_ICON, n); + nbt.setByte(NBT_KEY_COLOR, (byte) this.color.ordinal()); + nbt.setByte(NBT_KEY_ID, (byte) this.id); return nbt; } diff --git a/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java b/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java index 7f0392bfe..72f00024d 100644 --- a/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java +++ b/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java @@ -22,7 +22,7 @@ public ComponentBinnieCoreGUI(final Machine machine, final BinnieCoreGUI id) { } @Override - public void onRightClick(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + public void onRightClick(final World worldIn, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { if (!player.isSneaking()) { BinnieCore.getBinnieProxy().openGui(this.id, player, pos); } From bbb324246d73a2e54561be4e1acb46b506af2e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 15:35:28 +1000 Subject: [PATCH 75/99] Compartment refactoring start. --- .../ComponentCompartmentInventory.java | 28 +++++++++++-------- .../machines/storage/WindowCompartment.java | 6 ++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java b/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java index 6c1a3a1d1..322dc2c16 100644 --- a/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java +++ b/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java @@ -46,6 +46,9 @@ public CompartmentTab getTab(final int i) { return this.tabs.computeIfAbsent(i, CompartmentTab::new); } + private static final String NBT_KEY_TABS = "tabs"; + private static final String NBT_KEY_COMP_TABS = "comp-tabs"; + @Override public void sendGuiNBTToClient(final Map nbt) { final NBTTagList list = new NBTTagList(); @@ -55,14 +58,15 @@ public void sendGuiNBTToClient(final Map nbt) { list.appendTag(nbt2); } final NBTTagCompound tag = new NBTTagCompound(); - tag.setTag("tabs", list); - nbt.put("comp-tabs", tag); + tag.setTag(NBT_KEY_TABS, list); + nbt.put(NBT_KEY_COMP_TABS, tag); } @Override - public void receiveGuiNBTOnClient(EntityPlayer player, String name, NBTTagCompound nbt) { - if (name.equals("comp-tabs")) { - final NBTTagList tags = nbt.getTagList("tabs", 10); + public void receiveGuiNBTOnClient(final EntityPlayer player, final String name, final NBTTagCompound nbt) { + // TODO: RusTit: I think here should be ACTION_COMP_CHANGE_TAB key, need testing. + if (name.equals(NBT_KEY_COMP_TABS)) { + final NBTTagList tags = nbt.getTagList(NBT_KEY_TABS, 10); for (int i = 0; i < tags.tagCount(); ++i) { final NBTTagCompound tag = tags.getCompoundTagAt(i); final CompartmentTab tab = new CompartmentTab(tag); @@ -71,11 +75,13 @@ public void receiveGuiNBTOnClient(EntityPlayer player, String name, NBTTagCompou } } + public static final String ACTION_COMP_CHANGE_TAB = "comp-change-tab"; + @Override public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) { - if (name.equals("comp-change-tab")) { - final CompartmentTab tab2 = new CompartmentTab(nbt); - this.tabs.put(tab2.getId(), tab2); + if (name.equals(ACTION_COMP_CHANGE_TAB)) { + final CompartmentTab tab = new CompartmentTab(nbt); + this.tabs.put(tab.getId(), tab); this.getMachine().getTileEntity().markDirty(); } } @@ -83,7 +89,7 @@ public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, @Override public void readFromNBT(final NBTTagCompound compound) { super.readFromNBT(compound); - final NBTTagList tags = compound.getTagList("tabs", 10); + final NBTTagList tags = compound.getTagList(NBT_KEY_TABS, 10); for (int i = 0; i < tags.tagCount(); ++i) { final NBTTagCompound tag = tags.getCompoundTagAt(i); final CompartmentTab tab = new CompartmentTab(tag); @@ -93,14 +99,14 @@ public void readFromNBT(final NBTTagCompound compound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound compound) { - NBTTagCompound nbt = super.writeToNBT(compound); + final NBTTagCompound nbt = super.writeToNBT(compound); final NBTTagList list = new NBTTagList(); for (int i = 0; i < this.tabCount; ++i) { final NBTTagCompound nbt2 = new NBTTagCompound(); this.getTab(i).writeToNBT(nbt2); list.appendTag(nbt2); } - nbt.setTag("tabs", list); + nbt.setTag(NBT_KEY_TABS, list); return nbt; } } diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 6db684916..87c3fd600 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -168,7 +168,7 @@ public void initialiseClient() { currentTab.setName(event.getValue()); final NBTTagCompound nbt = new NBTTagCompound(); currentTab.writeToNBT(nbt); - WindowCompartment.this.sendClientAction("comp-change-tab", nbt); + WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); }); y2 += 20; new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Icon: "); @@ -184,7 +184,7 @@ public void initialiseClient() { currentTab.setIcon(stack); final NBTTagCompound nbt = new NBTTagCompound(); currentTab.writeToNBT(nbt); - WindowCompartment.this.sendClientAction("comp-change-tab", nbt); + WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); }); this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.WHITE); this.tabIcon.addHelp("Icon for Current Tab"); @@ -200,7 +200,7 @@ public void initialiseClient() { currentTab.setColor(color.getValue()); final NBTTagCompound nbt = new NBTTagCompound(); currentTab.writeToNBT(nbt); - WindowCompartment.this.sendClientAction("comp-change-tab", nbt); + WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); }); color.addHelp("Colour Selector"); color.addHelp("Select a colour to highlight the current tab"); From 853f7b3a4a2c66b75745a6e324a3399f70996514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 16:09:00 +1000 Subject: [PATCH 76/99] SearchDialog.java code refactoring. --- .../core/machines/storage/SearchDialog.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java index 6fff57831..46c188d5c 100644 --- a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java +++ b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java @@ -46,7 +46,8 @@ public SearchDialog(WindowCompartment windowCompartment) { scroll.setScrollableContent(this.slotGrid); new ControlPlayerInventory(this, true); new ControlTextEdit(this, 16, 16, 100, 14).addEventHandler(EventTextEdit.class, event -> { - textSearch = event.getValue(); + final String value = event.getValue(); + textSearch = (value == null) ? StringUtils.EMPTY : value; updateSearch(); }); this.includeItems = true; @@ -57,14 +58,13 @@ public SearchDialog(WindowCompartment windowCompartment) { this.updateSearch(); } - private void updateSearch() { - Map slotIds = new HashMap<>(); + private Map filter(final Map slotIds) { final IInventory inv = windowCompartment.getInventory(); for (int i = 0; i < inv.getSizeInventory(); ++i) { final ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { final String name = stack.getDisplayName().toLowerCase(); - if (this.textSearch == null || name.contains(this.textSearch)) { + if (this.textSearch.length() == 0 || name.contains(this.textSearch)) { if (this.includeBlocks || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) { if (this.includeItems || Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) { slotIds.put(i, name); @@ -73,22 +73,32 @@ private void updateSearch() { } } } + return slotIds; + } + + private Map sort(final Map slotIds) { if (this.sortByName) { final List> list = new LinkedList<>(slotIds.entrySet()); list.sort((o1, o2) -> -o2.getValue().compareTo(o1.getValue())); - final Map result = new LinkedHashMap<>(); + slotIds.clear(); for (final Map.Entry entry : list) { - result.put(entry.getKey(), entry.getValue()); + slotIds.put(entry.getKey(), entry.getValue()); } - slotIds = result; } + return slotIds; + } + + private void updateSearch() { + final Map slotIds = new HashMap<>(); + final Map filtered = filter(slotIds); + final Map sorted = sort(filtered); int y = 0; int x = 0; final int width = 108; - final int height = 2 + 18 * (1 + (slotIds.size() - 1) / 6); + final int height = 2 + 18 * (1 + (sorted.size() - 1) / 6); this.slotGrid.deleteAllChildren(); this.slotGrid.setSize(new Point(width, height)); - for (final int k : slotIds.keySet()) { + for (final int k : sorted.keySet()) { new ControlSlot.Builder(this.slotGrid, x, y).assign(k); x += 18; if (x >= 108) { From f4ed7040578f0de960ca8b6d84e499c6211d87dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 16:22:54 +1000 Subject: [PATCH 77/99] Revert back checking for null. --- .../binnie/core/machines/power/ComponentPowerReceptor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java index 5826f8268..3408749a7 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java @@ -160,10 +160,10 @@ public void onChunkUnload() { private void addToEnergyNet() { final World world = this.getMachine().getWorld(); - if (world.isRemote) { + if (world == null || world.isRemote) { return; } - if (Mods.IC2.active()) { + if (world == null || Mods.IC2.active()) { this.do_addToEnergyNet(); } } From f8b9fe492a54e5b089566b6af2158ccd6abfcab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Tue, 10 Apr 2018 16:23:14 +1000 Subject: [PATCH 78/99] Improve SearchDialog.java localizing --- .../binnie/core/machines/storage/SearchDialog.java | 12 +++++++----- .../main/resources/assets/binniecore/lang/en_US.lang | 3 +++ .../main/resources/assets/binniecore/lang/ru_RU.lang | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java index 46c188d5c..51cf128f7 100644 --- a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java +++ b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; +import binnie.core.ModId; import binnie.core.api.gui.IWidget; import binnie.core.gui.CraftGUI; import binnie.core.gui.controls.ControlCheckbox; @@ -20,6 +21,7 @@ import binnie.core.gui.minecraft.control.ControlSlot; import binnie.core.gui.renderer.RenderUtil; import binnie.core.gui.resource.textures.CraftGUITexture; +import binnie.core.util.I18N; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; @@ -137,7 +139,7 @@ private static class SortAlphabeticalCheckbox extends ControlCheckbox { private final SearchDialog searchDialog; public SortAlphabeticalCheckbox(SearchDialog searchDialog) { - super(searchDialog, 16, 40, 100, "Sort A-Z", searchDialog.sortByName); + super(searchDialog, 16, 40, 100, I18N.localise(ModId.CORE, "machine.storage.search.sort_by_name"), searchDialog.sortByName); this.searchDialog = searchDialog; } @@ -151,8 +153,8 @@ protected void onValueChanged(final boolean value) { private static class IncludeItemsCheckbox extends ControlCheckbox { private final SearchDialog searchDialog; - public IncludeItemsCheckbox(SearchDialog searchDialog) { - super(searchDialog, 16, 64, 100, "Include Items", searchDialog.includeItems); + public IncludeItemsCheckbox(final SearchDialog searchDialog) { + super(searchDialog, 16, 64, 100, I18N.localise(ModId.CORE, "machine.storage.search.include_items"), searchDialog.includeItems); this.searchDialog = searchDialog; } @@ -166,8 +168,8 @@ protected void onValueChanged(final boolean value) { private static class IncludeBlocksCheckbox extends ControlCheckbox { private final SearchDialog searchDialog; - public IncludeBlocksCheckbox(SearchDialog searchDialog) { - super(searchDialog, 16, 88, 100, "Include Blocks", searchDialog.includeBlocks); + public IncludeBlocksCheckbox(final SearchDialog searchDialog) { + super(searchDialog, 16, 88, 100, I18N.localise(ModId.CORE, "machine.storage.search.include_blocks"), searchDialog.includeBlocks); this.searchDialog = searchDialog; } diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index e1e0bdbc6..2d7bcfe53 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -190,6 +190,9 @@ binniecore.item.container.bucket=Bucket binniecore.item.container.glass=Bottle binniecore.item.container.cylinder=Cylinder +binniecore.machine.storage.search.sort_by_name=Sort A-Z +binniecore.machine.storage.search.include_items=Include Items +binniecore.machine.storage.search.include_blocks=Include Blocks binniecore.machine.storage.compartment=Compartment binniecore.machine.storage.compartment.info=Chests which contain several tabs to help organise their contents. Each tab can be named, assigned a colour and assigned an icon from any Item Stack. Number of Tabs: 4, slots per Tab: 25 binniecore.machine.storage.compartment_iron=Iron Compartment diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 3270ee690..7704b8acb 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -190,6 +190,9 @@ binniecore.item.container.bucket=Ведро binniecore.item.container.glass=Бутылка binniecore.item.container.cylinder=Цилиндр +binniecore.machine.storage.search.sort_by_name=Сорт. A-Z +binniecore.machine.storage.search.include_items=Вкл. предметы +binniecore.machine.storage.search.include_blocks=Вкл. блоки binniecore.machine.storage.compartment=Отсек binniecore.machine.storage.compartment.info=Сундуки, у которых несколько вкладок, чтобы помочь организовать их содержимое. Каждая вкладка может быть: переименована, назначен цвет, назначена пиктограмма из любого элемента. Количество вкладок: 4, слоты на вкладку: 25 binniecore.machine.storage.compartment_iron=Железный отсек From 8534327eeb40ab87450154f7d9aac2372305a006 Mon Sep 17 00:00:00 2001 From: Russkih Anatoly Date: Tue, 10 Apr 2018 23:24:15 +1000 Subject: [PATCH 79/99] Update ComponentPowerReceptor.java --- .../java/binnie/core/machines/power/ComponentPowerReceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java index 3408749a7..887974770 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java @@ -163,7 +163,7 @@ private void addToEnergyNet() { if (world == null || world.isRemote) { return; } - if (world == null || Mods.IC2.active()) { + if (Mods.IC2.active()) { this.do_addToEnergyNet(); } } From f1c71869015c2fff517bbb92529859fb65581480 Mon Sep 17 00:00:00 2001 From: Russkih Anatoly Date: Tue, 10 Apr 2018 23:25:22 +1000 Subject: [PATCH 80/99] Update ComponentPowerReceptor.java --- .../java/binnie/core/machines/power/ComponentPowerReceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java index 887974770..1ee469d56 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java @@ -170,7 +170,7 @@ private void addToEnergyNet() { private void removeFromEnergyNet() { final World world = this.getMachine().getWorld(); - if (world.isRemote) { + if (world == null || world.isRemote) { return; } if (Mods.IC2.active()) { From 537ab84dac7678d9721981d846363bb8695f5710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Wed, 11 Apr 2018 14:02:00 +1000 Subject: [PATCH 81/99] Fix border painting in SearchDialog --- .../java/binnie/core/machines/storage/SearchDialog.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java index 51cf128f7..9c7ef4f5c 100644 --- a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java +++ b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java @@ -34,6 +34,7 @@ public class SearchDialog extends Dialog { private final Control slotGrid; private final WindowCompartment windowCompartment; + final ControlScrollableContent scroll; private String textSearch = StringUtils.EMPTY; private boolean sortByName; private boolean includeItems; @@ -43,7 +44,7 @@ public SearchDialog(WindowCompartment windowCompartment) { super(windowCompartment, 252, 192); this.windowCompartment = windowCompartment; - final ControlScrollableContent scroll = new SearchScrollContent(this); + scroll = new SearchScrollContent(this); this.slotGrid = new Control(scroll, 1, 1, 108, 18); scroll.setScrollableContent(this.slotGrid); new ControlPlayerInventory(this, true); @@ -110,7 +111,7 @@ private void updateSearch() { } while (y < 108 || x != 0) { // TODO: what was this supposed to do? - new ControlSlot.Builder(this.slotGrid, x, y); + //new ControlSlot.Builder(this.slotGrid, x, y); x += 18; if (x >= 108) { x = 0; @@ -131,7 +132,7 @@ public SearchScrollContent(SearchDialog searchDialog) { @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { RenderUtil.setColour(11184810); - CraftGUI.RENDER.texture(CraftGUITexture.OUTLINE, searchDialog.windowCompartment.getArea().inset(new Border(0, 6, 0, 0))); + CraftGUI.RENDER.texture(CraftGUITexture.OUTLINE, searchDialog.scroll.getArea().inset(new Border(0, 6, 0, 0))); } } From ec8f38691ca36cac36d998a052d7b55dc2be9c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Wed, 11 Apr 2018 15:16:53 +1000 Subject: [PATCH 82/99] Small clean up --- .../java/binnie/core/machines/storage/SearchDialog.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java index 9c7ef4f5c..ac3568d2b 100644 --- a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java +++ b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java @@ -25,6 +25,7 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -40,7 +41,7 @@ public class SearchDialog extends Dialog { private boolean includeItems; private boolean includeBlocks; - public SearchDialog(WindowCompartment windowCompartment) { + public SearchDialog(final WindowCompartment windowCompartment) { super(windowCompartment, 252, 192); this.windowCompartment = windowCompartment; @@ -68,8 +69,10 @@ private Map filter(final Map slotIds) { if (!stack.isEmpty()) { final String name = stack.getDisplayName().toLowerCase(); if (this.textSearch.length() == 0 || name.contains(this.textSearch)) { - if (this.includeBlocks || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) { - if (this.includeItems || Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) { + final Item item = stack.getItem(); + final Block block = Block.getBlockFromItem(item); + if (this.includeBlocks || block == Blocks.AIR) { + if (this.includeItems || block != Blocks.AIR) { slotIds.put(i, name); } } From e8794459d34bb7586f3c3aa324308ca1ebedc129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Thu, 12 Apr 2018 09:23:11 +1000 Subject: [PATCH 83/99] Remove unused empty Integer[] array anymore --- core/src/main/java/binnie/core/util/EmptyHelper.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/main/java/binnie/core/util/EmptyHelper.java b/core/src/main/java/binnie/core/util/EmptyHelper.java index d2bb984a3..ab910d323 100644 --- a/core/src/main/java/binnie/core/util/EmptyHelper.java +++ b/core/src/main/java/binnie/core/util/EmptyHelper.java @@ -29,8 +29,6 @@ private EmptyHelper() {} public static final IFluidTank[] FLUID_TANKS_EMPTY = new IFluidTank[0]; - public static final Integer[] DEFAULT_TABS_EMPTY = new Integer[0]; - public static final IProperty[] PROPERTIES_EMPTY = new IProperty[0]; public static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; From 2b6610819accd0946c346ab20d18e87f4c6b666d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Fri, 13 Apr 2018 11:35:23 +1000 Subject: [PATCH 84/99] Remove final from vars --- .../botany/genetics/FlowerBreedingSystem.java | 2 +- .../java/binnie/core/block/BlockMetadata.java | 12 +-- .../java/binnie/core/block/ItemMetadata.java | 4 +- .../binnie/core/block/TileEntityMetadata.java | 2 +- .../binnie/core/genetics/AlleleHelper.java | 78 +++++++++---------- .../binnie/core/genetics/BreedingSystem.java | 60 +++++++------- .../main/java/binnie/core/genetics/Gene.java | 8 +- .../binnie/core/genetics/ManagerGenetics.java | 30 +++---- .../binnie/core/gui/BinnieGUIHandler.java | 6 +- .../java/binnie/core/gui/KeyBindings.java | 2 +- .../main/java/binnie/core/gui/Tooltip.java | 4 +- .../java/binnie/core/gui/TopLevelWidget.java | 6 +- .../src/main/java/binnie/core/gui/Widget.java | 22 +++--- .../controls/ControlIndividualDisplay.java | 6 +- .../gui/controls/button/ControlButton.java | 2 +- .../core/gui/controls/page/ControlPage.java | 2 +- .../gui/database/PageSpeciesOverview.java | 2 +- .../gui/fieldkit/ControlChromoPicker.java | 4 +- .../core/gui/fieldkit/ControlChromosome.java | 10 +-- .../core/gui/fieldkit/WindowFieldKit.java | 16 ++-- .../core/gui/genesis/WindowGenesis.java | 46 +++++------ .../core/gui/minecraft/ContainerCraftGUI.java | 28 +++---- .../binnie/core/gui/minecraft/CustomSlot.java | 6 +- .../core/gui/minecraft/GuiCraftGUI.java | 16 ++-- .../binnie/core/gui/minecraft/Window.java | 2 +- .../minecraft/control/ControlEnergyBar.java | 18 ++--- .../minecraft/control/ControlErrorState.java | 4 +- .../minecraft/control/ControlItemDisplay.java | 2 +- .../minecraft/control/ControlLiquidTank.java | 18 ++--- .../control/ControlProgressBase.java | 10 +-- .../gui/minecraft/control/ControlSlot.java | 12 +-- .../minecraft/control/ControlSlotArray.java | 8 +- .../minecraft/control/ControlSlotBase.java | 4 +- .../minecraft/control/ControlSlotCharge.java | 4 +- .../gui/minecraft/control/ControlTabIcon.java | 8 +- .../binnie/core/gui/renderer/RenderUtil.java | 22 +++--- .../core/gui/renderer/TextureRenderer.java | 10 +-- .../stylesheet/StyleSheetManager.java | 6 +- .../resource/stylesheet/StyleSheetParser.java | 54 ++++++------- .../core/integration/jei/CoreJeiPlugin.java | 2 +- .../java/binnie/core/item/ItemGenesis.java | 2 +- .../main/java/binnie/core/item/ItemMisc.java | 8 +- .../java/binnie/core/item/ModuleItems.java | 2 +- .../binnie/core/liquid/AlcoholEffect.java | 2 +- .../core/liquid/FluidContainerType.java | 6 +- .../core/liquid/FluidHandlerItemBinnie.java | 6 +- .../java/binnie/core/liquid/FluidType.java | 2 +- .../core/liquid/ItemFluidContainer.java | 2 +- .../binnie/core/liquid/ManagerLiquid.java | 14 ++-- .../machines/base/TileEntityMachineBase.java | 4 +- .../core/machines/errors/ErrorState.java | 26 +++---- .../machines/errors/ErrorStateRegistry.java | 2 +- .../inventory/ComponentChargedSlots.java | 2 +- .../inventory/ComponentInventory.java | 2 +- .../inventory/ComponentInventorySlots.java | 36 ++++----- .../inventory/ComponentInventoryTransfer.java | 18 ++--- .../inventory/ComponentTankContainer.java | 24 +++--- .../machines/inventory/InventorySlot.java | 2 +- .../core/machines/inventory/MachineSide.java | 8 +- .../core/machines/inventory/SidedAccess.java | 16 ++-- .../core/machines/inventory/TankSlot.java | 4 +- .../power/ComponentPowerReceptor.java | 10 +-- .../core/machines/power/ComponentProcess.java | 2 +- .../binnie/core/machines/power/TankInfo.java | 4 +- .../machines/render/RenderTESRMachine.java | 6 +- .../storage/ComponentBinnieCoreGUI.java | 2 +- .../ComponentCompartmentInventory.java | 2 +- .../core/machines/storage/SearchDialog.java | 2 +- .../java/binnie/core/util/EmptyHelper.java | 2 + .../java/binnie/core/util/FluidStackUtil.java | 12 +-- .../main/java/binnie/core/util/NBTUtil.java | 10 +-- 71 files changed, 400 insertions(+), 398 deletions(-) diff --git a/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java b/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java index 7a610966e..485191bf7 100644 --- a/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java +++ b/botany/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java @@ -41,7 +41,7 @@ public FlowerBreedingSystem() { } @Override - public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) { + public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies) { return mutation.getBaseChance(); } diff --git a/core/src/main/java/binnie/core/block/BlockMetadata.java b/core/src/main/java/binnie/core/block/BlockMetadata.java index bd030e0b9..b3bc26963 100644 --- a/core/src/main/java/binnie/core/block/BlockMetadata.java +++ b/core/src/main/java/binnie/core/block/BlockMetadata.java @@ -23,16 +23,16 @@ public BlockMetadata(final Material material) { } public static ItemStack getBlockDropped(IBlockMetadata block, IBlockAccess world, BlockPos pos) { - final TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); + TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); if (tile != null && !tile.hasDroppedBlock()) { - final int meta = block.getDroppedMeta(world.getBlockState(pos), tile.getTileMetadata()); + int meta = block.getDroppedMeta(world.getBlockState(pos), tile.getTileMetadata()); return TileEntityMetadata.getItemStack((Block) block, meta); } return ItemStack.EMPTY; } public static void getDrops(NonNullList drops, IBlockMetadata block, IBlockAccess world, BlockPos pos) { - final ItemStack drop = getBlockDropped(block, world, pos); + ItemStack drop = getBlockDropped(block, world, pos); if (!drop.isEmpty()) { drops.add(drop); } @@ -40,8 +40,8 @@ public static void getDrops(NonNullList drops, IBlockMetadata block, public static boolean breakBlock(IBlockMetadata blockMetadata, @Nullable EntityPlayer player, World world, BlockPos pos) { List drops = null; - final Block block = (Block) blockMetadata; - final TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); + Block block = (Block) blockMetadata; + TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); if (tile != null && !tile.hasDroppedBlock()) { drops = block.getDrops(world, pos, world.getBlockState(pos), 0); } @@ -56,7 +56,7 @@ public static boolean breakBlock(IBlockMetadata blockMetadata, @Nullable EntityP } public static ItemStack getPickBlock(World world, BlockPos pos) { - final Block block = world.getBlockState(pos).getBlock(); + Block block = world.getBlockState(pos).getBlock(); return getBlockDropped((IBlockMetadata) block, world, pos); } diff --git a/core/src/main/java/binnie/core/block/ItemMetadata.java b/core/src/main/java/binnie/core/block/ItemMetadata.java index 806740e8c..a85a6ca9b 100644 --- a/core/src/main/java/binnie/core/block/ItemMetadata.java +++ b/core/src/main/java/binnie/core/block/ItemMetadata.java @@ -27,7 +27,7 @@ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, B if (!(block instanceof IBlockMetadata)) { return false; } - final int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, pos, side); + int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, pos, side); if (placedMeta < 0) { return false; } @@ -35,7 +35,7 @@ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, B return false; } if (world.getBlockState(pos).getBlock() == block) { - final TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); + TileEntityMetadata tile = TileEntityMetadata.getTile(world, pos); if (tile != null) { tile.setTileMetadata(placedMeta, false); } diff --git a/core/src/main/java/binnie/core/block/TileEntityMetadata.java b/core/src/main/java/binnie/core/block/TileEntityMetadata.java index 6540302ba..df8c4f3e1 100644 --- a/core/src/main/java/binnie/core/block/TileEntityMetadata.java +++ b/core/src/main/java/binnie/core/block/TileEntityMetadata.java @@ -99,7 +99,7 @@ public void setTileMetadata(final int meta, final boolean notify) { if (this.meta != meta) { this.meta = meta; if (notify) { - final IBlockState state = world.getBlockState(pos); + IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 3); } } diff --git a/core/src/main/java/binnie/core/genetics/AlleleHelper.java b/core/src/main/java/binnie/core/genetics/AlleleHelper.java index 713371757..bb8a8613b 100644 --- a/core/src/main/java/binnie/core/genetics/AlleleHelper.java +++ b/core/src/main/java/binnie/core/genetics/AlleleHelper.java @@ -18,78 +18,78 @@ import javax.annotation.Nullable; public class AlleleHelper extends forestry.core.genetics.alleles.AlleleHelper { - public static IAllele getAllele(final EnumTemperature temperature) { + public static IAllele getAllele(EnumTemperature temperature) { return getAllele(getUid(temperature)); } - public static IAllele getAllele(final EnumHumidity humidity) { + public static IAllele getAllele(EnumHumidity humidity) { return getAllele(getUid(humidity)); } - public static IAllele getAllele(final EnumTolerance tolerance) { + public static IAllele getAllele(EnumTolerance tolerance) { return getAllele(getUid(tolerance)); } - public static IAllele getAllele(final EnumAllele.Fertility fertility) { + public static IAllele getAllele(EnumAllele.Fertility fertility) { return getAllele(getUid(fertility)); } - public static IAllele getAllele(final EnumAllele.Territory territory) { + public static IAllele getAllele(EnumAllele.Territory territory) { return getAllele(getUid(territory)); } - public static IAllele getAllele(final EnumAllele.Lifespan lifespan) { + public static IAllele getAllele(EnumAllele.Lifespan lifespan) { return getAllele(getUid(lifespan)); } - public static IAllele getAllele(final EnumAllele.Sappiness sappiness) { + public static IAllele getAllele(EnumAllele.Sappiness sappiness) { return getAllele(getUid(sappiness)); } - public static IAllele getAllele(final EnumAllele.Speed speed) { + public static IAllele getAllele(EnumAllele.Speed speed) { return getAllele(getUid(speed)); } - public static IAllele getAllele(final EnumAllele.Flowering flowering) { + public static IAllele getAllele(EnumAllele.Flowering flowering) { return getAllele(getUid(flowering)); } - public static IAllele getAllele(final EnumAllele.Height height) { + public static IAllele getAllele(EnumAllele.Height height) { return getAllele(getUid(height)); } - public static IAllele getAllele(final EnumAllele.Maturation maturation) { + public static IAllele getAllele(EnumAllele.Maturation maturation) { return getAllele(getUid(maturation)); } - public static IAllele getAllele(final EnumAllele.Yield yield) { + public static IAllele getAllele(EnumAllele.Yield yield) { return getAllele(getUid(yield)); } - public static IAllele getAllele(final EnumAllele.Saplings saplings) { + public static IAllele getAllele(EnumAllele.Saplings saplings) { return getAllele(getUid(saplings)); } - public static IAllele getAllele(final int number) { + public static IAllele getAllele(int number) { return getAllele("forestry.i" + number + 'd'); } - public static IAllele getAllele(final boolean bool) { + public static IAllele getAllele(boolean bool) { if (bool) { return getAllele("forestry.boolTrue"); } return getAllele("forestry.boolFalse"); } - public static IAllele getAllele(final String uid) { + public static IAllele getAllele(String uid) { return AlleleManager.alleleRegistry.getAllele(uid); } - public static String toDisplay(final EnumTemperature temperature) { + public static String toDisplay(EnumTemperature temperature) { return AlleleManager.climateHelper.toDisplay(temperature); } - public static String toDisplay(final EnumHumidity humidity) { + public static String toDisplay(EnumHumidity humidity) { return AlleleManager.climateHelper.toDisplay(humidity); } @@ -105,46 +105,46 @@ public static String toDisplay(final EnumHumidity humidity) { // return I18N.localise("botany.soil." + soilType.getName()); // } - public static String toDisplay(final EnumTolerance tolerance) { + public static String toDisplay(EnumTolerance tolerance) { return toAlleleDisplay("tolerance", tolerance.name()); } - public static String toDisplay(final EnumAllele.Flowering flowering) { + public static String toDisplay(EnumAllele.Flowering flowering) { if (flowering == EnumAllele.Flowering.AVERAGE) { return toAlleleDisplay("flowering", "normal"); } return toAlleleDisplay(null, flowering.name()); } - public static String toDisplay(final EnumAllele.Speed speed) { + public static String toDisplay(EnumAllele.Speed speed) { return toAlleleDisplay(null, speed.name()); } - public static String toDisplay(final EnumAllele.Lifespan lifespan) { + public static String toDisplay(EnumAllele.Lifespan lifespan) { return toAlleleDisplay("lifespan", lifespan.name()); } - public static String getUid(final EnumAllele.Fertility fertility) { + public static String getUid(EnumAllele.Fertility fertility) { return getUid("fertility", fertility.name()); } - public static String getUid(final EnumAllele.Lifespan lifespan) { + public static String getUid(EnumAllele.Lifespan lifespan) { return getUid("lifespan", lifespan.name()); } - public static String getUid(final EnumAllele.Sappiness sappiness) { + public static String getUid(EnumAllele.Sappiness sappiness) { return getUid("sappiness", sappiness.name()); } - private static String getUid(final EnumTemperature temperature) { + private static String getUid(EnumTemperature temperature) { return getUid("temperature", temperature.name()); } - private static String getUid(final EnumHumidity humidity) { + private static String getUid(EnumHumidity humidity) { return getUid("humidity", humidity.name()); } - public static String getUid(final EnumAllele.Saplings saplings) { + public static String getUid(EnumAllele.Saplings saplings) { if (saplings == EnumAllele.Saplings.AVERAGE) { return getUid("saplings", "Default"); } @@ -157,51 +157,51 @@ public static String getUid(final EnumAllele.Saplings saplings) { return getUid("saplings", saplings.name()); } - public static String getUid(final EnumAllele.Height height) { + public static String getUid(EnumAllele.Height height) { if (height == EnumAllele.Height.AVERAGE) { return getUid("height", "Max10", false); } return getUid("height", height.name()); } - public static String getUid(final EnumAllele.Maturation maturation) { + public static String getUid(EnumAllele.Maturation maturation) { return getUid("maturation", maturation.name()); } - public static String getUid(final EnumAllele.Territory territory) { + public static String getUid(EnumAllele.Territory territory) { return getUid("territory", territory.name()); } - public static String getUid(final EnumAllele.Yield yield) { + public static String getUid(EnumAllele.Yield yield) { if (yield == EnumAllele.Yield.AVERAGE) { return getUid("yield", "Default", false); } return getUid("yield", yield.name()); } - public static String getUid(final EnumAllele.Fireproof fireproof) { + public static String getUid(EnumAllele.Fireproof fireproof) { return getUid("bool", fireproof.name()); } - public static String getUid(final EnumAllele.Flowering flowering) { + public static String getUid(EnumAllele.Flowering flowering) { return getUid("flowering", flowering.name()); } - public static String getUid(final EnumTolerance tolerance) { + public static String getUid(EnumTolerance tolerance) { return getUid("tolerance", tolerance.name()); } - public static String getUid(final EnumAllele.Speed speed) { + public static String getUid(EnumAllele.Speed speed) { return getUid("speed", speed.name()); } - protected static String getUid(final String key, final String valueName) { + protected static String getUid(String key, String valueName) { return getUid(key, valueName, true); } private static final Pattern PATTERN_REPLACEMENT = Pattern.compile("_"); - private static String getUid(final String key, String valueName, final boolean needCapitalize) { + private static String getUid(String key, String valueName, boolean needCapitalize) { if (needCapitalize) { valueName = WordUtils.capitalize(valueName.toLowerCase(Locale.ENGLISH)); } @@ -209,7 +209,7 @@ private static String getUid(final String key, String valueName, final boolean n return "forestry." + key + valueName; } - private static String toAlleleDisplay(final @Nullable String key, final String valueName) { + private static String toAlleleDisplay(@Nullable String key, String valueName) { String name = PATTERN_REPLACEMENT.matcher(valueName.toLowerCase()).replaceAll(StringUtils.EMPTY); if (key == null) { return I18N.localise("forestry.allele." + name); diff --git a/core/src/main/java/binnie/core/genetics/BreedingSystem.java b/core/src/main/java/binnie/core/genetics/BreedingSystem.java index 9d11dfef0..eebede49f 100644 --- a/core/src/main/java/binnie/core/genetics/BreedingSystem.java +++ b/core/src/main/java/binnie/core/genetics/BreedingSystem.java @@ -126,26 +126,26 @@ public final Collection getAllMutations() { @Override public void calculateArrays() { - final ISpeciesRoot speciesRoot = getSpeciesRoot(); + ISpeciesRoot speciesRoot = getSpeciesRoot(); calculateAlleles(speciesRoot); calculateBranches(speciesRoot); calculateMutations(speciesRoot); } @Override - public void calculateAlleles(final ISpeciesRoot speciesRoot) { + public void calculateAlleles(ISpeciesRoot speciesRoot) { this.allSpecies.clear(); this.allActiveSpecies.clear(); this.resultantMutations.clear(); this.furtherMutations.clear(); this.allResultantMutations.clear(); this.allFurtherMutations.clear(); - final Collection allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values(); - for (final IAllele allele : allAlleles) { + Collection allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values(); + for (IAllele allele : allAlleles) { String uid = allele.getUID(); - final IAllele[] template = speciesRoot.getTemplate(uid); + IAllele[] template = speciesRoot.getTemplate(uid); if (template != null) { - final IAlleleSpecies species = (IAlleleSpecies) allele; + IAlleleSpecies species = (IAlleleSpecies) allele; this.allSpecies.add(species); if (isBlacklisted(allele) || uid.contains("speciesBotAlfheim")) { continue; @@ -156,16 +156,16 @@ public void calculateAlleles(final ISpeciesRoot speciesRoot) { } @Override - public void calculateBranches(final ISpeciesRoot speciesRoot) { - final Collection allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values(); + public void calculateBranches(ISpeciesRoot speciesRoot) { + Collection allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values(); this.allBranches.clear(); - for (final IClassification branch : allRegBranches) { - final IAlleleSpecies[] species = branch.getMemberSpecies(); + for (IClassification branch : allRegBranches) { + IAlleleSpecies[] species = branch.getMemberSpecies(); if (species.length == 0) { continue; } - final IAlleleSpecies firstSpecies = species[0]; - final IAllele[] template = speciesRoot.getTemplate(firstSpecies.getUID()); + IAlleleSpecies firstSpecies = species[0]; + IAllele[] template = speciesRoot.getTemplate(firstSpecies.getUID()); if (template != null) { for (final IAlleleSpecies species2 : branch.getMemberSpecies()) { if (allActiveSpecies.contains(species2)) { @@ -180,24 +180,24 @@ public void calculateBranches(final ISpeciesRoot speciesRoot) { @Override public void calculateMutations(ISpeciesRoot speciesRoot) { this.allMutations.clear(); - final List speciesMutations = speciesRoot.getMutations(false); + List speciesMutations = speciesRoot.getMutations(false); if (speciesMutations.isEmpty()) { return; } - final Set mutations = new LinkedHashSet<>(speciesMutations); - for (final IMutation mutation : mutations) { + Set mutations = new LinkedHashSet<>(speciesMutations); + for (IMutation mutation : mutations) { this.allMutations.add(mutation); - final Set participatingSpecies = new LinkedHashSet<>(); + Set participatingSpecies = new LinkedHashSet<>(); participatingSpecies.add(mutation.getAllele0()); participatingSpecies.add(mutation.getAllele1()); - for (final IAlleleSpecies species : participatingSpecies) { + for (IAlleleSpecies species : participatingSpecies) { this.allFurtherMutations.put(species, mutation); if (this.allActiveSpecies.contains(species)) { this.furtherMutations.put(species, mutation); } } - final IAllele[] template = mutation.getTemplate(); - final IAlleleSpecies speciesAllele = (IAlleleSpecies) template[0]; + IAllele[] template = mutation.getTemplate(); + IAlleleSpecies speciesAllele = (IAlleleSpecies) template[0]; this.allResultantMutations.put(speciesAllele, mutation); this.resultantMutations.put(speciesAllele, mutation); } @@ -262,7 +262,7 @@ public final boolean isSecret(final IClassification branch) { @Override public final Collection getDiscoveredBranches(final World world, final GameProfile player) { final List branches = new ArrayList<>(); - for (final IClassification branch : this.allBranches) { + for (IClassification branch : this.allBranches) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, world, player)) { branches.add(branch); @@ -276,7 +276,7 @@ public final Collection getDiscoveredBranches(final World world @Override public final Collection getDiscoveredBranches(final IBreedingTracker tracker) { final List branches = new ArrayList<>(); - for (final IClassification branch : this.allBranches) { + for (IClassification branch : this.allBranches) { for (final IAlleleSpecies species : branch.getMemberSpecies()) { if (this.isSpeciesDiscovered(species, tracker)) { branches.add(branch); @@ -332,7 +332,7 @@ public TextureAtlasSprite getDiscoveredIcon() { } @Override - public abstract float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies); + public abstract float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies); @Override @SubscribeEvent @@ -420,7 +420,7 @@ public final String getIdent() { @Override public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) { if (allele instanceof IAlleleBoolean) { - final IAlleleBoolean alleleBoolean = (IAlleleBoolean) allele; + IAlleleBoolean alleleBoolean = (IAlleleBoolean) allele; return alleleBoolean.getValue() ? I18N.localise("binniecore.allele.true") : I18N.localise("binniecore.allele.false"); } if (Objects.equals(allele.getAlleleName(), "for.gui.maximum")) { @@ -436,8 +436,8 @@ public String getName() { @Override public ItemStack getItemStackRepresentitive() { - final ISpeciesRoot root = this.getSpeciesRoot(); - final IIndividual first = root.getIndividualTemplates().get(0); + ISpeciesRoot root = this.getSpeciesRoot(); + IIndividual first = root.getIndividualTemplates().get(0); return root.getMemberStack(first, this.getDefaultType()); } @@ -454,7 +454,7 @@ public IIndividual getConversion(final ItemStack stack) { @Override public final IIndividual getDefaultIndividual() { - final ISpeciesRoot root = this.getSpeciesRoot(); + ISpeciesRoot root = this.getSpeciesRoot(); return root.templateAsIndividual(root.getDefaultTemplate()); } @@ -468,7 +468,7 @@ public final ISpeciesType getDefaultType() { @Override public ItemStack getConversionStack(final ItemStack stack) { - final IIndividual conversion = this.getConversion(stack); + IIndividual conversion = this.getConversion(stack); if (conversion == null) { return ItemStack.EMPTY; } @@ -486,7 +486,7 @@ public final Collection getActiveKaryotype() { @Override public ItemStack getDefaultMember(final String uid) { - final IIndividual individual = this.getIndividual(uid); + IIndividual individual = this.getIndividual(uid); if (individual == null) { return ItemStack.EMPTY; } @@ -496,8 +496,8 @@ public ItemStack getDefaultMember(final String uid) { @Override @Nullable public IIndividual getIndividual(String uid) { - final ISpeciesRoot root = this.getSpeciesRoot(); - final IAllele[] template = root.getTemplate(uid); + ISpeciesRoot root = this.getSpeciesRoot(); + IAllele[] template = root.getTemplate(uid); if (template == null) { return null; } diff --git a/core/src/main/java/binnie/core/genetics/Gene.java b/core/src/main/java/binnie/core/genetics/Gene.java index 198a02a02..1ea2b8d41 100644 --- a/core/src/main/java/binnie/core/genetics/Gene.java +++ b/core/src/main/java/binnie/core/genetics/Gene.java @@ -26,8 +26,8 @@ public Gene(final IAllele allele, final IChromosomeType chromosome, final ISpeci public Gene(final NBTTagCompound nbt) { this.allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele")); - final String rootKey = nbt.getString("root"); - final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); + String rootKey = nbt.getString("root"); + ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); Preconditions.checkArgument(root != null, "Could not find root: %s", rootKey); this.root = root; final int chromoID = nbt.getByte("chromo"); @@ -56,8 +56,8 @@ public String toString() { @Override public void readFromNBT(final NBTTagCompound nbt) { this.allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele")); - final String rootKey = nbt.getString("root"); - final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); + String rootKey = nbt.getString("root"); + ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(rootKey); Preconditions.checkArgument(root != null, "Could not find root: %s", rootKey); this.root = root; final int chromoID = nbt.getByte("chromo"); diff --git a/core/src/main/java/binnie/core/genetics/ManagerGenetics.java b/core/src/main/java/binnie/core/genetics/ManagerGenetics.java index ba274504d..e92d94684 100644 --- a/core/src/main/java/binnie/core/genetics/ManagerGenetics.java +++ b/core/src/main/java/binnie/core/genetics/ManagerGenetics.java @@ -64,18 +64,18 @@ public static boolean isAnalysed(final ItemStack stack) { return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack); } - public static ItemStack analyse(ItemStack stack, final World world, final GameProfile username) { + public static ItemStack analyse(ItemStack stack, World world, GameProfile username) { if (!stack.isEmpty()) { - final ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy(); + ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy(); if (!conv.isEmpty()) { conv.setCount(stack.getCount()); stack = conv; } - final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack); + ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack); if (root != null) { final IIndividual ind = root.getMember(stack); ind.analyze(); - final IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username); + IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username); breedingTracker.registerBirth(ind); final NBTTagCompound nbttagcompound = new NBTTagCompound(); ind.writeToNBT(nbttagcompound); @@ -105,8 +105,8 @@ public IBreedingSystem getSystem(final String string) { } public IBreedingSystem getSystem(final ISpeciesRoot root) { - final String rootUID = root.getUID(); - final IBreedingSystem system = this.getSystem(rootUID); + String rootUID = root.getUID(); + IBreedingSystem system = this.getSystem(rootUID); Preconditions.checkState(system != null, "Could not find system for species root %s", rootUID); return system; } @@ -124,8 +124,8 @@ public Collection getActiveSystems() { } public IBreedingSystem getFirstActiveSystem() { - final Collection activeSystems = getActiveSystems(); - final IBreedingSystem first = Iterables.getFirst(activeSystems, null); + Collection activeSystems = getActiveSystems(); + IBreedingSystem first = Iterables.getFirst(activeSystems, null); if (first == null) { throw new IllegalStateException("There are no breeding systems"); } @@ -180,14 +180,14 @@ private void loadAlleles() { this.invalidChromosomeTypes.clear(); final ComparatorAllele comparator = new ComparatorAllele(); for (IBreedingSystem system : BREEDING_SYSTEMS.values()) { - final ISpeciesRoot root = system.getSpeciesRoot(); - final Map> chromosomeMap = new LinkedHashMap<>(); - for (final IChromosomeType chromosome : root.getKaryotype()) { - final TreeSet alleles = new TreeSet<>(comparator); + ISpeciesRoot root = system.getSpeciesRoot(); + Map> chromosomeMap = new LinkedHashMap<>(); + for (IChromosomeType chromosome : root.getKaryotype()) { + TreeSet alleles = new TreeSet<>(comparator); for (IIndividual individual : root.getIndividualTemplates()) { - final IGenome genome = individual.getGenome(); - final IAllele activeAllele = genome.getActiveAllele(chromosome); - final IAllele inactiveAllele = genome.getInactiveAllele(chromosome); + IGenome genome = individual.getGenome(); + IAllele activeAllele = genome.getActiveAllele(chromosome); + IAllele inactiveAllele = genome.getInactiveAllele(chromosome); if (chromosome.getAlleleClass().isInstance(activeAllele)) { alleles.add(activeAllele); } diff --git a/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java b/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java index 470ae0696..4f804e49b 100644 --- a/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java +++ b/core/src/main/java/binnie/core/gui/BinnieGUIHandler.java @@ -21,7 +21,7 @@ public BinnieGUIHandler(final IBinnieGUID[] guiIds) { @Override @Nullable public final Object getServerGuiElement(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z) { - final Window window = this.getWindow(id, player, world, x, y, z, Side.SERVER); + Window window = this.getWindow(id, player, world, x, y, z, Side.SERVER); if (window == null) { return null; } @@ -36,7 +36,7 @@ public final Object getClientGuiElement(final int id, final EntityPlayer player, if (!world.isRemote) { return this.getServerGuiElement(id, player, world, x, y, z); } - final Window window = this.getWindow(id, player, world, x, y, z, Side.CLIENT); + Window window = this.getWindow(id, player, world, x, y, z, Side.CLIENT); if (window == null) { return null; } @@ -45,7 +45,7 @@ public final Object getClientGuiElement(final int id, final EntityPlayer player, @Nullable public Window getWindow(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) { - for (final IBinnieGUID guid : guiIds) { + for (IBinnieGUID guid : guiIds) { if (guid.ordinal() == id) { return guid.getWindow(player, world, x, y, z, side); } diff --git a/core/src/main/java/binnie/core/gui/KeyBindings.java b/core/src/main/java/binnie/core/gui/KeyBindings.java index 0456e3508..0c9c91e3f 100644 --- a/core/src/main/java/binnie/core/gui/KeyBindings.java +++ b/core/src/main/java/binnie/core/gui/KeyBindings.java @@ -28,7 +28,7 @@ private KeyBindings() { } public static void init() { - for (final KeyBinding binding : allBindings) { + for (KeyBinding binding : allBindings) { ClientRegistry.registerKeyBinding(binding); } } diff --git a/core/src/main/java/binnie/core/gui/Tooltip.java b/core/src/main/java/binnie/core/gui/Tooltip.java index e1165fd6f..d089805f9 100644 --- a/core/src/main/java/binnie/core/gui/Tooltip.java +++ b/core/src/main/java/binnie/core/gui/Tooltip.java @@ -71,7 +71,7 @@ public void setType(final ITooltipType type) { * Add a tooltip that also displays an itemStack on the tooltip directly. */ public void add(ItemStack itemStack, String string) { - final NBTTagCompound nbt = new NBTTagCompound(); + NBTTagCompound nbt = new NBTTagCompound(); itemStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_ITEM); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); @@ -81,7 +81,7 @@ public void add(ItemStack itemStack, String string) { * Add a tooltip that also displays an fluidStack on the tooltip directly. */ public void add(FluidStack fluidStack, String string) { - final NBTTagCompound nbt = new NBTTagCompound(); + NBTTagCompound nbt = new NBTTagCompound(); fluidStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_FLUID); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); diff --git a/core/src/main/java/binnie/core/gui/TopLevelWidget.java b/core/src/main/java/binnie/core/gui/TopLevelWidget.java index 040a4b8b6..4984945c2 100644 --- a/core/src/main/java/binnie/core/gui/TopLevelWidget.java +++ b/core/src/main/java/binnie/core/gui/TopLevelWidget.java @@ -157,14 +157,14 @@ public Deque calculateMousedOverWidgets() { } private Collection getQueuedWidgets(final IWidget widget) { - final List widgets = new ArrayList<>(); + List widgets = new ArrayList<>(); boolean addChildren = true; - final IArea croppedZone = widget.getCroppedZone(); + IArea croppedZone = widget.getCroppedZone(); if (croppedZone != null) { addChildren = croppedZone.contains(widget.getCropWidget().getRelativeMousePosition()); } if (addChildren) { - final ListIterator iterator = widget.getChildren().listIterator(widget.getChildren().size()); + ListIterator iterator = widget.getChildren().listIterator(widget.getChildren().size()); while (iterator.hasPrevious()) { final IWidget child = iterator.previous(); widgets.addAll(this.getQueuedWidgets(child)); diff --git a/core/src/main/java/binnie/core/gui/Widget.java b/core/src/main/java/binnie/core/gui/Widget.java index f62427d44..6d2fbc783 100644 --- a/core/src/main/java/binnie/core/gui/Widget.java +++ b/core/src/main/java/binnie/core/gui/Widget.java @@ -91,7 +91,7 @@ public void addChild(IWidget child) { if(child == null){ return; } - final IWidget topWidget = getTopChild(); + IWidget topWidget = getTopChild(); if (topWidget != null && topWidget.hasAttribute(Attribute.ALWAYS_ON_TOP)) { this.children.add(this.children.size() - 1, child); } else { @@ -115,11 +115,11 @@ public final List getChildren() { @Override @Nullable public W getWidget(Class widgetClass) { - for (final IWidget child : this.getChildren()) { + for (IWidget child : this.getChildren()) { if (widgetClass.isInstance(child)) { return widgetClass.cast(child); } - final W found = child.getWidget(widgetClass); + W found = child.getWidget(widgetClass); if (found != null) { return found; } @@ -132,7 +132,7 @@ public IWidget getTopChild() { if(children.isEmpty()){ return null; } - final int childrenCount = getChildren().size(); + int childrenCount = getChildren().size(); return children.get(childrenCount - 1); } @@ -191,7 +191,7 @@ public final void setCroppedZone(final IWidget relative, final IArea area) { @Override public final IPoint getAbsolutePosition() { - final IWidget parent = this.getParent(); + IWidget parent = this.getParent(); return parent == null ? this.getPosition() : parent.getAbsolutePosition().add(this.getPosition()); } @@ -271,14 +271,14 @@ public void callEvent(final Event event) { @Override @SuppressWarnings("unchecked") public void receiveEvent(Event event) { - for (final EventHandler handler : this.eventHandlers) { + for (EventHandler handler : this.eventHandlers) { if (handler.handles(event)) { ((EventHandler) handler).onEvent(event); } } - final List children = new LinkedList<>(getChildren()); - for (final IWidget child : children) { + List children = new LinkedList<>(getChildren()); + for (IWidget child : children) { child.receiveEvent(event); } } @@ -295,7 +295,7 @@ public IPoint getMousePosition() { @Override public final IPoint getRelativeMousePosition() { - final IWidget parent = this.getParent(); + IWidget parent = this.getParent(); return parent == null ? this.getMousePosition() : parent.getRelativeMousePosition().sub(this.getPosition()); } @@ -388,7 +388,7 @@ public void onRenderOverlay() { /* STATES*/ @Override public boolean isEnabled() { - final IWidget parent = this.getParent(); + IWidget parent = this.getParent(); return parent == null || parent.isEnabled(); } @@ -407,7 +407,7 @@ public final void hide() { @Override public final boolean isVisible() { if (this.visible) { - final IWidget parent = this.getParent(); + IWidget parent = this.getParent(); return parent == null || parent.isVisible() && parent.isChildVisible(this); } return false; diff --git a/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java b/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java index b405e9b5b..19a4f8443 100644 --- a/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java +++ b/core/src/main/java/binnie/core/gui/controls/ControlIndividualDisplay.java @@ -20,18 +20,18 @@ public ControlIndividualDisplay(IWidget parent, int x, int y, IIndividual ind) { public ControlIndividualDisplay(IWidget parent, int x, int y, int size, IIndividual ind) { super(parent, x, y, size); - final IBreedingSystem system = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot()); + IBreedingSystem system = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot()); setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType())); setTooltip(); } @Override public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) { - final ItemStack stack = getItemStack(); + ItemStack stack = getItemStack(); if (stack.isEmpty()) { return; } - final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack); + IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack); if (ind == null) { return; } diff --git a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java index 9d27226af..ad2f3042a 100644 --- a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java +++ b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java @@ -42,7 +42,7 @@ protected void onMouseClick(final EventMouse.Down event) { @Override public void onUpdateClient() { if (this.textWidget != null) { - final String text = this.getText(); + String text = this.getText(); if (text != null) { this.textWidget.setValue(text); } diff --git a/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java b/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java index fcb0f1ab8..ae9f757e0 100644 --- a/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java +++ b/core/src/main/java/binnie/core/gui/controls/page/ControlPage.java @@ -15,7 +15,7 @@ public ControlPage(final IWidget parent, final int x, final int y, final int w, super(parent, x, y, w, h); this.value = value; if (parent instanceof IControlValue) { - final IControlValue controlValue = (IControlValue) parent; + IControlValue controlValue = (IControlValue) parent; if (controlValue.getValue() == null) { controlValue.setValue(value); } diff --git a/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java b/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java index b73984ba6..26ac73f0a 100644 --- a/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java +++ b/core/src/main/java/binnie/core/gui/database/PageSpeciesOverview.java @@ -54,7 +54,7 @@ public void onValueChanged(final IAlleleSpecies species) { this.controlAuthority.setValue(I18N.localise(DatabaseConstants.KEY + ".discovered") + ": " + TextFormatting.BOLD + species.getAuthority()); this.controlComplexity.setValue(I18N.localise(DatabaseConstants.KEY + ".overview.complexity") + ": " + species.getComplexity()); final String desc = species.getDescription(); - final StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString()); + StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString()); String descSig = StringUtils.EMPTY; if (desc == null || desc.length() == 0 || desc.contains("for.description") || desc.contains(".desc")) { descBody.append(I18N.localise(DatabaseConstants.KEY + ".no.description")); diff --git a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java index f57fe421b..fa0e0cab2 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromoPicker.java @@ -44,8 +44,8 @@ public ControlChromoPicker(ControlChromosome parent, int x, int y, IChromosomeTy @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { super.onRenderBackground(guiWidth, guiHeight); - final boolean selected = isMouseOver(); - final Texture text = selected ? this.selected : texture; + boolean selected = isMouseOver(); + Texture text = selected ? this.selected : texture; CraftGUI.RENDER.texture(text, Point.ZERO); } diff --git a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java index eee8a0cbb..521f6178e 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/ControlChromosome.java @@ -39,11 +39,11 @@ public void setSystem(@Nullable IBreedingSystem breedingSystem) { deleteAllChildren(); if (breedingSystem != null) { - final IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); + IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); for (Map.Entry entry : fieldKitPlugin.getChromosomePickerPositions().entrySet()) { - final IChromosomeType chromosomeType = entry.getKey(); - final IPoint position = entry.getValue(); + IChromosomeType chromosomeType = entry.getKey(); + IPoint position = entry.getValue(); new ControlChromoPicker(this, position.xPos(), position.yPos(), chromosomeType); } } @@ -67,7 +67,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { return; } super.onRenderBackground(guiWidth, guiHeight); - final ITexture texture = getTypeTexture(); + ITexture texture = getTypeTexture(); CraftGUI.RENDER.texture(texture, Point.ZERO); } @@ -76,7 +76,7 @@ private ITexture getTypeTexture() { if (breedingSystem == null) { return null; } - final IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); + IFieldKitPlugin fieldKitPlugin = breedingSystem.getFieldKitPlugin(); return fieldKitPlugin.getTypeTexture(); } } diff --git a/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java b/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java index 87cd86554..8613f509d 100644 --- a/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java +++ b/core/src/main/java/binnie/core/gui/fieldkit/WindowFieldKit.java @@ -86,7 +86,7 @@ protected String getBackgroundTextureName() { } private void setupValidators() { - final WindowInventory inventory = this.getWindowInventory(); + WindowInventory inventory = this.getWindowInventory(); inventory.setValidator(INDIVIDUAL_SLOT, new SlotValidatorIndividual(null)); inventory.setValidator(PAPER_SLOT, new SlotValidatorPaper(null)); inventory.disableAutoDispense(PAPER_SLOT); @@ -97,7 +97,7 @@ private void setupValidators() { public void initialiseClient() { this.setTitle(I18N.localise("binniecore.gui.fieldkit.title")); CraftGUI.RENDER.setStyleSheet(StyleSheetManager.getSheet(StyleSheetManager.PUNNETT_SHEET)); - final WindowInventory inventory = this.getWindowInventory(); + WindowInventory inventory = this.getWindowInventory(); inventory.createSlot(INDIVIDUAL_SLOT); inventory.createSlot(PAPER_SLOT); this.setupValidators(); @@ -123,7 +123,7 @@ public void initialiseClient() { @Override public void initialiseServer() { //create slots - final WindowInventory inventory = this.getWindowInventory(); + WindowInventory inventory = this.getWindowInventory(); final ItemStack kit = this.getPlayer().getHeldItemMainhand(); final int sheets = 64 - kit.getItemDamage(); inventory.createSlot(INDIVIDUAL_SLOT); @@ -172,7 +172,7 @@ private void refreshSpecies() { if (root == null) { return; } - final IBreedingSystem system = Binnie.GENETICS.getSystem(root); + IBreedingSystem system = Binnie.GENETICS.getSystem(root); this.chromo.setSystem(system); final Random rand = new Random(); this.info.clear(); @@ -197,13 +197,13 @@ private void refreshSpecies() { @Override public void onWindowInventoryChanged() { super.onWindowInventoryChanged(); - final WindowInventory inventory = getWindowInventory(); + WindowInventory inventory = getWindowInventory(); if (this.isServer()) { final ItemStack kit = this.getPlayer().getHeldItemMainhand(); if (kit.isEmpty() || !kit.getItem().equals(BinnieCore.getFieldKit())) { return; } - final ItemStack paper = inventory.getStackInSlot(PAPER_SLOT); + ItemStack paper = inventory.getStackInSlot(PAPER_SLOT); final int sheets = 64 - kit.getItemDamage(); final int size = (paper.isEmpty()) ? 0 : paper.getCount(); if (sheets != size) { @@ -257,8 +257,8 @@ public String showInfoButton() { public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) { super.receiveGuiNBTOnServer(player, name, nbt); if (name.equals("analyse")) { - final WindowInventory inventory = getWindowInventory(); - final ItemStack individualStack = inventory.getStackInSlot(INDIVIDUAL_SLOT); + WindowInventory inventory = getWindowInventory(); + ItemStack individualStack = inventory.getStackInSlot(INDIVIDUAL_SLOT); inventory.setInventorySlotContents(INDIVIDUAL_SLOT, ManagerGenetics.analyse(individualStack, this.getWorld(), this.getUsername())); inventory.decrStackSize(PAPER_SLOT, 1); } diff --git a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java index 179a1b1c0..6bfd6d53c 100644 --- a/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java +++ b/core/src/main/java/binnie/core/gui/genesis/WindowGenesis.java @@ -93,29 +93,29 @@ public void initialiseClient() { refreshTemplate(null); }); this.geneList.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, this.geneList, event -> { - final Object value = event.getValue(); + Object value = event.getValue(); if (!(value instanceof Gene)) { return; } - final Gene gene = (Gene) value; - final Map> map = Binnie.GENETICS.getChromosomeMap(root); - final IChromosomeType chromosomeType = gene.getChromosome(); - final List alleles = map.get(chromosomeType); - final List options = new ArrayList<>(alleles.size()); - for (final IAllele allele : alleles) { + Gene gene = (Gene) value; + Map> map = Binnie.GENETICS.getChromosomeMap(root); + IChromosomeType chromosomeType = gene.getChromosome(); + List alleles = map.get(chromosomeType); + List options = new ArrayList<>(alleles.size()); + for (IAllele allele : alleles) { options.add(new Gene(allele, chromosomeType, root)); } geneOptions.setOptions(options); }); this.geneOptions.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, this.geneOptions, event -> { - final Object value = event.getValue(); + Object value = event.getValue(); if (!(value instanceof Gene)) { return; } - final Gene gene = (Gene) value; - final IChromosomeType chromosomeType = gene.getChromosome(); - final ISpeciesRoot speciesRoot = gene.getSpeciesRoot(); - final IAllele allele = gene.getAllele(); + Gene gene = (Gene) value; + IChromosomeType chromosomeType = gene.getChromosome(); + ISpeciesRoot speciesRoot = gene.getSpeciesRoot(); + IAllele allele = gene.getAllele(); if (chromosomeType == speciesRoot.getSpeciesChromosomeType()) { template = speciesRoot.getTemplate(allele.getUID()); }else { @@ -128,10 +128,10 @@ public void initialiseClient() { } private void refreshTemplate(@Nullable IChromosomeType selection) { - final IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(EmptyHelper.CHROMOSOME_TYPES_EMPTY); - final List genes = new ArrayList<>(chromosomeTypes.length); + IChromosomeType[] chromosomeTypes = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(EmptyHelper.CHROMOSOME_TYPES_EMPTY); + List genes = new ArrayList<>(chromosomeTypes.length); for (IChromosomeType type : chromosomeTypes) { - final IAllele allele = this.template[type.ordinal()]; + IAllele allele = this.template[type.ordinal()]; if (allele == null) { throw new NullPointerException("Allele missing for Chromosome " + type.getName()); } @@ -149,12 +149,12 @@ private void refreshTemplate(@Nullable IChromosomeType selection) { private void refreshPickup() { this.panelPickup.deleteAllChildren(); int i = 0; - final IBreedingSystem system = Binnie.GENETICS.getSystem(this.root); - for (final ISpeciesType type : system.getActiveTypes()) { - final IIndividual ind = this.root.templateAsIndividual(this.template); + IBreedingSystem system = Binnie.GENETICS.getSystem(this.root); + for (ISpeciesType type : system.getActiveTypes()) { + IIndividual ind = this.root.templateAsIndividual(this.template); ind.analyze(); - final ItemStack stack = this.root.getMemberStack(ind, type); - final ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18); + ItemStack stack = this.root.getMemberStack(ind, type); + ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18); display.setItemStack(stack); display.setTooltip(); display.addEventHandler(EventMouse.Down.class, EventHandlerOrigin.SELF, display, event -> { @@ -170,12 +170,12 @@ private void refreshPickup() { public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, final NBTTagCompound nbt) { super.receiveGuiNBTOnServer(player, name, nbt); if (name.equals(ACTION_GENESIS)) { - final ItemStack stack = new ItemStack(nbt); + ItemStack stack = new ItemStack(nbt); if (stack.isEmpty()) { return; } - final InventoryPlayer inventoryPlayer = player.inventory; - final ItemStack playerStack = inventoryPlayer.getItemStack(); + InventoryPlayer inventoryPlayer = player.inventory; + ItemStack playerStack = inventoryPlayer.getItemStack(); if (playerStack.isEmpty()) { inventoryPlayer.setItemStack(stack); } else if (playerStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(playerStack, stack)) { diff --git a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java index 687a6bd7e..82fe1f3a6 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java @@ -88,15 +88,15 @@ private Side getSide() { public void onContainerClosed(final EntityPlayer playerIn) { this.crafters.remove(playerIn); super.onContainerClosed(playerIn); - final WindowInventory inventory = this.window.getWindowInventory(); + WindowInventory inventory = this.window.getWindowInventory(); for (int i = 0; i < inventory.getSizeInventory(); ++i) { if (inventory.dispenseOnClose(i)) { - final ItemStack stack = inventory.getStackInSlot(i); + ItemStack stack = inventory.getStackInSlot(i); if (stack.isEmpty()) { continue; } - final TransferRequest transferRequest = new TransferRequest(stack, playerIn.inventory); - final TransferResult transferResult = transferRequest.transfer(playerIn, true); + TransferRequest transferRequest = new TransferRequest(stack, playerIn.inventory); + TransferResult transferResult = transferRequest.transfer(playerIn, true); if (transferResult.isSuccess()) { for (ItemStack result : transferResult.getRemaining()) { playerIn.dropItem(result, false); @@ -126,7 +126,7 @@ public boolean canInteractWith(EntityPlayer entityPlayer) { crafters.add(entityPlayer); this.sentNBT.clear(); } - final IInventory inventory = this.window.getInventory(); + IInventory inventory = this.window.getInventory(); return inventory == null || inventory.isUsableByPlayer(entityPlayer); } @@ -137,9 +137,9 @@ public final ItemStack transferStackInSlot(final EntityPlayer player, final int private ItemStack shiftClick(final EntityPlayer player, final int slotnumber) { final TransferRequest request = this.getShiftClickRequest(player, slotnumber); - final TransferResult transferResult = request.transfer(player, true); + TransferResult transferResult = request.transfer(player, true); if (transferResult.isSuccess()) { - final NonNullList results = transferResult.getRemaining(); + NonNullList results = transferResult.getRemaining(); if (results.size() == 1) { final ItemStack itemstack = results.get(0); final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber); @@ -180,7 +180,7 @@ private TransferRequest getShiftClickRequest(final EntityPlayer player, final in } public final void tankClick(final EntityPlayer player, final int slotID) { - final IInventory inventory = this.window.getInventory(); + IInventory inventory = this.window.getInventory(); if (inventory == null) { return; } @@ -189,18 +189,18 @@ public final void tankClick(final EntityPlayer player, final int slotID) { return; } heldItem = heldItem.copy(); - final TransferRequest transferRequest = new TransferRequest(heldItem, inventory).setTargetTanks(slotID); - final TransferResult transferResult = transferRequest.transfer(player, true); + TransferRequest transferRequest = new TransferRequest(heldItem, inventory).setTargetTanks(slotID); + TransferResult transferResult = transferRequest.transfer(player, true); if (transferResult.isSuccess()) { - final NonNullList results = transferResult.getRemaining(); + NonNullList results = transferResult.getRemaining(); if (results.size() > 0) { - final ItemStack heldItemResult = results.remove(results.size() - 1); + ItemStack heldItemResult = results.remove(results.size() - 1); player.inventory.setItemStack(heldItemResult); if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).updateHeldItem(); } if (results.size() > 0) { - final IItemHandler itemHandler = new InvWrapper(inventory); + IItemHandler itemHandler = new InvWrapper(inventory); for (ItemStack remaining : results) { ItemHandlerHelper.insertItemStacked(itemHandler, remaining, false); } @@ -270,7 +270,7 @@ public void detectAndSendChanges() { } private void sendTankChanges(){ - final ITankMachine tanks = Machine.getInterface(ITankMachine.class, this.window.getInventory()); + ITankMachine tanks = Machine.getInterface(ITankMachine.class, this.window.getInventory()); if (tanks != null && this.window.isServer()) { for (int i = 0; i < tanks.getTankInfos().length; ++i) { final TankInfo tank = tanks.getTankInfos()[i]; diff --git a/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java b/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java index fdd6fbf4d..05036fd9d 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/CustomSlot.java @@ -38,13 +38,13 @@ public boolean handleClick() { } public void onSlotClick(final ContainerCraftGUI container, final int dragType, final ClickType modifier, final EntityPlayer player) { - final InventoryPlayer inventory = player.inventory; - final ItemStack stack = inventory.getItemStack(); + InventoryPlayer inventory = player.inventory; + ItemStack stack = inventory.getItemStack(); //TODO modifier==mouseButton2? if (stack.isEmpty() || modifier == ClickType.PICKUP_ALL) { this.putStack(ItemStack.EMPTY); }else { - final ItemStack slotStack = stack.copy(); + ItemStack slotStack = stack.copy(); slotStack.setCount(1); this.putStack(slotStack); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java b/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java index cc77f14a3..6b9e2e4f7 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java +++ b/core/src/main/java/binnie/core/gui/minecraft/GuiCraftGUI.java @@ -137,11 +137,11 @@ public void renderTooltip(final Point mousePosition, final MinecraftTooltip tool final int mouseX = mousePosition.xPos(); final int mouseY = mousePosition.yPos(); final FontRenderer font = this.getFontRenderer(); - final ItemStack itemStack = tooltip.getItemStack(); + ItemStack itemStack = tooltip.getItemStack(); boolean containsItemRender = false; - final List textLines = new ArrayList<>(tooltip.getList().size()); + List textLines = new ArrayList<>(tooltip.getList().size()); for (final String string : tooltip.getList()) { if (string != null) { if (!string.contains(Tooltip.NBT_SEPARATOR)) { @@ -200,15 +200,15 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List textLin if (needsWrap) { int wrappedTooltipWidth = 0; - final List wrappedTextLines = new ArrayList<>(textLines.size()); + List wrappedTextLines = new ArrayList<>(textLines.size()); for (int i = 0; i < textLines.size(); i++) { - final String textLine = textLines.get(i); - final List wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth); + String textLine = textLines.get(i); + List wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth); if (i == 0) { titleLinesCount = wrappedLine.size(); } - for (final String line : wrappedLine) { + for (String line : wrappedLine) { int lineWidth = font.getStringWidth(line); if (textLine.contains(Tooltip.NBT_SEPARATOR)) { lineWidth = 12 + font.getStringWidth(PATTERN_NBT_CONTENT.matcher(textLine).replaceAll(StringUtils.EMPTY)); @@ -284,8 +284,8 @@ private void drawHoveringText(@Nonnull ItemStack itemStack, List textLin private void drawItem(String line, int tooltipX, int tooltipY){ String itemTag = line.split(Tooltip.NBT_SEPARATOR)[1]; try { - final NBTTagCompound nbt = JsonToNBT.getTagFromJson(itemTag); - final ItemStack stack = new ItemStack(nbt); + NBTTagCompound nbt = JsonToNBT.getTagFromJson(itemTag); + ItemStack stack = new ItemStack(nbt); GlStateManager.pushMatrix(); GlStateManager.translate(tooltipX, tooltipY - 1.5f, 0.0f); GlStateManager.scale(0.6f, 0.6f, 1.0f); diff --git a/core/src/main/java/binnie/core/gui/minecraft/Window.java b/core/src/main/java/binnie/core/gui/minecraft/Window.java index 6e8283cfb..9054a781a 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/Window.java +++ b/core/src/main/java/binnie/core/gui/minecraft/Window.java @@ -165,7 +165,7 @@ public boolean showHelpButton() { @Nullable public String showInfoButton() { - final IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory()); + IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory()); if (machineInformation != null) { return machineInformation.getInformation(); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java index a11870acf..e8ad78c51 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlEnergyBar.java @@ -57,10 +57,10 @@ private float getMaxEnergy() { @SideOnly(Side.CLIENT) public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.add(I18N.localise(ModId.CORE, "gui.energy.bar")); - final NumberFormat numberFormat = I18N.getNumberFormat(); - final String storedEnergy = numberFormat.format(this.getStoredEnergy()); - final String maxEnergy = numberFormat.format(this.getMaxEnergy()); - final String energyString = TextFormatting.GRAY + storedEnergy + '/' + maxEnergy + " RF"; + NumberFormat numberFormat = I18N.getNumberFormat(); + String storedEnergy = numberFormat.format(this.getStoredEnergy()); + String maxEnergy = numberFormat.format(this.getMaxEnergy()); + String energyString = TextFormatting.GRAY + storedEnergy + '/' + maxEnergy + " RF"; tooltip.add(energyString); } @@ -72,16 +72,16 @@ public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.add(I18N.localise(ModId.CORE, "gui.energy.bar")); if (tooltipFlag.isAdvanced()) { - final String currentFormat = I18N.localise(ModId.CORE, "gui.energy.amount.current"); - final NumberFormat numberFormat = I18N.getNumberFormat(); + String currentFormat = I18N.localise(ModId.CORE, "gui.energy.amount.current"); + NumberFormat numberFormat = I18N.getNumberFormat(); String currentString = PATTERN_MAX.matcher(currentFormat).replaceAll(numberFormat.format(this.getStoredEnergy())); currentString = PATTERN_PERCENT.matcher(currentString).replaceAll(I18N.getPercentFormat().format(this.getPercentage() / 100.0)); tooltip.add(TextFormatting.GRAY + currentString); - final String maxEnergy = numberFormat.format(this.getMaxEnergy()); + String maxEnergy = numberFormat.format(this.getMaxEnergy()); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.energy.capacity", maxEnergy)); final IProcess process = Machine.getInterface(IProcess.class, Window.get(this).getInventory()); if (process != null) { - final String energyPerTick = numberFormat.format((int) process.getEnergyPerTick()); + String energyPerTick = numberFormat.format((int) process.getEnergyPerTick()); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.energy.cost.per.tick", energyPerTick)); } } @@ -98,7 +98,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { switch (this.direction) { case TOP: case BOTTOM: { - final IPoint fullSize = area.size(); + IPoint fullSize = area.size(); final int height = Math.round(fullSize.yPos() * percentage); area.setSize(new Point(fullSize.xPos(), height)); area.setYPos(fullSize.yPos() - height); diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java index fda646456..c54dfc840 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlErrorState.java @@ -67,8 +67,8 @@ public final void onUpdateClient() { } ControlEnergyBar.isError = this.errorState.isPowerError(); if (this.errorState.isItemError()) { - final Collection slots = this.errorState.getCustomSlots(Window.get(this).getContainer()); - for (final CustomSlot slot : slots) { + Collection slots = this.errorState.getCustomSlots(Window.get(this).getContainer()); + for (CustomSlot slot : slots) { if (this.type == 0) { ControlSlot.highlighting.get(EnumHighlighting.ERROR).add(slot.slotNumber); } else { diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java index a2a718c14..aad65026b 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlItemDisplay.java @@ -97,7 +97,7 @@ public void setItemStack(ItemStack itemStack) { @SideOnly(Side.CLIENT) public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (this.hasTooltip && !this.itemStack.isEmpty()) { - final List itemStackTooltip = this.itemStack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); + List itemStackTooltip = this.itemStack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); tooltip.add(itemStackTooltip); tooltip.setItemStack(this.itemStack); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java index 5c86efb0f..b81acaf79 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java @@ -86,7 +86,7 @@ public int getTankCapacity() { @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(this.horizontal ? CraftGUITexture.HORIZONTAL_LIQUID_TANK : CraftGUITexture.LIQUID_TANK, Point.ZERO); - final GuiCraftGUI gui = Window.get(this).getGui(); + GuiCraftGUI gui = Window.get(this).getGui(); if (this.isMouseOver() && gui.isHelpMode()) { final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.HELP); RenderUtil.drawGradientRect(this.getArea().inset(1), c, c); @@ -142,7 +142,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { @SideOnly(Side.CLIENT) public void onRenderForeground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(this.horizontal ? CraftGUITexture.HORIZONTAL_LIQUID_TANK_OVERLAY : CraftGUITexture.LIQUID_TANK_OVERLAY, Point.ZERO); - final GuiCraftGUI gui = Window.get(this).getGui(); + GuiCraftGUI gui = Window.get(this).getGui(); if (this.isMouseOver() && gui.isHelpMode()) { final IArea area = this.getArea(); RenderUtil.setColour(MinecraftTooltip.getOutline(Tooltip.Type.HELP)); @@ -161,14 +161,14 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (this.getTankSlot() != null) { final TankSlot slot = this.getTankSlot(); tooltip.add(slot.getName()); - final NumberFormat numberFormat = I18N.getNumberFormat(); + NumberFormat numberFormat = I18N.getNumberFormat(); tooltip.add(I18N.localise(ModId.CORE, "gui.tank.capacity", numberFormat.format(this.getTankCapacity()))); if (tooltipFlag.isAdvanced()) { - final Collection inputSides = slot.getInputSides(); + Collection inputSides = slot.getInputSides(); if (inputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides))); } - final Collection outputSides = slot.getOutputSides(); + Collection outputSides = slot.getOutputSides(); if (outputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides))); } @@ -183,13 +183,13 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { @SideOnly(Side.CLIENT) public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (this.isTankValid()) { - final NumberFormat numberFormat = I18N.getNumberFormat(); - final NumberFormat percentFormat = I18N.getPercentFormat(); + NumberFormat numberFormat = I18N.getNumberFormat(); + NumberFormat percentFormat = I18N.getPercentFormat(); final float percentage = this.getTank().getAmount() / this.getTankCapacity(); tooltip.add(this.getTank().getName()); - final String percentFull = percentFormat.format(percentage); + String percentFull = percentFormat.format(percentage); tooltip.add(I18N.localise(ModId.CORE, "gui.tank.percent.full", percentFull)); - final String tankAmount = numberFormat.format((int) this.getTank().getAmount()); + String tankAmount = numberFormat.format((int) this.getTank().getAmount()); tooltip.add(I18N.localise(ModId.CORE, "gui.tank.amount", tankAmount)); return; } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java index 033fc1cbe..3f2020145 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlProgressBase.java @@ -33,7 +33,7 @@ public static String convertTime(final int time) { ++minutes; seconds -= 60; } - final StringBuilder stringBuilder = new StringBuilder(); + StringBuilder stringBuilder = new StringBuilder(); if (minutes > 0) { if (minutes == 1) { stringBuilder.append(I18N.localise(ModId.CORE, "gui.progress.time.minute", minutes)); @@ -93,14 +93,14 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (tooltipFlag.isAdvanced()) { NumberFormat numberFormat = I18N.getNumberFormat(); if (process.getProcessTime() > 0) { - final String timeLeft = convertTime((int) ((1.0f - this.progress) * process.getProcessTime())); + String timeLeft = convertTime((int) ((1.0f - this.progress) * process.getProcessTime())); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.progress.time.left", timeLeft)); - final String timeTotal = convertTime(process.getProcessTime()); + String timeTotal = convertTime(process.getProcessTime()); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.progress.time.total", timeTotal)); - final String energyCostTotal = numberFormat.format(process.getProcessEnergy() * 10); + String energyCostTotal = numberFormat.format(process.getProcessEnergy() * 10); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.progress.energy.cost.total", energyCostTotal)); } else { - final String energyCostPerTick = numberFormat.format(process.getEnergyPerTick() * 10.0f); + String energyCostPerTick = numberFormat.format(process.getEnergyPerTick() * 10.0f); tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.energy.cost.per.tick", energyCostPerTick)); } } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java index 69048cb3f..f9da3b7e2 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java @@ -58,9 +58,9 @@ public ControlSlot(final IWidget parent, final int x, final int y, final Slot sl super(parent, x, y); this.slot = slot; this.addSelfEventHandler(EventMouse.Down.class, event -> { - final Window superParent = (Window) ControlSlot.this.getTopParent(); - final GuiCraftGUI superParentGui = superParent.getGui(); - final Minecraft mc = superParentGui.getMinecraft(); + Window superParent = (Window) ControlSlot.this.getTopParent(); + GuiCraftGUI superParentGui = superParent.getGui(); + Minecraft mc = superParentGui.getMinecraft(); final PlayerControllerMP playerController = mc.playerController; final int windowId = superParent.getContainer().windowId; final int slotNumber = this.slot.slotNumber; @@ -87,7 +87,7 @@ public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(CraftGUITexture.SLOT, Point.ZERO); final InventorySlot islot = this.getInventorySlot(); if (islot != null) { - final SlotValidator validator = islot.getValidator(); + SlotValidator validator = islot.getValidator(); if (validator != null) { final TextureAtlasSprite icon = validator.getIcon(!islot.getInputSides().isEmpty()); if (icon != null && icon != Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()) { @@ -193,11 +193,11 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (slot != null) { tooltip.add(slot.getName()); if (tooltipFlag.isAdvanced()) { - final Collection inputSides = slot.getInputSides(); + Collection inputSides = slot.getInputSides(); if (inputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides))); } - final Collection outputSides = slot.getOutputSides(); + Collection outputSides = slot.getOutputSides(); if (outputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides))); } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java index 328a768f5..d51000bca 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotArray.java @@ -28,8 +28,8 @@ public void setItemStacks(final ItemStack[] array) { if (i >= this.slots.size()) { return; } - final ControlSlot controlSlot = this.slots.get(i); - final Slot slot = controlSlot.slot; + ControlSlot controlSlot = this.slots.get(i); + Slot slot = controlSlot.slot; slot.putStack(item); ++i; } @@ -68,8 +68,8 @@ public ControlSlotArray create(final InventoryType type, final int[] index) { int i = 0; for (int row = 0; row < rows; ++row) { for (int column = 0; column < columns; ++column) { - final ControlSlot.Builder slotBuilder = new ControlSlot.Builder(controlSlots, column * 18, row * 18); - final ControlSlot slot = slotBuilder.assign(type, index[i++]); + ControlSlot.Builder slotBuilder = new ControlSlot.Builder(controlSlots, column * 18, row * 18); + ControlSlot slot = slotBuilder.assign(type, index[i++]); controlSlots.slots.add(slot); } } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java index 954b4c625..d0a6e9fde 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotBase.java @@ -48,7 +48,7 @@ protected void setRotating() { public void onRenderBackground(int guiWidth, int guiHeight) { CraftGUI.RENDER.texture(CraftGUITexture.SLOT, this.getArea()); if (this.getTopParent().getMousedOverWidget() == this) { - final Area area = new Area(new Point(1, 1), this.getArea().size().sub(new Point(2, 2))); + Area area = new Area(new Point(1, 1), this.getArea().size().sub(new Point(2, 2))); RenderUtil.drawGradientRect(area, -2130706433, -2130706433); } } @@ -67,7 +67,7 @@ public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (stack.isEmpty()) { return; } - final List list = stack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); + List list = stack.getTooltip(((Window) this.getTopParent()).getPlayer(), tooltipFlag); for (int i = 0; i < list.size(); ++i) { if (i == 0) { diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java index 3763cdc89..30e065048 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlotCharge.java @@ -42,8 +42,8 @@ public void onRenderBackground(int guiWidth, int guiHeight) { @Override @SideOnly(Side.CLIENT) public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { - final NumberFormat percentFormat = I18N.getPercentFormat(); - final String chargePercent = percentFormat.format(this.getCharge()); + NumberFormat percentFormat = I18N.getPercentFormat(); + String chargePercent = percentFormat.format(this.getCharge()); tooltip.add(I18N.localise(ModId.CORE, "gui.charge.remaining.percent", chargePercent)); } } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java index 6922950e7..d5c9611e2 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlTabIcon.java @@ -31,11 +31,11 @@ public ItemStack getItemStack() { public void onUpdateClient() { super.onUpdateClient(); this.item.setItemStack(this.getItemStack()); - final ControlTabBar parent = (ControlTabBar) this.getParent(); + ControlTabBar parent = (ControlTabBar) this.getParent(); final int x = parent.getDirection().x(); - final boolean selected = this.isCurrentSelection() || this.isMouseOver(); - final int xOffset = selected ? 0 : (-4 * x); - final Point offset = new Point(xOffset, 0); + boolean selected = this.isCurrentSelection() || this.isMouseOver(); + int xOffset = selected ? 0 : (-4 * x); + Point offset = new Point(xOffset, 0); this.item.setOffset(offset); } diff --git a/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java b/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java index 8583444c9..877c96d2d 100644 --- a/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java +++ b/core/src/main/java/binnie/core/gui/renderer/RenderUtil.java @@ -95,8 +95,8 @@ public static void drawTexture(double xCoord, double yCoord, TextureAtlasSprite uMax -= maskRight / 16.0 * (uMax - uMin); vMax -= maskTop / 16.0 * (vMax - vMin); - final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder bufferBuilder = tessellator.getBuffer(); + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder bufferBuilder = tessellator.getBuffer(); bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferBuilder.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex(); bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex(); @@ -121,12 +121,12 @@ public static void setColour(final int hexColour) { } public static int getTextWidth(final String text) { - final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; return fontRenderer.getStringWidth(text); } public static int getTextHeight() { - final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; return (fontRenderer == null) ? 0 : fontRenderer.FONT_HEIGHT; } @@ -139,7 +139,7 @@ public static void drawText(final IArea area, final TextJustification justificat if (area.size().xPos() <= 0.0f) { return; } - final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; final List wrappedStrings = fontRenderer.listFormattedStringToWidth(text, area.size().xPos()); final float totalHeight = wrappedStrings.size() * getTextHeight(); float posY = pos.yPos(); @@ -191,13 +191,13 @@ public static void drawFluid(Point pos, @Nullable FluidStack fluidStack) { GlStateManager.enableBlend(); GlStateManager.enableAlpha(); - final Minecraft minecraft = Minecraft.getMinecraft(); + Minecraft minecraft = Minecraft.getMinecraft(); if (fluidStack != null) { - final Fluid fluid = fluidStack.getFluid(); + Fluid fluid = fluidStack.getFluid(); if (fluid != null) { - final TextureAtlasSprite stillSprite = getStillFluidSprite(minecraft, fluid); + TextureAtlasSprite stillSprite = getStillFluidSprite(minecraft, fluid); - final int fluidColor = fluid.getColor(fluidStack); + int fluidColor = fluid.getColor(fluidStack); minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); setColour(fluidColor); @@ -209,8 +209,8 @@ public static void drawFluid(Point pos, @Nullable FluidStack fluidStack) { } private static TextureAtlasSprite getStillFluidSprite(Minecraft minecraft, Fluid fluid) { - final TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); - final ResourceLocation fluidStill = fluid.getStill(); + TextureMap textureMapBlocks = minecraft.getTextureMapBlocks(); + ResourceLocation fluidStill = fluid.getStill(); TextureAtlasSprite fluidStillSprite = null; if (fluidStill != null) { fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString()); diff --git a/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java b/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java index f1041b86a..7cc9e4894 100644 --- a/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java +++ b/core/src/main/java/binnie/core/gui/renderer/TextureRenderer.java @@ -96,7 +96,7 @@ public void setStyleSheet(IStyleSheet styleSheet) { this.styleSheet = styleSheet; } - public final void preRender(final IWidget widget, final int guiWidth, final int guiHeight) { + public final void preRender(final IWidget widget, int guiWidth, int guiHeight) { GlStateManager.pushMatrix(); GlStateManager.translate(widget.getPosition().xPos(), widget.getPosition().yPos(), 0.0f); RenderUtil.setColour(widget.getColor()); @@ -167,13 +167,13 @@ public void texture(@Nullable final ITexture texture, final IArea area) { } } - public void limitArea(final IArea area, final int guiWidth, final int guiHeight) { + public void limitArea(final IArea area, int guiWidth, int guiHeight) { float x = area.pos().xPos(); float y = area.pos().yPos(); float w = area.size().xPos(); float h = area.size().yPos(); y = guiHeight - (y + h); - final Minecraft minecraft = Minecraft.getMinecraft(); + Minecraft minecraft = Minecraft.getMinecraft(); final float scaleX = guiWidth / (float) minecraft.displayWidth; final float scaleY = guiHeight / (float) minecraft.displayHeight; x += 0.0f; @@ -184,8 +184,8 @@ public void limitArea(final IArea area, final int guiWidth, final int guiHeight) } public int textHeight(final String text, final int width) { - final Minecraft minecraft = Minecraft.getMinecraft(); - final FontRenderer fontRenderer = minecraft.fontRenderer; + Minecraft minecraft = Minecraft.getMinecraft(); + FontRenderer fontRenderer = minecraft.fontRenderer; return fontRenderer.listFormattedStringToWidth(text, width).size() * RenderUtil.getTextHeight(); } diff --git a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java index 51b33bc44..2902ed660 100644 --- a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java +++ b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetManager.java @@ -37,8 +37,8 @@ public void onResourceManagerReload(final IResourceManager manager) { sheets.clear(); try { for(Map.Entry entry : sheetLocations.entrySet()){ - final ResourceLocation location = entry.getValue(); - final StyleSheet styleSheet = StyleSheetParser.parseSheet(manager, location); + ResourceLocation location = entry.getValue(); + StyleSheet styleSheet = StyleSheetParser.parseSheet(manager, location); sheets.put(entry.getKey(), styleSheet); } } catch (Exception e) { @@ -48,7 +48,7 @@ public void onResourceManagerReload(final IResourceManager manager) { @SideOnly(Side.CLIENT) public static Texture getDefaultTexture(Object key) { - final StyleSheet styleSheet = getDefaultSheet(); + StyleSheet styleSheet = getDefaultSheet(); return styleSheet.getTexture(key); } diff --git a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java index 8b2b72854..eb37c1f39 100644 --- a/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java +++ b/core/src/main/java/binnie/core/gui/resource/stylesheet/StyleSheetParser.java @@ -43,14 +43,14 @@ public class StyleSheetParser { @SideOnly(Side.CLIENT) public static StyleSheet parseSheet(IResourceManager manager, ResourceLocation location) { try { - final IResource res = manager.getResource(location); - final BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(res.getInputStream(), Charsets.UTF_8)); + IResource res = manager.getResource(location); + BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(res.getInputStream(), Charsets.UTF_8)); - final JsonParser jsonParser = new JsonParser(); - final JsonObject jsonObject = jsonParser.parse(bufferedreader).getAsJsonObject(); + JsonParser jsonParser = new JsonParser(); + JsonObject jsonObject = jsonParser.parse(bufferedreader).getAsJsonObject(); - final Map textureSheets = parseTextureSheets(jsonObject); - final Map textures = parseTextures(jsonObject, textureSheets); + Map textureSheets = parseTextureSheets(jsonObject); + Map textures = parseTextures(jsonObject, textureSheets); IOUtils.closeQuietly(bufferedreader); return new StyleSheet(textures); @@ -60,21 +60,21 @@ public static StyleSheet parseSheet(IResourceManager manager, ResourceLocation l } private static Map parseTextureSheets(JsonObject jsonObject){ - final JsonArray textureSheetsArray = JsonUtils.getJsonArray(jsonObject, SHEETS_KEY); + JsonArray textureSheetsArray = JsonUtils.getJsonArray(jsonObject, SHEETS_KEY); if(textureSheetsArray == null){ return Collections.emptyMap(); } - final Map textureSheets = new HashMap<>(); - for (final JsonElement element : textureSheetsArray) { + Map textureSheets = new HashMap<>(); + for (JsonElement element : textureSheetsArray) { if(!element.isJsonObject()){ continue; } try { - final JsonObject sheetJson = (JsonObject) element; - final String name = JsonUtils.getString(sheetJson, NAME_KEY); - final String modid = JsonUtils.getString(sheetJson, MODID_KEY); - final String path = JsonUtils.getString(sheetJson, PATH_KEY); - final ParsedTextureSheet textureSheet = new ParsedTextureSheet(modid, path); + JsonObject sheetJson = (JsonObject) element; + String name = JsonUtils.getString(sheetJson, NAME_KEY); + String modid = JsonUtils.getString(sheetJson, MODID_KEY); + String path = JsonUtils.getString(sheetJson, PATH_KEY); + ParsedTextureSheet textureSheet = new ParsedTextureSheet(modid, path); textureSheets.put(name, textureSheet); }catch(Exception e){ Log.warning("Failed to load stylesheet for Binnie's Mods.", e); @@ -84,22 +84,22 @@ private static Map parseTextureSheets(JsonObject jso } private static Map parseTextures(JsonObject jsonObject, Map textureSheets){ - final JsonArray texturesJson = JsonUtils.getJsonArray(jsonObject, TEXTURES_KEY); + JsonArray texturesJson = JsonUtils.getJsonArray(jsonObject, TEXTURES_KEY); if(texturesJson == null){ return Collections.emptyMap(); } - final Map textures = new HashMap<>(); + Map textures = new HashMap<>(); for (JsonElement element : texturesJson) { if(!element.isJsonObject()){ continue; } try { - final JsonObject sheetJson = element.getAsJsonObject(); - final String name = JsonUtils.getString(sheetJson, NAME_KEY); - final String sheet = JsonUtils.getString(sheetJson, SHEET_KEY); - final JsonArray uvArray = JsonUtils.getJsonArray(sheetJson, UV_KEY); - final IBinnieTexture textureSheet = textureSheets.get(sheet); - final Area uv = parseArea(uvArray); + JsonObject sheetJson = element.getAsJsonObject(); + String name = JsonUtils.getString(sheetJson, NAME_KEY); + String sheet = JsonUtils.getString(sheetJson, SHEET_KEY); + JsonArray uvArray = JsonUtils.getJsonArray(sheetJson, UV_KEY); + IBinnieTexture textureSheet = textureSheets.get(sheet); + Area uv = parseArea(uvArray); Border border = Border.ZERO; Border padding = Border.ZERO; if (sheetJson.has(BORDER_KEY)) { @@ -110,7 +110,7 @@ private static Map parseTextures(JsonObject jsonObject, Map parseTextures(JsonObject jsonObject, Map 4) { throw new JsonParseException("Parameter must have between one and four numbers"); } for(int i = 0;i < uvArray.size();i++){ - final JsonElement object = uvArray.get(i); + JsonElement object = uvArray.get(i); ints[i] = JsonUtils.getInt(object, "uv" + i); } if (ints.length == 1) { @@ -141,12 +141,12 @@ private static Area parseArea(JsonArray uvArray) { } private static Border parseBorder(JsonArray array) { - final int[] ints = new int[array.size()]; + int[] ints = new int[array.size()]; if (ints.length < 1 || ints.length > 4) { throw new JsonParseException("Parameter must have between one and four numbers"); } for(int i = 0;i < array.size();i++){ - final JsonElement object = array.get(i); + JsonElement object = array.get(i); ints[i] = JsonUtils.getInt(object, UV_KEY + i); } if (ints.length == 1) { diff --git a/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java b/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java index 151eab4f0..45958f2e4 100644 --- a/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java +++ b/core/src/main/java/binnie/core/integration/jei/CoreJeiPlugin.java @@ -28,7 +28,7 @@ public Class getGuiContainerClass() { @Nullable @Override public Object getIngredientUnderMouse(GuiCraftGUI guiContainer, int mouseX, int mouseY) { - final IWidget widgetUnderMouse = guiContainer.getWidgetUnderMouse(); + IWidget widgetUnderMouse = guiContainer.getWidgetUnderMouse(); if (widgetUnderMouse != null) { return widgetUnderMouse.getIngredient(); } diff --git a/core/src/main/java/binnie/core/item/ItemGenesis.java b/core/src/main/java/binnie/core/item/ItemGenesis.java index b0fcdb9b7..c8c6f42c9 100644 --- a/core/src/main/java/binnie/core/item/ItemGenesis.java +++ b/core/src/main/java/binnie/core/item/ItemGenesis.java @@ -23,7 +23,7 @@ public ItemGenesis() { @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { - final ItemStack itemStack = playerIn.getHeldItem(handIn); + ItemStack itemStack = playerIn.getHeldItem(handIn); openGuiOnRightClick(itemStack, worldIn, playerIn); return new ActionResult<>(EnumActionResult.SUCCESS, itemStack); } diff --git a/core/src/main/java/binnie/core/item/ItemMisc.java b/core/src/main/java/binnie/core/item/ItemMisc.java index 5ed9f6da6..2d0338977 100644 --- a/core/src/main/java/binnie/core/item/ItemMisc.java +++ b/core/src/main/java/binnie/core/item/ItemMisc.java @@ -32,7 +32,7 @@ public ItemMisc(CreativeTabs tab, final IItemMiscProvider[] items) { @Override public void getSubItems(CreativeTabs tab, NonNullList items) { if (this.isInCreativeTab(tab)) { - for (final IItemMiscProvider item : this.items) { + for (IItemMiscProvider item : this.items) { if (item.isActive()) { items.add(this.getStack(item, 1)); } @@ -52,21 +52,21 @@ public ItemStack getStack(IItemMiscProvider type, int size) { @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); - final IItemMiscProvider item = this.getItem(stack.getItemDamage()); + IItemMiscProvider item = this.getItem(stack.getItemDamage()); item.addInformation(tooltip); } @SideOnly(Side.CLIENT) @Override public void registerModel(Item item, IModelManager manager) { - for (final IItemMiscProvider type : items) { + for (IItemMiscProvider type : items) { manager.registerItemModel(item, type.ordinal(), "misc/" + type.getModelPath()); } } @Override public String getItemStackDisplayName(final ItemStack stack) { - final IItemMiscProvider item = this.getItem(stack.getItemDamage()); + IItemMiscProvider item = this.getItem(stack.getItemDamage()); return item.getDisplayName(stack); } } diff --git a/core/src/main/java/binnie/core/item/ModuleItems.java b/core/src/main/java/binnie/core/item/ModuleItems.java index d8b97b2e7..e39ca2247 100644 --- a/core/src/main/java/binnie/core/item/ModuleItems.java +++ b/core/src/main/java/binnie/core/item/ModuleItems.java @@ -26,7 +26,7 @@ public void init() { @Override public void postInit() { - final RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); + RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); recipeUtil.addRecipe("field_kit", new ItemStack(BinnieCore.getFieldKit(), 1, 63), "g ", " is", " pi", 'g', Blocks.GLASS_PANE, 'i', Items.IRON_INGOT, 'p', Items.PAPER, 's', new ItemStack(Items.DYE, 1)); } } diff --git a/core/src/main/java/binnie/core/liquid/AlcoholEffect.java b/core/src/main/java/binnie/core/liquid/AlcoholEffect.java index 95be24f0d..1d43c2488 100644 --- a/core/src/main/java/binnie/core/liquid/AlcoholEffect.java +++ b/core/src/main/java/binnie/core/liquid/AlcoholEffect.java @@ -6,7 +6,7 @@ public class AlcoholEffect { public static void makeDrunk(final EntityPlayer player, final float strength) { - final PotionEffect potionEffect = player.getActivePotionEffect(MobEffects.NAUSEA); + PotionEffect potionEffect = player.getActivePotionEffect(MobEffects.NAUSEA); final int existingStrength = potionEffect != null ? potionEffect.getAmplifier() : 0; final int existingTime = potionEffect != null ? potionEffect.getDuration() : 0; int time = (int) (100.0 * Math.sqrt(strength)) + existingTime; diff --git a/core/src/main/java/binnie/core/liquid/FluidContainerType.java b/core/src/main/java/binnie/core/liquid/FluidContainerType.java index babd9ea72..eb5bf28f7 100644 --- a/core/src/main/java/binnie/core/liquid/FluidContainerType.java +++ b/core/src/main/java/binnie/core/liquid/FluidContainerType.java @@ -76,10 +76,10 @@ public ItemStack getEmpty() { } public ItemStack getFilled(Fluid fluid) { - final ItemStack stack = getEmpty(); - final IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack); + ItemStack stack = getEmpty(); + IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack); if (fluidHandler != null) { - final int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true); + int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true); if (fill > 0) { return stack; } diff --git a/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java b/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java index eb43fdb00..42d060935 100644 --- a/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java +++ b/core/src/main/java/binnie/core/liquid/FluidHandlerItemBinnie.java @@ -21,14 +21,14 @@ private boolean contentsAllowed(@Nullable FluidStack fluidStack) { return false; } - final Fluid fluid = fluidStack.getFluid(); + Fluid fluid = fluidStack.getFluid(); if (fluid == null) { return false; } if (fluid instanceof BinnieFluid) { - final BinnieFluid binnieFluid = (BinnieFluid) fluid; - final FluidType definition = binnieFluid.getType(); + BinnieFluid binnieFluid = (BinnieFluid) fluid; + FluidType definition = binnieFluid.getType(); return definition.canPlaceIn(containerType); } return false; diff --git a/core/src/main/java/binnie/core/liquid/FluidType.java b/core/src/main/java/binnie/core/liquid/FluidType.java index c9b7bdfe6..97dc3fc48 100644 --- a/core/src/main/java/binnie/core/liquid/FluidType.java +++ b/core/src/main/java/binnie/core/liquid/FluidType.java @@ -25,7 +25,7 @@ public FluidType(String identifier, String unlocalizedName, int color) { this.unlocalizedName = unlocalizedName.toLowerCase(); this.color = color; this.containerColor = color; - final ResourceLocation texture = new ResourceLocation(Constants.CORE_MOD_ID, "blocks/liquids/blank"); + ResourceLocation texture = new ResourceLocation(Constants.CORE_MOD_ID, "blocks/liquids/blank"); this.textureFlowing = texture; this.textureStill = texture; } diff --git a/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java b/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java index 45e3b45c7..d192207b3 100644 --- a/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java +++ b/core/src/main/java/binnie/core/liquid/ItemFluidContainer.java @@ -53,7 +53,7 @@ public ItemFluidContainer(FluidContainerType container) { @Override public String getItemStackDisplayName(final ItemStack itemstack) { - final FluidStack fluid = getContained(itemstack); + FluidStack fluid = getContained(itemstack); if (fluid == null) { return I18N.localise(ModId.CORE, "item.container.empty", container.getDisplayName()); } diff --git a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java index bde6251f2..da4821673 100644 --- a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java +++ b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java @@ -37,15 +37,15 @@ public ManagerLiquid() { } public void createLiquids(IFluidDefinition[] liquids) { - for (final IFluidDefinition liquid : liquids) { - final FluidType type = liquid.getType(); + for (IFluidDefinition liquid : liquids) { + FluidType type = liquid.getType(); this.createLiquid(type); } } - private void createLiquid(final FluidType fluid) { + private void createLiquid(FluidType fluid) { this.fluids.put(fluid.getIdentifier().toLowerCase(), fluid); - final BinnieFluid bFluid = new BinnieFluid(fluid); + BinnieFluid bFluid = new BinnieFluid(fluid); if ((!FluidRegistry.registerFluid(bFluid)) || (FluidRegistry.addBucketForFluid(bFluid))) { Log.error("Liquid registered incorrectly - {} ", fluid.getIdentifier()); } @@ -67,7 +67,7 @@ public void init() { @Override public void postInit() { - final RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); + RecipeUtil recipeUtil = new RecipeUtil(Constants.CORE_MOD_ID); recipeUtil.addShapelessRecipe("glass_container_conversion", FluidContainerType.GLASS.get(1), Items.GLASS_BOTTLE); recipeUtil.addShapelessRecipe("glass_bottle_conversion", new ItemStack(Items.GLASS_BOTTLE), FluidContainerType.GLASS.get(1)); recipeUtil.addRecipe("glass_container", FluidContainerType.GLASS.get(3), @@ -79,8 +79,8 @@ public void postInit() { @SubscribeEvent @SideOnly(Side.CLIENT) public void registerSprites(TextureStitchEvent event) { - final TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); - for (final FluidType definition : fluids.values()) { + TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); + for (FluidType definition : fluids.values()) { textureMap.registerSprite(definition.getFlowing()); textureMap.registerSprite(definition.getStill()); } diff --git a/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java b/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java index 1c865438a..69645c12d 100644 --- a/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java +++ b/core/src/main/java/binnie/core/machines/base/TileEntityMachineBase.java @@ -196,10 +196,10 @@ public T getCapability(Capability capability, @Nullable EnumFacing facing return CapabilityEnergy.ENERGY.cast(this); } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (facing != null) { - final SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(getInventory(), facing); + SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(getInventory(), facing); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(sidedInvWrapper); } else { - final InvWrapper invWrapper = new InvWrapper(getInventory()); + InvWrapper invWrapper = new InvWrapper(getInventory()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(invWrapper); } } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { diff --git a/core/src/main/java/binnie/core/machines/errors/ErrorState.java b/core/src/main/java/binnie/core/machines/errors/ErrorState.java index 483ec7b69..ad99ef276 100644 --- a/core/src/main/java/binnie/core/machines/errors/ErrorState.java +++ b/core/src/main/java/binnie/core/machines/errors/ErrorState.java @@ -29,24 +29,24 @@ public class ErrorState implements INbtReadable, INbtWritable { private boolean tankError; private boolean powerError; - public ErrorState(final IErrorStateDefinition definition) { + public ErrorState(IErrorStateDefinition definition) { this(definition, definition); } - public ErrorState(final IErrorStateDefinition definition, final int[] data) { + public ErrorState(IErrorStateDefinition definition, int[] data) { this(definition, definition, data); } - public ErrorState(final IErrorStateDefinition definition, final int data) { + public ErrorState(IErrorStateDefinition definition, int data) { this(definition, definition, new int[]{data}); } - public ErrorState(final IErrorStateDefinition nameDefinition, final IErrorStateDefinition definition) { + public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition) { this(nameDefinition, definition, EmptyHelper.INT_ARRAY_EMPTY); } - public ErrorState(final IErrorStateDefinition nameDefinition, final IErrorStateDefinition definition, final int[] data) { - final EnumErrorType type = definition.getType(); + public ErrorState(IErrorStateDefinition nameDefinition, IErrorStateDefinition definition, int[] data) { + EnumErrorType type = definition.getType(); this.data = data; this.itemError = type.isItemError(); this.tankError = type.isTankError(); @@ -75,12 +75,12 @@ public String getTooltip() { } public String getTooltip(ContainerCraftGUI container) { - final Collection slots = getCustomSlots(container); - final Set> validators = new HashSet<>(); - for (final CustomSlot slot : slots) { - final InventorySlot inventorySlot = slot.getInventorySlot(); + Collection slots = getCustomSlots(container); + Set> validators = new HashSet<>(); + for (CustomSlot slot : slots) { + InventorySlot inventorySlot = slot.getInventorySlot(); if (inventorySlot != null) { - final SlotValidator validator = inventorySlot.getValidator(); + SlotValidator validator = inventorySlot.getValidator(); if (validator != null) { validators.add(validator); } @@ -133,9 +133,9 @@ public boolean isPowerError() { } public Collection getCustomSlots(ContainerCraftGUI container) { - final Collection slots = new ArrayList<>(); + Collection slots = new ArrayList<>(); if (isItemError()) { - final IntSet slotNumbers = new IntArraySet(getData()); + IntSet slotNumbers = new IntArraySet(getData()); for (final CustomSlot cslot : container.getCustomSlots()) { if (!(cslot.inventory instanceof InventoryPlayer) && slotNumbers.contains(cslot.getSlotIndex())) { slots.add(cslot); diff --git a/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java b/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java index f7dfdca0c..f59323d3f 100644 --- a/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java +++ b/core/src/main/java/binnie/core/machines/errors/ErrorStateRegistry.java @@ -7,7 +7,7 @@ public class ErrorStateRegistry { private static final Map states = new HashMap<>(); public static void registerErrorState(IErrorStateDefinition state) { - final String uid = state.getUID(); + String uid = state.getUID(); if (!uid.contains(":")) { throw new RuntimeException("Binnie Error State name must be in the format :."); } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java b/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java index 462f71c1a..0ad480031 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentChargedSlots.java @@ -32,7 +32,7 @@ public void readFromNBT(final NBTTagCompound nbttagcompound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) { - final NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); + NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); final NBTTagList chargeList = new NBTTagList(); for (final Map.Entry entry : this.charges.entrySet()) { final NBTTagCompound chargesNBT = new NBTTagCompound(); diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java index 85a2ef1fa..7eb69c9d4 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventory.java @@ -12,7 +12,7 @@ public ComponentInventory(final IMachine machine) { @Override public void markDirty() { - final IMachine machine = this.getMachine(); + IMachine machine = this.getMachine(); machine.markDirty(); } } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java index 5601c5498..fb19bc988 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java @@ -36,12 +36,12 @@ public ComponentInventorySlots(final IMachine machine) { } @Override - public ItemStack removeStackFromSlot(final int index) { - final InventorySlot slot = getInternalSlot(index); + public ItemStack removeStackFromSlot(int index) { + InventorySlot slot = getInternalSlot(index); if(slot.isFake()){ return ItemStack.EMPTY; } - final ItemStack content = slot.getItemStack(); + ItemStack content = slot.getItemStack(); slot.setContent(ItemStack.EMPTY); this.markDirty(); return content; @@ -71,8 +71,8 @@ public ItemStack getStackInSlot(final int index) { @Override public ItemStack decrStackSize(final int index, final int amount) { - final InventorySlot slot = getInternalSlot(index); - final ItemStack stack = slot.decrStackSize(amount); + InventorySlot slot = getInternalSlot(index); + ItemStack stack = slot.decrStackSize(amount); if (!stack.isEmpty()) { this.markDirty(); } @@ -81,7 +81,7 @@ public ItemStack decrStackSize(final int index, final int amount) { @Override public void setInventorySlotContents(int index, ItemStack itemStack) { - final InventorySlot slot = getInternalSlot(index); + InventorySlot slot = getInternalSlot(index); if (!slot.isFake() && (itemStack.isEmpty() || slot.isValid(itemStack))) { slot.setContent(itemStack); this.markDirty(); @@ -97,7 +97,7 @@ public boolean isEmpty() { public void readFromNBT(final NBTTagCompound compound) { super.readFromNBT(compound); NBTUtil.readFromList(compound, INVENTORY_KEY, (slotNBT) -> { - final int index = slotNBT.getInteger(INDEX_KEY); + int index = slotNBT.getInteger(INDEX_KEY); InventorySlot slot = getInternalSlot(index); slot.readFromNBT(slotNBT); }); @@ -112,7 +112,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound compound) { } public final InventorySlot addSlot(final int index, final ResourceLocation unlocLocation) { - final InventorySlot slot = new InventorySlot(index, unlocLocation); + InventorySlot slot = new InventorySlot(index, unlocLocation); this.inventory.put(index, slot); return slot; } @@ -122,7 +122,7 @@ public final InventorySlot addSlot(final int index, final ResourceLocation unloc */ @Deprecated public final InventorySlot addSlot(final int index, final String unlocName) { - final ResourceLocation unlocLocation = new ResourceLocation(Constants.CORE_MOD_ID, "gui.slot." + unlocName); + ResourceLocation unlocLocation = new ResourceLocation(Constants.CORE_MOD_ID, "gui.slot." + unlocName); return addSlot(index, unlocLocation); } @@ -167,18 +167,18 @@ public boolean hasCustomName() { @Override public boolean isItemValidForSlot(final int index, final ItemStack itemStack) { - final InventorySlot slot = this.getSlot(index); + InventorySlot slot = this.getSlot(index); return slot != null && (slot.isValid(itemStack) && !this.isReadOnly(index)); } @Override public void onDestruction() { - final IMachine machine = getMachine(); - final World world = machine.getWorld(); - final Random rand = world.rand; - final BlockPos pos = machine.getTileEntity().getPos(); - for (final InventorySlot slot : this.inventory.values()) { - final ItemStack stack = slot.getItemStack(); + IMachine machine = getMachine(); + World world = machine.getWorld(); + Random rand = world.rand; + BlockPos pos = machine.getTileEntity().getPos(); + for (InventorySlot slot : this.inventory.values()) { + ItemStack stack = slot.getItemStack(); if (slot.isRecipe() || stack.isEmpty()) { continue; } @@ -208,13 +208,13 @@ public boolean canInsertItem(final int index, final ItemStack itemstack, final E if (!isItemValidForSlot(index, itemstack)) { return false; } - final InventorySlot slot = this.getSlot(index); + InventorySlot slot = this.getSlot(index); return slot != null && slot.canInsert(direction); } @Override public boolean canExtractItem(final int index, final ItemStack itemstack, final EnumFacing direction) { - final InventorySlot slot = this.getSlot(index); + InventorySlot slot = this.getSlot(index); return slot != null && slot.canExtract(direction); } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java index a081c6e77..a7c770d06 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentInventoryTransfer.java @@ -22,17 +22,17 @@ public ComponentInventoryTransfer(final IMachine machine) { } public void addRestock(final int[] buffer, final int destination, final int limit) { - final Restock restock = new Restock(this.getMachine(), buffer, destination, limit); + Restock restock = new Restock(this.getMachine(), buffer, destination, limit); this.transfers.add(restock); } public void addRestock(final int[] buffer, final int destination) { - final Restock restock = new Restock(this.getMachine(), buffer, destination); + Restock restock = new Restock(this.getMachine(), buffer, destination); this.transfers.add(restock); } public void addStorage(final int source, final int[] destination) { - final Storage storage = new Storage(this.getMachine(), source, destination); + Storage storage = new Storage(this.getMachine(), source, destination); this.transfers.add(storage); } @@ -44,8 +44,8 @@ public void onUpdate() { } public void addStorage(final int source, final int[] destination, final Condition condition) { - final Storage storage = new Storage(this.getMachine(), source, destination); - final Transfer transfer = storage.setCondition(condition); + Storage storage = new Storage(this.getMachine(), source, destination); + Transfer transfer = storage.setCondition(condition); this.transfers.add(transfer); } @@ -130,12 +130,12 @@ private Storage(final IMachine machine, final int source, final int[] destinatio @Override protected void doTransfer(final IInventory inv) { - final ItemStack stackInSlot = inv.getStackInSlot(this.source); + ItemStack stackInSlot = inv.getStackInSlot(this.source); if (!stackInSlot.isEmpty()) { - final TransferRequest transferRequest = new TransferRequest(stackInSlot, inv).setTargetSlots(this.destination).ignoreValidation(); - final TransferResult transferResult = transferRequest.transfer(null, true); + TransferRequest transferRequest = new TransferRequest(stackInSlot, inv).setTargetSlots(this.destination).ignoreValidation(); + TransferResult transferResult = transferRequest.transfer(null, true); if (transferResult.isSuccess()) { - final NonNullList results = transferResult.getRemaining(); + NonNullList results = transferResult.getRemaining(); if (results.size() == 1) { inv.setInventorySlotContents(this.source, results.get(0)); } diff --git a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java index 7013e49ac..a92ee1959 100644 --- a/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java +++ b/core/src/main/java/binnie/core/machines/inventory/ComponentTankContainer.java @@ -45,14 +45,14 @@ public ComponentTankContainer(final IMachine machine) { @Override public final TankSlot addTank(final int index, final String name, final int capacity) { - final TankSlot tank = new TankSlot(index, name, capacity); + TankSlot tank = new TankSlot(index, name, capacity); this.tanks.put(index, tank); return tank; } @Override public final TankSlot addTank(final int index, final ResourceLocation name, final int capacity) { - final TankSlot tank = new TankSlot(index, name, capacity); + TankSlot tank = new TankSlot(index, name, capacity); this.tanks.put(index, tank); return tank; } @@ -89,7 +89,7 @@ private FluidStack drain(final int tankIndex, final int maxDrain, final boolean public void readFromNBT(final NBTTagCompound compound) { super.readFromNBT(compound); NBTUtil.readFromList(compound, TANKS_KEY, (tankNBT)->{ - final int index = tankNBT.getInteger(TANK_INDEX_KEY); + int index = tankNBT.getInteger(TANK_INDEX_KEY); if (this.tanks.containsKey(index)) { TankSlot tank = tanks.get(index); tank.readFromNBT(tankNBT); @@ -146,7 +146,7 @@ public void markDirty() { @Override @Nullable - public IFluidHandler getHandler(@Nullable final EnumFacing from) { + public IFluidHandler getHandler(@Nullable EnumFacing from) { if (from == null) { return noFacingHandler; } @@ -155,10 +155,10 @@ public IFluidHandler getHandler(@Nullable final EnumFacing from) { @Nullable @Override - public IFluidHandler getHandler(final int[] targetTanks) { - final Map tanks = new HashMap<>(); - for (final int index : targetTanks) { - final TankSlot tankSlot = this.tanks.get(index); + public IFluidHandler getHandler(int[] targetTanks) { + Map tanks = new HashMap<>(); + for (int index : targetTanks) { + TankSlot tankSlot = this.tanks.get(index); if (tankSlot != null) { tanks.put(index, tankSlot); } @@ -175,7 +175,7 @@ private static class TankContainer implements IFluidHandler { @Nullable private final EnumFacing from; - private TankContainer(final ComponentTankContainer tankContainer, final Map tanks, @Nullable final EnumFacing from) { + private TankContainer(ComponentTankContainer tankContainer, Map tanks, @Nullable EnumFacing from) { this.tankContainer = tankContainer; this.tanks = tanks; this.from = from; @@ -214,7 +214,7 @@ public final FluidStack drain(final int maxDrain, final boolean doDrain) { public IFluidTankProperties[] getTankProperties() { final IFluidTankProperties[] properties = new IFluidTankProperties[getTanks().length]; for (int i = 0; i < properties.length; ++i) { - final IFluidTank tank = getTanks()[i]; + IFluidTank tank = getTanks()[i]; properties[i] = new FluidTankProperties(tank.getFluid(), tank.getCapacity()); } return properties; @@ -228,7 +228,7 @@ private IFluidTank[] getTanks() { return ltanks.toArray(EmptyHelper.FLUID_TANKS_EMPTY); } - private static int getTankIndexToFill(final Map tanks, @Nullable final EnumFacing from, final FluidStack resource) { + private static int getTankIndexToFill(Map tanks, @Nullable EnumFacing from, FluidStack resource) { for (final TankSlot tank : tanks.values()) { if (tank.isValid(resource) && tank.canInsert(from) && (tank.getContent() == null || tank.getContent().isFluidEqual(resource))) { return tank.getIndex(); @@ -237,7 +237,7 @@ private static int getTankIndexToFill(final Map tanks, @Nulla return -1; } - private static int getTankIndexToDrain(final Map tanks, @Nullable final EnumFacing from, @Nullable final FluidStack resource) { + private static int getTankIndexToDrain(Map tanks, @Nullable EnumFacing from, @Nullable FluidStack resource) { for (final TankSlot tank : tanks.values()) { if (tank.getContent() != null && tank.canExtract(from) && (resource == null || resource.isFluidEqual(tank.getContent()))) { return tank.getIndex(); diff --git a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java index 44a30b681..cadae3a49 100644 --- a/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/InventorySlot.java @@ -94,7 +94,7 @@ public boolean isRecipe() { @Override public String getName() { - final SlotValidator validator = getValidator(); + SlotValidator validator = getValidator(); if (validator != null) { return I18N.localise(ModId.CORE, "gui.slot.validated", validator.getTooltip()); } diff --git a/core/src/main/java/binnie/core/machines/inventory/MachineSide.java b/core/src/main/java/binnie/core/machines/inventory/MachineSide.java index 9ef3f472a..d2753d0ce 100644 --- a/core/src/main/java/binnie/core/machines/inventory/MachineSide.java +++ b/core/src/main/java/binnie/core/machines/inventory/MachineSide.java @@ -30,12 +30,12 @@ public static String asString(final Collection sides) { return I18N.localise(ModId.CORE, "side.sides"); } - final StringBuilder text = new StringBuilder(); + StringBuilder text = new StringBuilder(); boolean firstSide = true; - final List sortedSides = new ArrayList<>(sides); + List sortedSides = new ArrayList<>(sides); sortedSides.sort(Comparator.comparing(ALL::indexOf)); - for (final EnumFacing side : sortedSides) { - final String localized = I18N.localise(ModId.CORE, "side." + side.getName()); + for (EnumFacing side : sortedSides) { + String localized = I18N.localise(ModId.CORE, "side." + side.getName()); if (firstSide) { firstSide = false; } else { diff --git a/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java b/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java index 13efa23f5..d17537169 100644 --- a/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java +++ b/core/src/main/java/binnie/core/machines/inventory/SidedAccess.java @@ -55,9 +55,9 @@ public void forbidExtractChange() { } public Collection getInsertionSides() { - final List dirs = new ArrayList<>(); - for (final EnumFacing side : EnumFacing.VALUES) { - final AccessDirection direction = getAccess(side); + List dirs = new ArrayList<>(); + for (EnumFacing side : EnumFacing.VALUES) { + AccessDirection direction = getAccess(side); if (direction.canInsert()) { dirs.add(side); } @@ -66,9 +66,9 @@ public Collection getInsertionSides() { } public Collection getExtractionSides() { - final List dirs = new ArrayList<>(); - for (final EnumFacing side : EnumFacing.VALUES) { - final AccessDirection direction = getAccess(side); + List dirs = new ArrayList<>(); + for (EnumFacing side : EnumFacing.VALUES) { + AccessDirection direction = getAccess(side); if (direction.canExtract()) { dirs.add(side); } @@ -77,14 +77,14 @@ public Collection getExtractionSides() { } public void setInsert(EnumFacing side, boolean value) { - final AccessDirection direction = getAccess(side); + AccessDirection direction = getAccess(side); if (direction.canInsert() != value) { this.accesses.put(side, direction.changeInsert(value)); } } public void setExtract(EnumFacing side, boolean value) { - final AccessDirection direction = getAccess(side); + AccessDirection direction = getAccess(side); if (direction.canExtract() != value) { this.accesses.put(side, direction.changeExtract(value)); } diff --git a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java index 8f1ed5ee9..ca31c2c2c 100644 --- a/core/src/main/java/binnie/core/machines/inventory/TankSlot.java +++ b/core/src/main/java/binnie/core/machines/inventory/TankSlot.java @@ -46,7 +46,7 @@ public FluidStack getContent() { return this.tank.getFluid(); } - private void setContent(@Nullable final FluidStack stack) { + private void setContent(@Nullable FluidStack stack) { this.tank.setFluid(stack); } @@ -56,7 +56,7 @@ public FluidTank getTank() { @Override public String getName() { - final Validator validator = getValidator(); + Validator validator = getValidator(); if (validator != null) { return I18N.localise(ModId.CORE, "gui.tank.validated", validator.getTooltip()); } diff --git a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java index 1ee469d56..817d89420 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentPowerReceptor.java @@ -57,7 +57,7 @@ public void readFromNBT(final NBTTagCompound nbttagcompound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) { - final NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); + NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); this.container.writeToNBT(nbttagcompound); return nbttagcompound; } @@ -98,14 +98,14 @@ public int getSinkTier() { @Override @Optional.Method(modid = "ic2") - public double injectEnergy(final EnumFacing directionFrom, final double amount, final double voltage) { + public double injectEnergy(EnumFacing directionFrom, final double amount, final double voltage) { this.container.addEnergy(PowerSystem.EU, amount, true); return 0.0; } @Override @Optional.Method(modid = "ic2") - public boolean acceptsEnergyFrom(final IEnergyEmitter emitter, final EnumFacing direction) { + public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { return this.acceptsPowerSystem(PowerSystem.EU); } @@ -159,7 +159,7 @@ public void onChunkUnload() { } private void addToEnergyNet() { - final World world = this.getMachine().getWorld(); + World world = this.getMachine().getWorld(); if (world == null || world.isRemote) { return; } @@ -169,7 +169,7 @@ private void addToEnergyNet() { } private void removeFromEnergyNet() { - final World world = this.getMachine().getWorld(); + World world = this.getMachine().getWorld(); if (world == null || world.isRemote) { return; } diff --git a/core/src/main/java/binnie/core/machines/power/ComponentProcess.java b/core/src/main/java/binnie/core/machines/power/ComponentProcess.java index d6d3606e6..8831969da 100644 --- a/core/src/main/java/binnie/core/machines/power/ComponentProcess.java +++ b/core/src/main/java/binnie/core/machines/power/ComponentProcess.java @@ -78,7 +78,7 @@ public void readFromNBT(final NBTTagCompound nbt) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound nbt1) { - final NBTTagCompound nbt = super.writeToNBT(nbt1); + NBTTagCompound nbt = super.writeToNBT(nbt1); nbt.setFloat(NBT_KEY_PROGRESS, this.progressAmount); return nbt; } diff --git a/core/src/main/java/binnie/core/machines/power/TankInfo.java b/core/src/main/java/binnie/core/machines/power/TankInfo.java index d8a52de5e..dfd968887 100644 --- a/core/src/main/java/binnie/core/machines/power/TankInfo.java +++ b/core/src/main/java/binnie/core/machines/power/TankInfo.java @@ -26,8 +26,8 @@ public TankInfo() { } public static TankInfo[] get(final ITankMachine machine) { - final IFluidTank[] fluidTanks = machine.getTanks(); - final TankInfo[] info = new TankInfo[fluidTanks.length]; + IFluidTank[] fluidTanks = machine.getTanks(); + TankInfo[] info = new TankInfo[fluidTanks.length]; for (int i = 0; i < info.length; ++i) { info[i] = new TankInfo(fluidTanks[i]); } diff --git a/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java b/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java index 510473c10..a1008fb5c 100644 --- a/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java +++ b/core/src/main/java/binnie/core/machines/render/RenderTESRMachine.java @@ -10,10 +10,10 @@ @SideOnly(Side.CLIENT) public class RenderTESRMachine extends TileEntitySpecialRenderer { @Override - public void render(final TileEntityTESRMachine te, final double x, final double y, final double z, final float partialTicks, final int destroyStage, final float alpha) { - final Machine machine = te.getMachine(); + public void render(TileEntityTESRMachine te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { + Machine machine = te.getMachine(); if (machine != null) { - for (final IRender.Render renders : machine.getInterfaces(IRender.Render.class)) { + for (IRender.Render renders : machine.getInterfaces(IRender.Render.class)) { renders.renderInWorld(x, y, z); } } diff --git a/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java b/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java index 72f00024d..7f0392bfe 100644 --- a/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java +++ b/core/src/main/java/binnie/core/machines/storage/ComponentBinnieCoreGUI.java @@ -22,7 +22,7 @@ public ComponentBinnieCoreGUI(final Machine machine, final BinnieCoreGUI id) { } @Override - public void onRightClick(final World worldIn, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { + public void onRightClick(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!player.isSneaking()) { BinnieCore.getBinnieProxy().openGui(this.id, player, pos); } diff --git a/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java b/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java index 322dc2c16..26ea09b91 100644 --- a/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java +++ b/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java @@ -99,7 +99,7 @@ public void readFromNBT(final NBTTagCompound compound) { @Override public NBTTagCompound writeToNBT(final NBTTagCompound compound) { - final NBTTagCompound nbt = super.writeToNBT(compound); + NBTTagCompound nbt = super.writeToNBT(compound); final NBTTagList list = new NBTTagList(); for (int i = 0; i < this.tabCount; ++i) { final NBTTagCompound nbt2 = new NBTTagCompound(); diff --git a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java index ac3568d2b..a650993ff 100644 --- a/core/src/main/java/binnie/core/machines/storage/SearchDialog.java +++ b/core/src/main/java/binnie/core/machines/storage/SearchDialog.java @@ -41,7 +41,7 @@ public class SearchDialog extends Dialog { private boolean includeItems; private boolean includeBlocks; - public SearchDialog(final WindowCompartment windowCompartment) { + public SearchDialog(WindowCompartment windowCompartment) { super(windowCompartment, 252, 192); this.windowCompartment = windowCompartment; diff --git a/core/src/main/java/binnie/core/util/EmptyHelper.java b/core/src/main/java/binnie/core/util/EmptyHelper.java index ab910d323..2ee7ed029 100644 --- a/core/src/main/java/binnie/core/util/EmptyHelper.java +++ b/core/src/main/java/binnie/core/util/EmptyHelper.java @@ -34,4 +34,6 @@ private EmptyHelper() {} public static final ItemStack[] ITEM_STACKS_EMPTY = new ItemStack[0]; public static final IGene[] GENES_EMPTY = new IGene[0]; + + public static final Integer[] DEFAULT_TABS_EMPTY = new Integer[0]; } diff --git a/core/src/main/java/binnie/core/util/FluidStackUtil.java b/core/src/main/java/binnie/core/util/FluidStackUtil.java index fffb3f413..5263357f6 100644 --- a/core/src/main/java/binnie/core/util/FluidStackUtil.java +++ b/core/src/main/java/binnie/core/util/FluidStackUtil.java @@ -25,9 +25,9 @@ public static String toString(@Nullable final FluidStack fluidStack) { (tag != null ? ":" + fluidStack.tag : StringUtils.EMPTY); } - public static NonNullList removeEqualFluids(final Collection fluidsStacks) { - final NonNullList dedupedFluidStacks = NonNullList.create(); - for (final FluidStack fluidStack : fluidsStacks) { + public static NonNullList removeEqualFluids(Collection fluidsStacks) { + NonNullList dedupedFluidStacks = NonNullList.create(); + for (FluidStack fluidStack : fluidsStacks) { if (!containsEqualFluid(dedupedFluidStacks, fluidStack)) { dedupedFluidStacks.add(fluidStack); } @@ -46,13 +46,13 @@ public static boolean containsEqualFluid(final NonNullList fluidStac @Nullable public static ItemStack getContainer(final FluidStack fluidStack) { - final ItemStack[] containers = { + ItemStack[] containers = { new ItemStack(Items.GLASS_BOTTLE), new ItemStack(Items.BUCKET) }; - for (final ItemStack container : containers) { - final IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(container); + for (ItemStack container : containers) { + IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(container); if (fluidHandler != null && fluidHandler.fill(fluidStack, true) > 0) { return fluidHandler.getContainer(); } diff --git a/core/src/main/java/binnie/core/util/NBTUtil.java b/core/src/main/java/binnie/core/util/NBTUtil.java index b499249a0..d3299df50 100644 --- a/core/src/main/java/binnie/core/util/NBTUtil.java +++ b/core/src/main/java/binnie/core/util/NBTUtil.java @@ -19,7 +19,7 @@ private NBTUtil() { public static BiFunction writeToListConsumer(final String Key) { return (index, slot) -> { - final NBTTagCompound nbtTagCompound = new NBTTagCompound(); + NBTTagCompound nbtTagCompound = new NBTTagCompound(); nbtTagCompound.setInteger(Key, index); slot.writeToNBT(nbtTagCompound); return nbtTagCompound; @@ -30,15 +30,15 @@ public static void readFromList(NBTTagCompound compound, String listKey, Consume if(!compound.hasKey(listKey, 9)){ return; } - final NBTTagList tagList = compound.getTagList(listKey, 10); + NBTTagList tagList = compound.getTagList(listKey, 10); for (int i = 0; i < tagList.tagCount(); ++i) { consumer.accept(tagList.getCompoundTagAt(i)); } } public static void writeToList(NBTTagCompound compound, String listKey, Map content, BiFunction consumer){ - final NBTTagList tagList = new NBTTagList(); - for(final Map.Entry entry : content.entrySet()){ + NBTTagList tagList = new NBTTagList(); + for(Map.Entry entry : content.entrySet()){ tagList.appendTag(consumer.apply(entry.getKey(), entry.getValue())); } compound.setTag(listKey, tagList); @@ -52,7 +52,7 @@ public static void readFromNBT(IEnergyStorage storage, String key, NBTTagCompoun public static void writeToNBT(IEnergyStorage storage, String key, NBTTagCompound nbt) { - final NBTBase nbtBase = CapabilityEnergy.ENERGY.writeNBT(storage, null); + NBTBase nbtBase = CapabilityEnergy.ENERGY.writeNBT(storage, null); if(nbtBase != null) { nbt.setTag(key, nbtBase); } From a25d01b15ec6411a05bf86ef123b714c0437ad2c Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 14 Apr 2018 11:42:05 +1000 Subject: [PATCH 85/99] Method names should start with a lowercase letter. --- core/src/main/java/binnie/core/genetics/Tolerance.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/genetics/Tolerance.java b/core/src/main/java/binnie/core/genetics/Tolerance.java index aa4ebb2f4..f791a1e43 100644 --- a/core/src/main/java/binnie/core/genetics/Tolerance.java +++ b/core/src/main/java/binnie/core/genetics/Tolerance.java @@ -36,7 +36,7 @@ public static > boolean canTolerate(final T base, final T test @Nullable private static Pattern PATTERN; - private static Pattern GetPattern() { + private static Pattern getPattern() { if (PATTERN == null) { PATTERN = Pattern.compile("_", Pattern.LITERAL); } @@ -45,7 +45,7 @@ private static Pattern GetPattern() { @Override public String toString() { - return GetPattern().matcher(super.toString().toLowerCase(Locale.ENGLISH)).replaceAll(StringUtils.EMPTY); + return getPattern().matcher(super.toString().toLowerCase(Locale.ENGLISH)).replaceAll(StringUtils.EMPTY); } public String getUID() { From 6db93dcbe79bd1d47740a90e78fb954442c65c59 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 14 Apr 2018 11:44:57 +1000 Subject: [PATCH 86/99] Improve variable. --- .../java/binnie/core/gui/controls/button/ControlButton.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java index ad2f3042a..6d322db18 100644 --- a/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java +++ b/core/src/main/java/binnie/core/gui/controls/button/ControlButton.java @@ -57,7 +57,7 @@ public String getText() { @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - Object texture; + final Object texture; if (this.isMouseOver()) { texture = CraftGUITexture.BUTTON_HIGHLIGHTED; } else if (this.isEnabled()) { From 2706a2e9ed377d3686cbdd1d00be3d299fb2fb62 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 14 Apr 2018 11:46:47 +1000 Subject: [PATCH 87/99] Change checking for string emptiness. --- .../java/binnie/core/gui/database/PageBranchOverview.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java b/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java index aca1e443b..4e297d2e5 100644 --- a/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java +++ b/core/src/main/java/binnie/core/gui/database/PageBranchOverview.java @@ -1,5 +1,7 @@ package binnie.core.gui.database; +import org.apache.commons.lang3.StringUtils; + import java.util.ArrayList; import java.util.List; @@ -15,7 +17,6 @@ import binnie.core.gui.controls.ControlTextCentered; import binnie.core.gui.renderer.RenderUtil; import binnie.core.util.I18N; -import org.apache.commons.lang3.StringUtils; @SideOnly(Side.CLIENT) public class PageBranchOverview extends PageBranch { @@ -42,7 +43,7 @@ public void onValueChanged(final IClassification branch) { } this.branchDescription.clear(); String desc = branch.getDescription(); - if (desc == null || desc.length() == 0 || desc.contains("for.")) { + if (desc == null || StringUtils.isEmpty(desc) || desc.contains("for.")) { desc = I18N.localise(DatabaseConstants.BRANCH_KEY + ".noDesc"); } StringBuilder line = new StringBuilder(); From 35833f9fe7edcf0c5923ee8f7357e84faa8f719e Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 14 Apr 2018 11:50:45 +1000 Subject: [PATCH 88/99] Improve intends --- .../core/gui/minecraft/control/ControlPlayerInventory.java | 4 ++-- .../java/binnie/core/gui/minecraft/control/ControlSlot.java | 4 ++-- core/src/main/java/binnie/core/item/ItemMisc.java | 4 ++-- core/src/main/java/binnie/core/liquid/ManagerLiquid.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java index be004a987..a2cdd44ca 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlPlayerInventory.java @@ -22,7 +22,7 @@ public ControlPlayerInventory(final IWidget parent, final boolean wide) { for (int row = 0; row < rowCount; ++row) { for (int column = 0; column < columnCount; ++column) { final ControlSlot slot = new ControlSlot.Builder(this, (wide ? 58 : 0) + column * 18, row * 18) - .assign(InventoryType.PLAYER, firstRowColumn + column + row * columnCount); + .assign(InventoryType.PLAYER, firstRowColumn + column + row * columnCount); this.slots.add(slot); } } @@ -51,7 +51,7 @@ public ControlPlayerInventory(final IWidget parent, final int x, final int y) { for (int row = 0; row < rowCount; ++row) { for (int column = 0; column < columnCount; ++column) { final ControlSlot slot = new ControlSlot.Builder(this, column * 18, row * 18) - .assign(InventoryType.PLAYER,column + row * columnCount); + .assign(InventoryType.PLAYER,column + row * columnCount); this.slots.add(slot); } } diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java index f9da3b7e2..bdcf84da0 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlSlot.java @@ -193,11 +193,11 @@ public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { if (slot != null) { tooltip.add(slot.getName()); if (tooltipFlag.isAdvanced()) { - Collection inputSides = slot.getInputSides(); + Collection inputSides = slot.getInputSides(); if (inputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides))); } - Collection outputSides = slot.getOutputSides(); + Collection outputSides = slot.getOutputSides(); if (outputSides.size() > 0) { tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides))); } diff --git a/core/src/main/java/binnie/core/item/ItemMisc.java b/core/src/main/java/binnie/core/item/ItemMisc.java index 2d0338977..3d8e66ee5 100644 --- a/core/src/main/java/binnie/core/item/ItemMisc.java +++ b/core/src/main/java/binnie/core/item/ItemMisc.java @@ -52,7 +52,7 @@ public ItemStack getStack(IItemMiscProvider type, int size) { @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); - IItemMiscProvider item = this.getItem(stack.getItemDamage()); + IItemMiscProvider item = this.getItem(stack.getItemDamage()); item.addInformation(tooltip); } @@ -66,7 +66,7 @@ public void registerModel(Item item, IModelManager manager) { @Override public String getItemStackDisplayName(final ItemStack stack) { - IItemMiscProvider item = this.getItem(stack.getItemDamage()); + IItemMiscProvider item = this.getItem(stack.getItemDamage()); return item.getDisplayName(stack); } } diff --git a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java index da4821673..b4e17eb76 100644 --- a/core/src/main/java/binnie/core/liquid/ManagerLiquid.java +++ b/core/src/main/java/binnie/core/liquid/ManagerLiquid.java @@ -49,7 +49,7 @@ private void createLiquid(FluidType fluid) { if ((!FluidRegistry.registerFluid(bFluid)) || (FluidRegistry.addBucketForFluid(bFluid))) { Log.error("Liquid registered incorrectly - {} ", fluid.getIdentifier()); } - } + } @Nullable public FluidStack getFluidStack(final String name, final int amount) { From f9a801f3fd1b5f8107b1a0a665626e1309dc9d73 Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 14 Apr 2018 16:10:45 +1000 Subject: [PATCH 89/99] Improve localise in ControlLiquidTank.java --- .../binnie/core/gui/minecraft/control/ControlLiquidTank.java | 2 +- core/src/main/resources/assets/binniecore/lang/en_US.lang | 1 + core/src/main/resources/assets/binniecore/lang/ru_RU.lang | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java index b81acaf79..5e3422498 100644 --- a/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java +++ b/core/src/main/java/binnie/core/gui/minecraft/control/ControlLiquidTank.java @@ -193,7 +193,7 @@ public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) { tooltip.add(I18N.localise(ModId.CORE, "gui.tank.amount", tankAmount)); return; } - tooltip.add("Empty"); + tooltip.add(I18N.localise(ModId.CORE, "gui.tank.empty")); } @Nullable diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index 2d7bcfe53..38521f81b 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -363,6 +363,7 @@ binniecore.gui.slot.pickup.only=Pickup Only Slot binniecore.gui.slotvalidator.individual=Breedable Individual +binniecore.gui.tank.empty=Empty binniecore.gui.tank.validated=%s Tank binniecore.gui.tank.input=Input Tank binniecore.gui.tank.process=Process Tank diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 7704b8acb..0d974df66 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -362,6 +362,7 @@ binniecore.gui.slot.pickup.only=Можно положить только в сл binniecore.gui.slotvalidator.individual=Разводимая особь +binniecore.gui.tank.empty=Резервуар пуст binniecore.gui.tank.validated=%s резервуар binniecore.gui.tank.input=Входной резервуар binniecore.gui.tank.process=Технологический резервуар From 8bd8a46de8e33dc885efcd5432a788b3bc541d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 09:35:13 +1000 Subject: [PATCH 90/99] Refactor tab slots array init. --- .../machines/storage/WindowCompartment.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 87c3fd600..d9e1f2a20 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -11,6 +11,7 @@ import binnie.core.gui.window.WindowMachine; import binnie.core.machines.IMachine; import binnie.core.machines.MachinePackage; +import javafx.util.Pair; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; @@ -64,6 +65,20 @@ public WindowCompartment(final EntityPlayer player, @Nullable final IInventory i this.currentTab = 0; } + private Pair calcTabsSlots(final int tabsCount) { + final int half = tabsCount / 2; + Integer[] tabs1 = new Integer[half + tabsCount % 2]; + Integer[] tabs2 = new Integer[half]; + int value = 0; + for (int index = 0; index < tabs1.length; ++index) { + tabs1[index] = value++; + } + for (int index = 0; index < tabs2.length; ++index) { + tabs2[index] = value++; + } + return new Pair<>(tabs1, tabs2); + } + //TODO: Clean Up, Localise @Override @SideOnly(Side.CLIENT) @@ -75,20 +90,9 @@ public void initialiseClient() { int x = 16; final int y = 32; final ComponentCompartmentInventory inv = machine.getInterface(ComponentCompartmentInventory.class); - Integer[] tabs1 = EmptyHelper.DEFAULT_TABS_EMPTY; - Integer[] tabs2 = EmptyHelper.DEFAULT_TABS_EMPTY; - if (inv.getTabCount() == 4) { - tabs1 = new Integer[]{0, 1}; - tabs2 = new Integer[]{2, 3}; - } - if (inv.getTabCount() == 6) { - tabs1 = new Integer[]{0, 1, 2}; - tabs2 = new Integer[]{3, 4, 5}; - } - if (inv.getTabCount() == 8) { - tabs1 = new Integer[]{0, 1, 2, 3}; - tabs2 = new Integer[]{4, 5, 6, 7}; - } + Pair slots = calcTabsSlots(inv.getTabCount()); + Integer[] tabs1 = slots.getKey(); + Integer[] tabs2 = slots.getValue(); final boolean doubleTabbed = tabs2.length > 0; final int compartmentPageWidth = 16 + 18 * inv.getPageSize() / 5; final int compartmentPageHeight = 106; From 0ec3efb50d9cea7b957e76f751d43b848d91eb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 09:39:29 +1000 Subject: [PATCH 91/99] Extract createTab from lambda --- .../core/machines/storage/WindowCompartment.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index d9e1f2a20..6118ec4f0 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -7,6 +7,7 @@ import binnie.core.api.gui.ITexture; import binnie.core.api.gui.events.EventHandlerOrigin; +import binnie.core.gui.controls.tab.ControlTab; import binnie.core.gui.geometry.Point; import binnie.core.gui.window.WindowMachine; import binnie.core.machines.IMachine; @@ -99,9 +100,7 @@ public void initialiseClient() { final int compartmentWidth = compartmentPageWidth + (doubleTabbed ? 48 : 24); final int compartmentHeight = compartmentPageHeight; final Control controlCompartment = new Control(this, x, y, compartmentWidth, compartmentHeight); - final ControlTabBar tab = new ControlTabBar<>(controlCompartment, 0, 0, 24, compartmentPageHeight, Alignment.LEFT, Arrays.asList(tabs1), (x1, y1, w, h, value) -> { - return new CompartmentTabIcon(this, x1, y1, w, h, value); - }); + final ControlTabBar tab = new ControlTabBar<>(controlCompartment, 0, 0, 24, compartmentPageHeight, Alignment.LEFT, Arrays.asList(tabs1), this::createTab); final String[] tabHelp = {"Compartment Tab", "Tabs that divide the inventory into sections. Each one can be labelled seperately."}; tab.addHelp(tabHelp); tab.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab, event -> { @@ -134,9 +133,7 @@ public void initialiseClient() { } x += compartmentPageWidth; if (tabs2.length > 0) { - final ControlTabBar tab2 = new ControlTabBar<>(controlCompartment, 24 + compartmentPageWidth, 0, 24, compartmentPageHeight, Alignment.RIGHT, Arrays.asList(tabs2), (x1, y1, w, h, value) -> { - return new CompartmentTabIcon(this, x1, y1, w, h, value); - }); + final ControlTabBar tab2 = new ControlTabBar<>(controlCompartment, 24 + compartmentPageWidth, 0, 24, compartmentPageHeight, Alignment.RIGHT, Arrays.asList(tabs2), this::createTab); tab2.setValue(tabs1[0]); tab2.addHelp(tabHelp); tab2.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab2, event -> { @@ -274,7 +271,11 @@ public CompartmentTab getCurrentTab() { return this.getTab(this.currentTab); } - private static class CompartmentTabIcon extends ControlTabIcon { + private ControlTab createTab(int x1, int y1, int w, int h, Integer value) { + return new CompartmentTabIcon(this, x1, y1, w, h, value); + } + + private static class CompartmentTabIcon extends ControlTabIcon { private final WindowCompartment windowCompartment; public CompartmentTabIcon(WindowCompartment windowCompartment, int x, int y, int w, int h, Integer value) { From 0595121c4bf6612be28af1f418c6ca3ec59e02a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 09:55:08 +1000 Subject: [PATCH 92/99] Refactoring compartment window. --- .../machines/storage/WindowCompartment.java | 48 +++++++++---------- .../assets/binniecore/lang/en_US.lang | 2 + .../assets/binniecore/lang/ru_RU.lang | 6 ++- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 6118ec4f0..1b5f33b60 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; +import binnie.core.ModId; import binnie.core.api.gui.ITexture; import binnie.core.api.gui.events.EventHandlerOrigin; import binnie.core.gui.controls.tab.ControlTab; @@ -12,6 +13,7 @@ import binnie.core.gui.window.WindowMachine; import binnie.core.machines.IMachine; import binnie.core.machines.MachinePackage; +import binnie.core.util.I18N; import javafx.util.Pair; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -51,7 +53,6 @@ import binnie.core.gui.window.Panel; import binnie.core.machines.Machine; import binnie.core.machines.transfer.TransferRequest; -import binnie.core.util.EmptyHelper; public class WindowCompartment extends WindowMachine implements IWindowAffectsShiftClick { private final Map panels; @@ -80,6 +81,24 @@ private Pair calcTabsSlots(final int tabsCount) { return new Pair<>(tabs1, tabs2); } + private void setControlTab(ControlTabBar tab) { + final String[] tabHelp = { + I18N.localise(ModId.CORE, "machine.storage.help.compartment_tab"), + I18N.localise(ModId.CORE, "machine.storage.help.compartment_tab.desc") + }; + tab.addHelp(tabHelp); + tab.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab, event -> { + if (event.getValue() == null) { + return; + } + final NBTTagCompound nbt = new NBTTagCompound(); + final int i = (Integer) event.getValue(); + nbt.setByte("i", (byte) i); + Window.get(tab).sendClientAction("tab-change", nbt); + WindowCompartment.this.currentTab = i; + }); + } + //TODO: Clean Up, Localise @Override @SideOnly(Side.CLIENT) @@ -101,18 +120,7 @@ public void initialiseClient() { final int compartmentHeight = compartmentPageHeight; final Control controlCompartment = new Control(this, x, y, compartmentWidth, compartmentHeight); final ControlTabBar tab = new ControlTabBar<>(controlCompartment, 0, 0, 24, compartmentPageHeight, Alignment.LEFT, Arrays.asList(tabs1), this::createTab); - final String[] tabHelp = {"Compartment Tab", "Tabs that divide the inventory into sections. Each one can be labelled seperately."}; - tab.addHelp(tabHelp); - tab.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab, event -> { - if (event.getValue() == null) { - return; - } - final NBTTagCompound nbt = new NBTTagCompound(); - final int i = (Integer) event.getValue(); - nbt.setByte("i", (byte) i); - Window.get(tab).sendClientAction("tab-change", nbt); - WindowCompartment.this.currentTab = i; - }); + setControlTab(tab); x += 24; final ControlPages compartmentPages = new ControlPages<>(controlCompartment, 24, 0, compartmentPageWidth, compartmentPageHeight); final ControlPage[] page = new ControlPage[inv.getTabCount()]; @@ -132,20 +140,10 @@ public void initialiseClient() { new ControlSlotArray.Builder(thisPage, 8, 8, inv.getPageSize() / 5, 5).create(slotsIDs); } x += compartmentPageWidth; - if (tabs2.length > 0) { + if (doubleTabbed) { final ControlTabBar tab2 = new ControlTabBar<>(controlCompartment, 24 + compartmentPageWidth, 0, 24, compartmentPageHeight, Alignment.RIGHT, Arrays.asList(tabs2), this::createTab); tab2.setValue(tabs1[0]); - tab2.addHelp(tabHelp); - tab2.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab2, event -> { - if (event.getValue() == null) { - return; - } - final NBTTagCompound nbt = new NBTTagCompound(); - final int iVal = (Integer) event.getValue(); - nbt.setByte("i", (byte) iVal); - Window.get(tab).sendClientAction("tab-change", nbt); - WindowCompartment.this.currentTab = iVal; - }); + setControlTab(tab2); CraftGUIUtil.linkWidgets(tab2, compartmentPages); x += 24; } diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index 38521f81b..4c0a46328 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -193,6 +193,8 @@ binniecore.item.container.cylinder=Cylinder binniecore.machine.storage.search.sort_by_name=Sort A-Z binniecore.machine.storage.search.include_items=Include Items binniecore.machine.storage.search.include_blocks=Include Blocks +binniecore.machine.storage.help.compartment_tab=Compartment Tab +binniecore.machine.storage.help.compartment_tab.desc=Tabs that divide the inventory into sections. Each one can be labelled seperately. binniecore.machine.storage.compartment=Compartment binniecore.machine.storage.compartment.info=Chests which contain several tabs to help organise their contents. Each tab can be named, assigned a colour and assigned an icon from any Item Stack. Number of Tabs: 4, slots per Tab: 25 binniecore.machine.storage.compartment_iron=Iron Compartment diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 0d974df66..9fd0abea0 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -191,8 +191,10 @@ binniecore.item.container.glass=Бутылка binniecore.item.container.cylinder=Цилиндр binniecore.machine.storage.search.sort_by_name=Сорт. A-Z -binniecore.machine.storage.search.include_items=Вкл. предметы -binniecore.machine.storage.search.include_blocks=Вкл. блоки +binniecore.machine.storage.search.include_items=Включая предметы +binniecore.machine.storage.search.include_blocks=Включая блоки +binniecore.machine.storage.help.compartment_tab=Вкладка Отсека +binniecore.machine.storage.help.compartment_tab.desc=Вкладки делят инвентарь на секции. Каждая настраивается отдельно. binniecore.machine.storage.compartment=Отсек binniecore.machine.storage.compartment.info=Сундуки, у которых несколько вкладок, чтобы помочь организовать их содержимое. Каждая вкладка может быть: переименована, назначен цвет, назначена пиктограмма из любого элемента. Количество вкладок: 4, слоты на вкладку: 25 binniecore.machine.storage.compartment_iron=Железный отсек From 1de8fe85599d27cc899b82d83ffeee79e0e2b386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 10:07:28 +1000 Subject: [PATCH 93/99] Code clean up --- .../core/machines/storage/WindowCompartment.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 1b5f33b60..7f138e59f 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -121,18 +121,14 @@ public void initialiseClient() { final Control controlCompartment = new Control(this, x, y, compartmentWidth, compartmentHeight); final ControlTabBar tab = new ControlTabBar<>(controlCompartment, 0, 0, 24, compartmentPageHeight, Alignment.LEFT, Arrays.asList(tabs1), this::createTab); setControlTab(tab); - x += 24; + x += tab.getWidth(); final ControlPages compartmentPages = new ControlPages<>(controlCompartment, 24, 0, compartmentPageWidth, compartmentPageHeight); - final ControlPage[] page = new ControlPage[inv.getTabCount()]; - for (int p = 0; p < inv.getTabCount(); ++p) { - page[p] = new ControlPage<>(compartmentPages, p); - } CraftGUIUtil.linkWidgets(tab, compartmentPages); int i = 0; - for (int p2 = 0; p2 < inv.getTabCount(); ++p2) { - final ControlPage thisPage = page[p2]; + for (int pos = 0; pos < inv.getTabCount(); ++pos) { + final ControlPage thisPage = new ControlPage<>(compartmentPages, pos); final Panel panel = new CompartmentCenterPanel(this, thisPage); - this.panels.put(panel, p2); + this.panels.put(panel, pos); final int[] slotsIDs = new int[inv.getPageSize()]; for (int k = 0; k < inv.getPageSize(); ++k) { slotsIDs[k] = i++; @@ -145,7 +141,7 @@ public void initialiseClient() { tab2.setValue(tabs1[0]); setControlTab(tab2); CraftGUIUtil.linkWidgets(tab2, compartmentPages); - x += 24; + x += tab2.getWidth(); } x += 16; this.setSize(new Point(Math.max(32 + compartmentWidth, 252), this.getHeight())); From 894fc2846e5f1aebdc7665fafab3e6ab51dffeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 10:15:20 +1000 Subject: [PATCH 94/99] Extract slide and localize --- .../machines/storage/WindowCompartment.java | 18 ++++++++++++------ .../assets/binniecore/lang/en_US.lang | 2 ++ .../assets/binniecore/lang/ru_RU.lang | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 7f138e59f..8a2a57b22 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -99,6 +99,15 @@ private void setControlTab(ControlTabBar tab) { }); } + private ControlSlide createSlide() { + final ControlSlide slide = new ControlSlide(this, 0, 134, 136, 92, Alignment.LEFT); + slide.setLabel(I18N.localise(ModId.CORE, "machine.storage.help.slide_label")); + slide.setSlide(false); + slide.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.slide_label")); + slide.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.slide_label.desc")); + return slide; + } + //TODO: Clean Up, Localise @Override @SideOnly(Side.CLIENT) @@ -146,12 +155,9 @@ public void initialiseClient() { x += 16; this.setSize(new Point(Math.max(32 + compartmentWidth, 252), this.getHeight())); controlCompartment.setPosition(new Point((this.getWidth() - controlCompartment.getWidth()) / 2, controlCompartment.getYPos())); - final ControlPlayerInventory invent = new ControlPlayerInventory(this, true); - final ControlSlide slide = new ControlSlide(this, 0, 134, 136, 92, Alignment.LEFT); - slide.setLabel("Tab Properties"); - slide.setSlide(false); - slide.addHelp("Tab Properties"); - slide.addHelp("The label, colour and icon of the Tab can be altered here. Clicking on the icon with a held item will change it."); + new ControlPlayerInventory(this, true); + + ControlSlide slide = createSlide(); final Panel tabPropertyPanel = new Panel(slide, 16, 8, 112, 76, MinecraftGUI.PanelType.GRAY); int y2 = 4; new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Name:"); diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index 4c0a46328..a53dffdf4 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -195,6 +195,8 @@ binniecore.machine.storage.search.include_items=Include Items binniecore.machine.storage.search.include_blocks=Include Blocks binniecore.machine.storage.help.compartment_tab=Compartment Tab binniecore.machine.storage.help.compartment_tab.desc=Tabs that divide the inventory into sections. Each one can be labelled seperately. +binniecore.machine.storage.help.slide_label=Tab Properties +binniecore.machine.storage.help.slide_label.desc=The label, colour and icon of the Tab can be altered here. Clicking on the icon with a held item will change it. binniecore.machine.storage.compartment=Compartment binniecore.machine.storage.compartment.info=Chests which contain several tabs to help organise their contents. Each tab can be named, assigned a colour and assigned an icon from any Item Stack. Number of Tabs: 4, slots per Tab: 25 binniecore.machine.storage.compartment_iron=Iron Compartment diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 9fd0abea0..276cf9336 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -195,6 +195,8 @@ binniecore.machine.storage.search.include_items=Включая предметы binniecore.machine.storage.search.include_blocks=Включая блоки binniecore.machine.storage.help.compartment_tab=Вкладка Отсека binniecore.machine.storage.help.compartment_tab.desc=Вкладки делят инвентарь на секции. Каждая настраивается отдельно. +binniecore.machine.storage.help.slide_label=Свойства вкладки +binniecore.machine.storage.help.slide_label.desc=Заголовок, цвет и иконка могут быть назначены здесь. Кликнув на иконке удерживая предмет изменят ее. binniecore.machine.storage.compartment=Отсек binniecore.machine.storage.compartment.info=Сундуки, у которых несколько вкладок, чтобы помочь организовать их содержимое. Каждая вкладка может быть: переименована, назначен цвет, назначена пиктограмма из любого элемента. Количество вкладок: 4, слоты на вкладку: 25 binniecore.machine.storage.compartment_iron=Железный отсек From b1fca09a6775a366fea6d6062c39665d57aeaa69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 10:19:59 +1000 Subject: [PATCH 95/99] Extract method createTabNameControl --- .../machines/storage/WindowCompartment.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 8a2a57b22..a7a3b2329 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -160,17 +160,7 @@ public void initialiseClient() { ControlSlide slide = createSlide(); final Panel tabPropertyPanel = new Panel(slide, 16, 8, 112, 76, MinecraftGUI.PanelType.GRAY); int y2 = 4; - new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Name:"); - final Panel parent = tabPropertyPanel; - final int x2 = 4; - y2 += 12; - (this.tabName = new ControlTextEdit(parent, x2, y2, 104, 12)).addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, this.tabName, event -> { - final binnie.core.machines.storage.CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); - currentTab.setName(event.getValue()); - final NBTTagCompound nbt = new NBTTagCompound(); - currentTab.writeToNBT(nbt); - WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); - }); + y2 = createTabNameControl(tabPropertyPanel, y2); y2 += 20; new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Icon: "); (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); @@ -212,6 +202,19 @@ public void initialiseClient() { searchButton.addHelp("Clicking this will open the Search dialog. This allows you to search the inventory for specific items."); } + private int createTabNameControl(Panel tabPropertyPanel, int y2) { + new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Name:"); + y2 += 12; + (this.tabName = new ControlTextEdit(tabPropertyPanel, 4, y2, 104, 12)).addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, this.tabName, event -> { + final CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); + currentTab.setName(event.getValue()); + final NBTTagCompound nbt = new NBTTagCompound(); + currentTab.writeToNBT(nbt); + WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); + }); + return y2; + } + @SideOnly(Side.CLIENT) public void createSearchDialog() { new SearchDialog(this); From 483d57cb3784f903eab47e87e2f3f85b5d8aeb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 10:32:35 +1000 Subject: [PATCH 96/99] Extract method createTabIconControl --- .../machines/storage/WindowCompartment.java | 42 ++++++++++--------- .../assets/binniecore/lang/en_US.lang | 3 ++ .../assets/binniecore/lang/ru_RU.lang | 3 ++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index a7a3b2329..6603f8550 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -162,24 +162,7 @@ public void initialiseClient() { int y2 = 4; y2 = createTabNameControl(tabPropertyPanel, y2); y2 += 20; - new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Icon: "); - (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); - this.tabIcon.addAttribute(Attribute.MOUSE_OVER); - this.tabIcon.addSelfEventHandler(EventMouse.Down.class, event -> { - if (WindowCompartment.this.getHeldItemStack().isEmpty()) { - return; - } - final binnie.core.machines.storage.CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); - final ItemStack stack = WindowCompartment.this.getHeldItemStack().copy(); - stack.setCount(1); - currentTab.setIcon(stack); - final NBTTagCompound nbt = new NBTTagCompound(); - currentTab.writeToNBT(nbt); - WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); - }); - this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.WHITE); - this.tabIcon.addHelp("Icon for Current Tab"); - this.tabIcon.addHelp("Click here with an item to change"); + createTabIconControl(tabPropertyPanel, y2); y2 += 20; new ControlText(tabPropertyPanel, new Point(4, y2), "Colour: "); final int cw = 8; @@ -202,7 +185,28 @@ public void initialiseClient() { searchButton.addHelp("Clicking this will open the Search dialog. This allows you to search the inventory for specific items."); } - private int createTabNameControl(Panel tabPropertyPanel, int y2) { + private void createTabIconControl(Panel tabPropertyPanel, int y2) { + new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.help.icon_label.text")); + (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); + this.tabIcon.addAttribute(Attribute.MOUSE_OVER); + this.tabIcon.addSelfEventHandler(EventMouse.Down.class, event -> { + if (WindowCompartment.this.getHeldItemStack().isEmpty()) { + return; + } + final CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); + final ItemStack stack = WindowCompartment.this.getHeldItemStack().copy(); + stack.setCount(1); + currentTab.setIcon(stack); + final NBTTagCompound nbt = new NBTTagCompound(); + currentTab.writeToNBT(nbt); + WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); + }); + this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.WHITE); + this.tabIcon.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.icon_label")); + this.tabIcon.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.icon_label.desc")); + } + + private int createTabNameControl(Panel tabPropertyPanel, int y2) { new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Name:"); y2 += 12; (this.tabName = new ControlTextEdit(tabPropertyPanel, 4, y2, 104, 12)).addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, this.tabName, event -> { diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index a53dffdf4..d14134087 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -197,6 +197,9 @@ binniecore.machine.storage.help.compartment_tab=Compartment Tab binniecore.machine.storage.help.compartment_tab.desc=Tabs that divide the inventory into sections. Each one can be labelled seperately. binniecore.machine.storage.help.slide_label=Tab Properties binniecore.machine.storage.help.slide_label.desc=The label, colour and icon of the Tab can be altered here. Clicking on the icon with a held item will change it. +binniecore.machine.storage.help.icon_label=Icon for Current Tab +binniecore.machine.storage.help.icon_label.text=Tab Icon: +binniecore.machine.storage.help.icon_label.desc=Click here with an item to change binniecore.machine.storage.compartment=Compartment binniecore.machine.storage.compartment.info=Chests which contain several tabs to help organise their contents. Each tab can be named, assigned a colour and assigned an icon from any Item Stack. Number of Tabs: 4, slots per Tab: 25 binniecore.machine.storage.compartment_iron=Iron Compartment diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 276cf9336..1ab79f037 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -197,6 +197,9 @@ binniecore.machine.storage.help.compartment_tab=Вкладка Отсека binniecore.machine.storage.help.compartment_tab.desc=Вкладки делят инвентарь на секции. Каждая настраивается отдельно. binniecore.machine.storage.help.slide_label=Свойства вкладки binniecore.machine.storage.help.slide_label.desc=Заголовок, цвет и иконка могут быть назначены здесь. Кликнув на иконке удерживая предмет изменят ее. +binniecore.machine.storage.help.icon_label=Иконка для текущей вкладки +binniecore.machine.storage.help.icon_label.text=Иконка вкл.: +binniecore.machine.storage.help.icon_label.desc=Кликните здесь, чтобы изменить binniecore.machine.storage.compartment=Отсек binniecore.machine.storage.compartment.info=Сундуки, у которых несколько вкладок, чтобы помочь организовать их содержимое. Каждая вкладка может быть: переименована, назначен цвет, назначена пиктограмма из любого элемента. Количество вкладок: 4, слоты на вкладку: 25 binniecore.machine.storage.compartment_iron=Железный отсек From 241d31e17c69e07b94056de847b833c6029b7635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 11:25:45 +1000 Subject: [PATCH 97/99] Refactoring and localizing compartment --- .../machines/storage/WindowCompartment.java | 35 +++++++++++-------- .../assets/binniecore/lang/en_US.lang | 9 ++++- .../assets/binniecore/lang/ru_RU.lang | 9 ++++- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 6603f8550..737468cc1 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -108,7 +108,7 @@ private ControlSlide createSlide() { return slide; } - //TODO: Clean Up, Localise + //TODO: Clean Up @Override @SideOnly(Side.CLIENT) public void initialiseClient() { @@ -164,29 +164,36 @@ public void initialiseClient() { y2 += 20; createTabIconControl(tabPropertyPanel, y2); y2 += 20; - new ControlText(tabPropertyPanel, new Point(4, y2), "Colour: "); + createTabColourControl(tabPropertyPanel, y2); + createSearchControl(compartmentPageHeight, compartmentWidth, controlCompartment); + } + + private void createSearchControl(int compartmentPageHeight, int compartmentWidth, Control controlCompartment) { + final ControlButton searchButton = new SearchButton(this, controlCompartment, compartmentWidth, compartmentPageHeight); + searchButton.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.search_label")); + searchButton.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.search_label.desc")); + } + + private void createTabColourControl(Panel tabPropertyPanel, int y2) { + new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.сolour")); final int cw = 8; final Panel panelColour = new Panel(tabPropertyPanel, 40, y2 - 4, cw * 8 + 2, cw * 2 + 1, MinecraftGUI.PanelType.GRAY); for (int cc = 0; cc < 16; ++cc) { final ControlColourSelector color = new ControlColourSelector(panelColour, 1 + cw * (cc % 8), 1 + cw * (cc / 8), cw, cw, EnumColor.values()[cc]); color.addSelfEventHandler(EventMouse.Down.class, event -> { - final binnie.core.machines.storage.CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); + final CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); currentTab.setColor(color.getValue()); final NBTTagCompound nbt = new NBTTagCompound(); currentTab.writeToNBT(nbt); WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); }); - color.addHelp("Colour Selector"); - color.addHelp("Select a colour to highlight the current tab"); + color.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.сolour_label")); + color.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.сolour_label.desc")); } - y2 += 20; - final ControlButton searchButton = new SearchButton(this, controlCompartment, compartmentWidth, compartmentPageHeight); - searchButton.addHelp("Search Button"); - searchButton.addHelp("Clicking this will open the Search dialog. This allows you to search the inventory for specific items."); } - private void createTabIconControl(Panel tabPropertyPanel, int y2) { - new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.help.icon_label.text")); + private void createTabIconControl(Panel tabPropertyPanel, int y2) { + new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.icon")); (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); this.tabIcon.addAttribute(Attribute.MOUSE_OVER); this.tabIcon.addSelfEventHandler(EventMouse.Down.class, event -> { @@ -207,7 +214,7 @@ private void createTabIconControl(Panel tabPropertyPanel, int y2) { } private int createTabNameControl(Panel tabPropertyPanel, int y2) { - new ControlText(tabPropertyPanel, new Point(4, y2), "Tab Name:"); + new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.tab_name")); y2 += 12; (this.tabName = new ControlTextEdit(tabPropertyPanel, 4, y2, 104, 12)).addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, this.tabName, event -> { final CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); @@ -249,7 +256,7 @@ public void receiveGuiNBTOnServer(final EntityPlayer player, final String name, @Override public String getTitle() { - return "Compartment"; + return I18N.localise(ModId.CORE, "machine.storage.compartment"); } @Override @@ -334,7 +341,7 @@ private static class SearchButton extends ControlButton { private final WindowCompartment windowCompartment; public SearchButton(WindowCompartment windowCompartment, Control controlCompartment, int compartmentWidth, int compartmentPageHeight) { - super(controlCompartment, compartmentWidth - 24 - 64 - 8, compartmentPageHeight, 64, 16, "Search"); + super(controlCompartment, compartmentWidth - 24 - 64 - 8, compartmentPageHeight, 64, 16, I18N.localise(ModId.CORE, "machine.storage.search.button")); this.windowCompartment = windowCompartment; } diff --git a/core/src/main/resources/assets/binniecore/lang/en_US.lang b/core/src/main/resources/assets/binniecore/lang/en_US.lang index d14134087..099676cda 100644 --- a/core/src/main/resources/assets/binniecore/lang/en_US.lang +++ b/core/src/main/resources/assets/binniecore/lang/en_US.lang @@ -190,6 +190,8 @@ binniecore.item.container.bucket=Bucket binniecore.item.container.glass=Bottle binniecore.item.container.cylinder=Cylinder +binniecore.machine.storage.tab_name=Tab Name: +binniecore.machine.storage.search.button=Search binniecore.machine.storage.search.sort_by_name=Sort A-Z binniecore.machine.storage.search.include_items=Include Items binniecore.machine.storage.search.include_blocks=Include Blocks @@ -197,9 +199,14 @@ binniecore.machine.storage.help.compartment_tab=Compartment Tab binniecore.machine.storage.help.compartment_tab.desc=Tabs that divide the inventory into sections. Each one can be labelled seperately. binniecore.machine.storage.help.slide_label=Tab Properties binniecore.machine.storage.help.slide_label.desc=The label, colour and icon of the Tab can be altered here. Clicking on the icon with a held item will change it. +binniecore.machine.storage.icon=Tab Icon: binniecore.machine.storage.help.icon_label=Icon for Current Tab -binniecore.machine.storage.help.icon_label.text=Tab Icon: binniecore.machine.storage.help.icon_label.desc=Click here with an item to change +binniecore.machine.storage.help.search_label=Search Button +binniecore.machine.storage.help.search_label.desc=Clicking this will open the Search dialog. This allows you to search the inventory for specific items. +binniecore.machine.storage.сolour=Colour: +binniecore.machine.storage.help.сolour_label=Colour Selector +binniecore.machine.storage.help.сolour_label.desc=Select a colour to highlight the current tab binniecore.machine.storage.compartment=Compartment binniecore.machine.storage.compartment.info=Chests which contain several tabs to help organise their contents. Each tab can be named, assigned a colour and assigned an icon from any Item Stack. Number of Tabs: 4, slots per Tab: 25 binniecore.machine.storage.compartment_iron=Iron Compartment diff --git a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang index 1ab79f037..f0a8c495c 100644 --- a/core/src/main/resources/assets/binniecore/lang/ru_RU.lang +++ b/core/src/main/resources/assets/binniecore/lang/ru_RU.lang @@ -190,6 +190,8 @@ binniecore.item.container.bucket=Ведро binniecore.item.container.glass=Бутылка binniecore.item.container.cylinder=Цилиндр +binniecore.machine.storage.tab_name=Имя вкладки: +binniecore.machine.storage.search.button=Поиск binniecore.machine.storage.search.sort_by_name=Сорт. A-Z binniecore.machine.storage.search.include_items=Включая предметы binniecore.machine.storage.search.include_blocks=Включая блоки @@ -197,9 +199,14 @@ binniecore.machine.storage.help.compartment_tab=Вкладка Отсека binniecore.machine.storage.help.compartment_tab.desc=Вкладки делят инвентарь на секции. Каждая настраивается отдельно. binniecore.machine.storage.help.slide_label=Свойства вкладки binniecore.machine.storage.help.slide_label.desc=Заголовок, цвет и иконка могут быть назначены здесь. Кликнув на иконке удерживая предмет изменят ее. +binniecore.machine.storage.icon=Иконка вкл.: binniecore.machine.storage.help.icon_label=Иконка для текущей вкладки -binniecore.machine.storage.help.icon_label.text=Иконка вкл.: binniecore.machine.storage.help.icon_label.desc=Кликните здесь, чтобы изменить +binniecore.machine.storage.help.search_label=Кнопка поиска +binniecore.machine.storage.help.search_label.desc=Кликнув вы откроете окно поиска. Это позволяет искать в инвентаре специфические предметы. +binniecore.machine.storage.сolour=Цвет: +binniecore.machine.storage.help.сolour_label=Выбор цвета +binniecore.machine.storage.help.сolour_label.desc=Выбрать цвет, чтобы выделять текущую вкладку binniecore.machine.storage.compartment=Отсек binniecore.machine.storage.compartment.info=Сундуки, у которых несколько вкладок, чтобы помочь организовать их содержимое. Каждая вкладка может быть: переименована, назначен цвет, назначена пиктограмма из любого элемента. Количество вкладок: 4, слоты на вкладку: 25 binniecore.machine.storage.compartment_iron=Железный отсек From 01b2c61deae8b44ea915b20caca71ec29fdfb80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 11:29:06 +1000 Subject: [PATCH 98/99] indentation --- .../machines/storage/WindowCompartment.java | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java index 737468cc1..3836b42dd 100644 --- a/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java +++ b/core/src/main/java/binnie/core/machines/storage/WindowCompartment.java @@ -100,13 +100,13 @@ private void setControlTab(ControlTabBar tab) { } private ControlSlide createSlide() { - final ControlSlide slide = new ControlSlide(this, 0, 134, 136, 92, Alignment.LEFT); - slide.setLabel(I18N.localise(ModId.CORE, "machine.storage.help.slide_label")); - slide.setSlide(false); - slide.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.slide_label")); - slide.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.slide_label.desc")); - return slide; - } + final ControlSlide slide = new ControlSlide(this, 0, 134, 136, 92, Alignment.LEFT); + slide.setLabel(I18N.localise(ModId.CORE, "machine.storage.help.slide_label")); + slide.setSlide(false); + slide.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.slide_label")); + slide.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.slide_label.desc")); + return slide; + } //TODO: Clean Up @Override @@ -157,12 +157,12 @@ public void initialiseClient() { controlCompartment.setPosition(new Point((this.getWidth() - controlCompartment.getWidth()) / 2, controlCompartment.getYPos())); new ControlPlayerInventory(this, true); - ControlSlide slide = createSlide(); + ControlSlide slide = createSlide(); final Panel tabPropertyPanel = new Panel(slide, 16, 8, 112, 76, MinecraftGUI.PanelType.GRAY); int y2 = 4; y2 = createTabNameControl(tabPropertyPanel, y2); y2 += 20; - createTabIconControl(tabPropertyPanel, y2); + createTabIconControl(tabPropertyPanel, y2); y2 += 20; createTabColourControl(tabPropertyPanel, y2); createSearchControl(compartmentPageHeight, compartmentWidth, controlCompartment); @@ -193,27 +193,27 @@ private void createTabColourControl(Panel tabPropertyPanel, int y2) { } private void createTabIconControl(Panel tabPropertyPanel, int y2) { - new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.icon")); - (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); - this.tabIcon.addAttribute(Attribute.MOUSE_OVER); - this.tabIcon.addSelfEventHandler(EventMouse.Down.class, event -> { - if (WindowCompartment.this.getHeldItemStack().isEmpty()) { - return; - } - final CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); - final ItemStack stack = WindowCompartment.this.getHeldItemStack().copy(); - stack.setCount(1); - currentTab.setIcon(stack); - final NBTTagCompound nbt = new NBTTagCompound(); - currentTab.writeToNBT(nbt); - WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); - }); - this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.WHITE); - this.tabIcon.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.icon_label")); - this.tabIcon.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.icon_label.desc")); - } - - private int createTabNameControl(Panel tabPropertyPanel, int y2) { + new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.icon")); + (this.tabIcon = new ControlItemDisplay(tabPropertyPanel, 58, y2 - 4)).setItemStack(new ItemStack(Items.PAPER)); + this.tabIcon.addAttribute(Attribute.MOUSE_OVER); + this.tabIcon.addSelfEventHandler(EventMouse.Down.class, event -> { + if (WindowCompartment.this.getHeldItemStack().isEmpty()) { + return; + } + final CompartmentTab currentTab = WindowCompartment.this.getCurrentTab(); + final ItemStack stack = WindowCompartment.this.getHeldItemStack().copy(); + stack.setCount(1); + currentTab.setIcon(stack); + final NBTTagCompound nbt = new NBTTagCompound(); + currentTab.writeToNBT(nbt); + WindowCompartment.this.sendClientAction(ComponentCompartmentInventory.ACTION_COMP_CHANGE_TAB, nbt); + }); + this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.WHITE); + this.tabIcon.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.icon_label")); + this.tabIcon.addHelp(I18N.localise(ModId.CORE, "machine.storage.help.icon_label.desc")); + } + + private int createTabNameControl(Panel tabPropertyPanel, int y2) { new ControlText(tabPropertyPanel, new Point(4, y2), I18N.localise(ModId.CORE, "machine.storage.tab_name")); y2 += 12; (this.tabName = new ControlTextEdit(tabPropertyPanel, 4, y2, 104, 12)).addEventHandler(EventTextEdit.class, EventHandlerOrigin.SELF, this.tabName, event -> { @@ -285,11 +285,11 @@ public CompartmentTab getCurrentTab() { return this.getTab(this.currentTab); } - private ControlTab createTab(int x1, int y1, int w, int h, Integer value) { - return new CompartmentTabIcon(this, x1, y1, w, h, value); - } + private ControlTab createTab(int x1, int y1, int w, int h, Integer value) { + return new CompartmentTabIcon(this, x1, y1, w, h, value); + } - private static class CompartmentTabIcon extends ControlTabIcon { + private static class CompartmentTabIcon extends ControlTabIcon { private final WindowCompartment windowCompartment; public CompartmentTabIcon(WindowCompartment windowCompartment, int x, int y, int w, int h, Integer value) { From 839e47684758c7c201b4b681268a0fa7e9ed0f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D1=85=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9?= Date: Mon, 16 Apr 2018 13:14:02 +1000 Subject: [PATCH 99/99] Remove unused comment. --- .../core/machines/storage/ComponentCompartmentInventory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java b/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java index 26ea09b91..267fd7a40 100644 --- a/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java +++ b/core/src/main/java/binnie/core/machines/storage/ComponentCompartmentInventory.java @@ -64,7 +64,6 @@ public void sendGuiNBTToClient(final Map nbt) { @Override public void receiveGuiNBTOnClient(final EntityPlayer player, final String name, final NBTTagCompound nbt) { - // TODO: RusTit: I think here should be ACTION_COMP_CHANGE_TAB key, need testing. if (name.equals(NBT_KEY_COMP_TABS)) { final NBTTagList tags = nbt.getTagList(NBT_KEY_TABS, 10); for (int i = 0; i < tags.tagCount(); ++i) {