Compare commits

...
Author SHA1 Message Date
Martin Robertz 66e040d9b3 update 2025-11-04 22:44:09 +01:00
Worive 7f8c7ca5bc Rename attribute for more clarity 2025-11-04 18:26:07 +01:00
Worive e4daa5a796 Improve NetworkedInventory robustness
Replaced the hardcoded inventory re-check logic with a universal TileEntity validity check. By caching the TileEntity and using isInvalid(), conduits can now automatically detect when a connected block is broken or replaced, allowing them to reconnect seamlessly.
2025-11-02 10:50:55 +01:00
8 changed files with 71 additions and 48 deletions

No files matched your search

+14 -14
View File
@@ -2,23 +2,23 @@
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.5.0:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.17:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.19-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.7.0:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.2:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.26-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.7.7:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.45:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
api("com.github.GTNewHorizons:TinkersConstruct:1.14.6-GTNH:dev")
compileOnly('com.github.GTNewHorizons:waila:1.9.2:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-717-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.1-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.60:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.3.4-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.17.0:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.2.0-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.17.0-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.2-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.9.7:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-729-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.2-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.95:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.3.5-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.17.4:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.2.1-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.17.3-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.4-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:ee3-65509:2305023') // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
@@ -26,6 +26,6 @@ dependencies {
compileOnly(rfg.deobf('curse.maven:mekanism-268560:2475797')) // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
compileOnly(rfg.deobf('maven.modrinth:immibis-microblocks:59.1.2')) // https://modrinth.com/mod/immibis-microblocks/version/59.1.2
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta62:api') {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.3:dev")
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta64:api') {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.9:dev")
}
+9 -1
View File
@@ -96,7 +96,9 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -172,6 +174,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -2
View File
@@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -2
View File
@@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
}
@@ -10,7 +10,6 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -41,8 +40,8 @@ public class NetworkedInventory {
int tickDeficit;
// work around for a vanilla chest changing into a double chest without doing unneeded checks all the time
boolean recheckInv = false;
private TileEntity connectedTileEntity;
// Hack for TiC crafting station not working correctly when setting output slot to null
boolean ticHack = false;
@@ -61,19 +60,13 @@ public class NetworkedInventory {
this.location = location;
world = con.getBundle().getWorld();
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if (te.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if (te.getClass().getName().contains("cpw.mods.ironchest")) {
recheckInv = true;
} else if (te instanceof TileEntityChest) {
recheckInv = true;
} else if (te instanceof TileInventoryPanel) {
inventoryPanel = true;
}
updateInventory();
}
public boolean isInvalid() {
return connectedTileEntity == null || connectedTileEntity.isInvalid();
}
public boolean hasTarget(IItemConduit conduit, ForgeDirection dir) {
for (Target t : sendPriority) {
if (t.inv.con == conduit && t.inv.conDir == dir) {
@@ -110,6 +103,13 @@ public class NetworkedInventory {
}
public void onTick() {
if (isInvalid()) {
updateInventory();
if (isInvalid()) {
return;
}
}
if (tickDeficit > 0 || !canExtract() || !con.isExtractionRedstoneConditionMet(conDir)) {
// do nothing
} else {
@@ -144,11 +144,6 @@ public class NetworkedInventory {
}
private boolean transferItems() {
if (recheckInv) {
updateInventory();
}
int[] slotIndices = getInventory().getAccessibleSlotsFromSide(inventorySide);
if (slotIndices == null) {
return false;
@@ -257,9 +252,6 @@ public class NetworkedInventory {
matchedStickyInput = of != null && of.isValid() && of.doesItemPassFilter(this, toExtract);
}
if (target.stickyInput || !matchedStickyInput) {
if (target.inv.recheckInv) {
target.inv.updateInventory();
}
int inserted = target.inv.insertItem(toExtract);
if (inserted > 0) {
toExtract.stackSize -= inserted;
@@ -281,15 +273,38 @@ public class NetworkedInventory {
}
public final void updateInventory() {
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if (te instanceof ISidedInventory) {
inv = (ISidedInventory) te;
} else if (te instanceof IInventory) {
inv = new InventoryWrapper((IInventory) te);
TileEntity newTe = world.getTileEntity(location.x, location.y, location.z);
if (newTe != connectedTileEntity) {
connectedTileEntity = newTe;
ticHack = false;
inventoryPanel = false;
if (connectedTileEntity != null) {
if (connectedTileEntity.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if (connectedTileEntity instanceof TileInventoryPanel) {
inventoryPanel = true;
}
}
network.routesChanged();
}
if (connectedTileEntity instanceof ISidedInventory) {
inv = (ISidedInventory) connectedTileEntity;
} else if (connectedTileEntity instanceof IInventory) {
inv = new InventoryWrapper((IInventory) connectedTileEntity);
} else {
inv = null;
}
}
private int insertItem(ItemStack item) {
if (isInvalid()) {
updateInventory();
if (isInvalid()) {
return 0;
}
}
if (!canInsert() || item == null) {
return 0;
}
@@ -410,7 +425,7 @@ public class NetworkedInventory {
}
public ISidedInventory getInventoryRecheck() {
if (recheckInv) {
if (isInvalid()) {
updateInventory();
}
return inv;