From f9efc57898c614200b8610130e8c37d8816227bc Mon Sep 17 00:00:00 2001 From: RusTit Date: Sat, 7 Apr 2018 13:48:26 +1000 Subject: [PATCH] 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; }