diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da0705780..68b7f51117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,5 @@ # ChangeLog -* fix tools only accepting digger enchantments -* fix stone, netherrack, hay being craftable to 9 dust in a crafting table -* fix machines sometimes crashing when auto-output is toggled rapidly, resulting in it being enabled but no output side being set -* fix SoundEntryProvider always placing the JSON in /assets/gtceu/sounds.json -* add material tooltips for non-GT items -* add KJS binding for ChemicalHelper +* fix transfer + fix ldlib +* fix fluid slot overflow +* fix assembly line recipe handling diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java index 2e4719e7e1..32f7b2be34 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java @@ -178,7 +178,7 @@ private boolean onCoverDirty(CoverBehavior coverBehavior) { for (IRef ref : coverBehavior.getSyncStorage().getNonLazyFields()) { ref.update(); } - return coverBehavior.getSyncStorage().hasDirtyFields(); + return coverBehavior.getSyncStorage().hasDirtySyncFields() || coverBehavior.getSyncStorage().hasDirtyPersistedFields(); } return false; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java index a9d5b3f16f..4cca505034 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableFluidTank.java @@ -66,6 +66,9 @@ public NotifiableFluidTank(MetaMachine machine, List storages, IO for (FluidStorage storage : this.storages) { storage.setOnContentsChanged(this::onContentsChanged); } + if (io == IO.IN) { + this.allowSameFluids = true; + } } public NotifiableFluidTank(MetaMachine machine, int slots, long capacity, IO io) { @@ -215,6 +218,36 @@ public boolean isFluidValid(int tank, @NotNull FluidStack stack) { return storages[tank].isFluidValid(stack); } + @Override + public long fill(FluidStack resource, boolean simulate, boolean notifyChanges) { + if (resource.isEmpty()) return 0; + long filled = 0; + FluidStorage existingStorage = null; + if (!allowSameFluids) { + for (var storage : storages) { + if (!storage.getFluid().isEmpty() && storage.getFluid().isFluidEqual(resource)) { + existingStorage = storage; + break; + } + } + } + if (existingStorage == null) { + for (int i = 0; i < getTanks(); i++) { + if (filled > 0 && !allowSameFluids) { + break; + } + filled += fill(i, resource.copy(resource.getAmount() - filled), simulate, notifyChanges); + if (filled == resource.getAmount()) break; + } + } else { + filled += existingStorage.fill(resource.copy(resource.getAmount() - filled), simulate, notifyChanges); + } + if (notifyChanges && filled > 0 && !simulate) { + onContentsChanged(); + } + return filled; + } + @Override public long fill(int tank, FluidStack resource, boolean simulate, boolean notifyChanges) { if (tank >= 0 && tank < storages.length && canCapInput()) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeCoverContainer.java b/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeCoverContainer.java index 31b2f10505..bbe0c9855b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeCoverContainer.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeCoverContainer.java @@ -171,7 +171,7 @@ public void setCoverAtSide(@Nullable CoverBehavior coverBehavior, Direction side @SuppressWarnings("unused") private boolean onCoverDirty(CoverBehavior coverBehavior) { - return coverBehavior != null && coverBehavior.getSyncStorage().hasDirtyFields(); + return coverBehavior != null && (coverBehavior.getSyncStorage().hasDirtySyncFields() || coverBehavior.getSyncStorage().hasDirtyPersistedFields()); } @SuppressWarnings("unused") diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java index 53cb378da9..9cfe9367f5 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java @@ -62,7 +62,11 @@ public static SizedIngredient create(TagKey tag, int amount) { public static SizedIngredient copy(Ingredient ingredient) { if (ingredient instanceof SizedIngredient sizedIngredient) { - return SizedIngredient.create(sizedIngredient.inner, sizedIngredient.amount); + var copied = SizedIngredient.create(sizedIngredient.inner, sizedIngredient.amount); + if (sizedIngredient.itemStacks != null) { + copied.itemStacks = Arrays.stream(sizedIngredient.itemStacks).map(ItemStack::copy).toArray(ItemStack[]::new); + } + return copied; } return SizedIngredient.create(ingredient); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java b/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java index a32fa0564d..8541bf3b1b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java @@ -2,11 +2,17 @@ import com.gregtechceu.gtceu.GTCEu; import com.lowdragmc.lowdraglib.LDLib; +import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.syncdata.field.FieldManagedStorage; import com.lowdragmc.lowdraglib.syncdata.managed.IRef; +import net.minecraft.Util; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; /** * @author KilaBash @@ -32,6 +38,23 @@ public void init() { } } + final static BiFunction, Method> METHOD_CACHES = Util.memoize((rawField, clazz) -> { + var methodName = rawField.getAnnotation(UpdateListener.class).methodName(); + Method method = null; + while (clazz != null && method == null) { + try { + method = clazz.getDeclaredMethod(methodName, rawField.getType(), rawField.getType()); + method.setAccessible(true); + } catch (NoSuchMethodException ignored) { + } + clazz = clazz.getSuperclass(); + } + if (method == null) { + GTCEu.LOGGER.error("couldn't find the listener method {} for synced field {}", methodName, rawField.getName()); + } + return method; + }); + public void initEnhancedFeature() { for (IRef syncField : getSyncFields()) { var rawField = syncField.getKey().getRawField(); @@ -39,28 +62,15 @@ public void initEnhancedFeature() { addSyncUpdateListener(syncField.getKey(), enhancedManaged::scheduleRender); } if (rawField.isAnnotationPresent(UpdateListener.class)) { - var methodName = rawField.getAnnotation(UpdateListener.class).methodName(); - Method method = null; - Class clazz = enhancedManaged.getClass(); - while (clazz != null && method == null) { - try { - method = clazz.getDeclaredMethod(methodName, rawField.getType(), rawField.getType()); - method.setAccessible(true); - } catch (NoSuchMethodException ignored) { - } - clazz = clazz.getSuperclass(); - } + final var method = METHOD_CACHES.apply(rawField, enhancedManaged.getClass()); if (method != null) { - final Method finalMethod = method; addSyncUpdateListener(syncField.getKey(), (name, newValue, oldValue) -> { try { - finalMethod.invoke(enhancedManaged, newValue, oldValue); + method.invoke(enhancedManaged, newValue, oldValue); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }); - } else { - GTCEu.LOGGER.error("couldn't find the listener method {} for synced field {}", methodName, rawField.getName()); } } } diff --git a/gradle.properties b/gradle.properties index 8e332e4059..e7fbef03e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx6G # Mod Info mod_id = gtceu mod_name = GregTech -mod_version = 1.0.13.d +mod_version = 1.0.13.e mod_description = GregTech CE Unofficial, ported from 1.12.2 mod_license = LGPL-3.0 license mod_url = https://github.com/GregTechCEu/GregTech-Modern/ diff --git a/settings.gradle b/settings.gradle index 273d76fc16..fb3aea3a39 100644 --- a/settings.gradle +++ b/settings.gradle @@ -58,7 +58,7 @@ dependencyResolutionManagement { def architecturyLoomVersion = "1.0-SNAPSHOT" def vineFlowerVersion = "1.+" def macheteVersion = "1.+" - def ldLibVersion = "1.0.19.d" + def ldLibVersion = "1.0.20" fabric { def parchment = version("parchment", parchmentVersion)