diff --git a/dependencies.gradle b/dependencies.gradle index 041826c0..94bcffaa 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,12 +1,12 @@ // Add your dependencies here dependencies { - api('com.github.GTNewHorizons:ForestryMC:4.11.0:dev') - implementation('com.github.GTNewHorizons:GTNHLib:0.7.3:dev') + api('com.github.GTNewHorizons:ForestryMC:4.11.4:dev') + implementation('com.github.GTNewHorizons:GTNHLib:0.9.13:dev') - devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.26-GTNH:dev') + devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.63-GTNH:dev') - compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.45:api') + compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.55:api') compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev') compileOnly("curse.maven:extrabiomesxl-60041:2273301") } diff --git a/gradle.properties b/gradle.properties index 21bd5cd7..2a8709c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,14 +39,34 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co # `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE. developmentEnvironmentUserName = Developer -# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8. -# See https://github.com/bsideup/jabel for details on how this works. -enableModernJavaSyntax = true +# Enables modern Java syntax support. Valid values: +# - false: No modern syntax, Java 8 only +# - jabel: Jabel syntax-only support, compiles to J8 bytecode +# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs) +# - modern: Native modern Java bytecode, no downgrading +enableModernJavaSyntax = jabel # If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues, # and should *not* be used in most situations. -1 disables this. # forceToolchainVersion = -1 +# Target JVM version for JVM Downgrader bytecode downgrading. +# Only used when enableModernJavaSyntax = jvmDowngrader +# downgradeTargetVersion = 8 + +# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only). +# Classes will be available in META-INF/versions/N/ for each version N in this list. +# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade). +# jvmDowngraderMultiReleaseVersions = 21,25 + +# Specifies how JVM Downgrader API stubs are provided. Options: +# - shade: Shade minimized stubs into the jar +# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint) +# - external: Another dependency provides stubs (no constraint, no warning) +# - (empty): Warning reminding you to configure stubs +# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md +# jvmDowngraderStubsProvider = + # Enables injecting missing generics into the decompiled source code for a better coding experience. # Turns most publicly visible List, Map, etc. into proper List, Map types. enableGenericInjection = true diff --git a/settings.gradle b/settings.gradle index 2b172cf9..335f37c4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,5 +17,5 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.6' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.19' } diff --git a/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java b/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java index 6df30578..700a30a6 100644 --- a/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java +++ b/src/main/java/binnie/core/machines/inventory/ComponentInventorySlots.java @@ -1,7 +1,6 @@ package binnie.core.machines.inventory; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Random; @@ -16,10 +15,13 @@ import net.minecraftforge.common.util.ForgeDirection; import binnie.core.machines.IMachine; +import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; public class ComponentInventorySlots extends ComponentInventory implements IInventoryMachine, IInventorySlots { - private final Map inventory = new LinkedHashMap<>(); + private final Int2ObjectLinkedOpenHashMap inventory = new Int2ObjectLinkedOpenHashMap<>(); + private int cachedSize = 0; + private int[] cachedAccessibleSlots = null; public ComponentInventorySlots(IMachine machine) { super(machine); @@ -27,25 +29,20 @@ public ComponentInventorySlots(IMachine machine) { @Override public int getSizeInventory() { - int size = 0; - for (Integer index : inventory.keySet()) { - size = Math.max(size, index + 1); - } - return size; + return cachedSize; } @Override public ItemStack getStackInSlot(int index) { - if (inventory.containsKey(index)) { - return inventory.get(index).getContent(); - } - return null; + InventorySlot slot = inventory.get(index); + return slot != null ? slot.getContent() : null; } @Override public ItemStack decrStackSize(int index, int amount) { - if (inventory.containsKey(index)) { - ItemStack stack = inventory.get(index).decrStackSize(amount); + InventorySlot slot = inventory.get(index); + if (slot != null) { + ItemStack stack = slot.decrStackSize(amount); markDirty(); return stack; } @@ -59,8 +56,9 @@ public ItemStack getStackInSlotOnClosing(int var1) { @Override public void setInventorySlotContents(int index, ItemStack itemStack) { - if (inventory.containsKey(index) && (itemStack == null || inventory.get(index).isValid(itemStack))) { - inventory.get(index).setContent(itemStack); + InventorySlot slot = inventory.get(index); + if (slot != null && (itemStack == null || slot.isValid(itemStack))) { + slot.setContent(itemStack); } markDirty(); } @@ -113,7 +111,7 @@ public void readFromNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); NBTTagList inventoryNBT = new NBTTagList(); - for (Map.Entry entry : inventory.entrySet()) { + for (Map.Entry entry : inventory.int2ObjectEntrySet()) { NBTTagCompound slotNBT = new NBTTagCompound(); slotNBT.setInteger("id", entry.getKey()); entry.getValue().writeToNBT(slotNBT); @@ -125,6 +123,8 @@ public void writeToNBT(NBTTagCompound nbttagcompound) { @Override public InventorySlot addSlot(int index, String unlocalizedName) { inventory.put(index, new InventorySlot(index, unlocalizedName)); + cachedSize = Math.max(cachedSize, index + 1); + cachedAccessibleSlots = null; return getSlot(index); } @@ -138,10 +138,7 @@ public InventorySlot[] addSlotArray(int[] indexes, String unlocalizedName) { @Override public InventorySlot getSlot(int index) { - if (inventory.containsKey(index)) { - return inventory.get(index); - } - return null; + return inventory.get(index); } @Override @@ -151,7 +148,7 @@ public InventorySlot[] getAllSlots() { @Override public InventorySlot[] getSlots(int[] indexes) { - List list = new ArrayList<>(); + List list = new ArrayList<>(indexes.length); for (int i : indexes) { if (getSlot(i) != null) { list.add(getSlot(i)); @@ -213,18 +210,20 @@ public void onDestruction() { @Override public int[] getAccessibleSlotsFromSide(int var1) { - List slots = new ArrayList<>(); - for (InventorySlot slot : inventory.values()) { - if (slot.canInsert() || slot.canExtract()) { - slots.add(slot.getIndex()); + if (cachedAccessibleSlots == null) { + List slots = new ArrayList<>(); + for (InventorySlot slot : inventory.values()) { + if (slot.canInsert() || slot.canExtract()) { + slots.add(slot.getIndex()); + } } - } - int[] ids = new int[slots.size()]; - for (int i = 0; i < slots.size(); ++i) { - ids[i] = slots.get(i); + cachedAccessibleSlots = new int[slots.size()]; + for (int i = 0; i < slots.size(); ++i) { + cachedAccessibleSlots[i] = slots.get(i); + } } - return ids; + return cachedAccessibleSlots; } @Override @@ -234,6 +233,7 @@ public boolean canInsertItem(int slot, ItemStack itemstack, int direction) { @Override public boolean canExtractItem(int slot, ItemStack itemstack, int direction) { - return getSlot(slot).canExtract(ForgeDirection.getOrientation(direction)); + InventorySlot iSlot = getSlot(slot); + return iSlot != null && iSlot.canExtract(ForgeDirection.getOrientation(direction)); } }