Compare commits

..
2 Commits
8 changed files with 63 additions and 98 deletions

No files matched your search

+4 -4
View File
@@ -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")
}
+23 -3
View File
@@ -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<E>, Map<K, V> types.
enableGenericInjection = true
+1 -1
View File
@@ -17,5 +17,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.6'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.19'
}
@@ -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.minecraft.world.World;
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<Integer, InventorySlot> inventory = new LinkedHashMap<>();
private final Int2ObjectLinkedOpenHashMap<InventorySlot> inventory = new Int2ObjectLinkedOpenHashMap<>();
private int cachedSize = 0;
private int[] cachedAccessibleSlots = null;
public ComponentInventorySlots(IMachine machine) {
super(machine);
@@ -27,25 +29,20 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@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 class ComponentInventorySlots extends ComponentInventory implements IInve
@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 class ComponentInventorySlots extends ComponentInventory implements IInve
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
NBTTagList inventoryNBT = new NBTTagList();
for (Map.Entry<Integer, InventorySlot> entry : inventory.entrySet()) {
for (Map.Entry<Integer, InventorySlot> entry : inventory.int2ObjectEntrySet()) {
NBTTagCompound slotNBT = new NBTTagCompound();
slotNBT.setInteger("id", entry.getKey());
entry.getValue().writeToNBT(slotNBT);
@@ -125,6 +123,8 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@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 class ComponentInventorySlots extends ComponentInventory implements IInve
@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 class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public InventorySlot[] getSlots(int[] indexes) {
List<InventorySlot> list = new ArrayList<>();
List<InventorySlot> list = new ArrayList<>(indexes.length);
for (int i : indexes) {
if (getSlot(i) != null) {
list.add(getSlot(i));
@@ -213,18 +210,20 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
List<Integer> slots = new ArrayList<>();
for (InventorySlot slot : inventory.values()) {
if (slot.canInsert() || slot.canExtract()) {
slots.add(slot.getIndex());
if (cachedAccessibleSlots == null) {
List<Integer> slots = new ArrayList<>();
for (InventorySlot slot : inventory.values()) {
if (slot.canInsert() || slot.canExtract()) {
slots.add(slot.getIndex());
}
}
cachedAccessibleSlots = new int[slots.size()];
for (int i = 0; i < slots.size(); ++i) {
cachedAccessibleSlots[i] = slots.get(i);
}
}
int[] ids = new int[slots.size()];
for (int i = 0; i < slots.size(); ++i) {
ids[i] = slots.get(i);
}
return ids;
return cachedAccessibleSlots;
}
@Override
@@ -234,6 +233,7 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@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));
}
}
@@ -9,11 +9,4 @@ public interface IProcess extends IErrorStateSource {
boolean isInProgress();
ProcessInfo getInfo();
/***
* Returns true if the current target got worked on at least once.
*/
default boolean workedOnTarget() {
return false;
}
}
@@ -387,7 +387,7 @@ public enum ExtraTreeFruitGene implements IAlleleFruit, IFruitProvider {
if (ripeningTime >= ripeningPeriod) {
return 1.0f;
}
return ripeningTime / ripeningPeriod;
return (float) ripeningTime / ripeningPeriod;
}
@Override
@@ -19,10 +19,6 @@ import forestry.api.genetics.IIndividual;
public class SplicerComponentLogic extends ComponentProcessSetCost implements IProcess {
// Needed to keep stack. If user takes out target slot and it gets automatically refilled, this happens in the same
// tick
private ItemStack workedOnStack = null;
public int nOfGenes;
public SplicerComponentLogic(Machine machine) {
@@ -54,11 +50,6 @@ public class SplicerComponentLogic extends ComponentProcessSetCost implements IP
public void onInventoryUpdate() {
super.onInventoryUpdate();
nOfGenes = getGenesToUse();
ItemStack newTarget = getUtil().getStack(Splicer.SLOT_TARGET);
if (newTarget == null || !ItemStack.areItemStacksEqual(workedOnStack, newTarget)) {
workedOnStack = null;
}
}
protected int getGenesToUse() {
@@ -199,31 +190,5 @@ public class SplicerComponentLogic extends ComponentProcessSetCost implements IP
Splicer.setGene(gene, target, 1);
}
getUtil().damageItem(Splicer.SLOT_SERUM_VIAL, 1);
workedOnStack = getUtil().getStack(Splicer.SLOT_TARGET).copy();
}
@Override
public boolean workedOnTarget() {
return ItemStack.areItemStacksEqual(workedOnStack, getUtil().getStack(Splicer.SLOT_TARGET));
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagCompound tagWorkedOnStack = (NBTTagCompound) nbt.getTag("workedOnStack");
if (tagWorkedOnStack != null) {
workedOnStack = ItemStack.loadItemStackFromNBT(tagWorkedOnStack);
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
if (workedOnStack != null) {
NBTTagCompound tagWorkedOnStack = new NBTTagCompound();
workedOnStack.writeToNBT(tagWorkedOnStack);
// Need to save, in case inventory is full it might need to get moved out way later.
nbt.setTag("workedOnStack", tagWorkedOnStack);
}
}
}
@@ -3,7 +3,6 @@ package binnie.genetics.machine.splicer;
import net.minecraft.item.ItemStack;
import binnie.core.craftgui.minecraft.IMachineInformation;
import binnie.core.machines.IMachine;
import binnie.core.machines.Machine;
import binnie.core.machines.inventory.ComponentInventorySlots;
import binnie.core.machines.inventory.ComponentInventoryTransfer;
@@ -80,20 +79,8 @@ public class SplicerPackage extends AdvGeneticMachine.PackageAdvGeneticBase impl
@Override
public boolean fufilled(ItemStack stack) {
if (stack == null) {
return false;
}
IMachine machine = transfer.getMachine();
boolean hasSerum = machine.getMachineUtil().getStack(Splicer.SLOT_SERUM_VIAL) != null;
if (hasSerum) {
// Move item if it can't be processed anymore with current serum.
boolean validSerum = machine.getInterface(SplicerComponentLogic.class).isValidSerum() == null;
return !validSerum;
} else {
// Move item if there is no serum and item got processed already
return machine.getMachineUtil().getProcess().workedOnTarget();
}
return stack != null && transfer.getMachine().getMachineUtil().getStack(Splicer.SLOT_SERUM_VIAL) != null
&& transfer.getMachine().getInterface(SplicerComponentLogic.class).isValidSerum() != null;
}
});