Compare commits

..
3 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
14 changed files with 102 additions and 101 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'
}
@@ -9,18 +9,12 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.render.ConduitRenderer;
import crazypants.enderio.machine.hypercube.HyperCubeRegister;
import crazypants.enderio.machine.transceiver.ServerChannelRegister;
public class CommonProxy {
@@ -29,7 +23,6 @@ public class CommonProxy {
protected long serverTickCount = 0;
protected long clientTickCount = 0;
protected final TickTimer tickTimer = new TickTimer();
public ConduitNetworkTickHandler conduitNetworkTickHandler = null;
public CommonProxy() {}
@@ -51,7 +44,7 @@ public class CommonProxy {
}
public void loadIcons() {
;
}
public void load() {
@@ -83,22 +76,6 @@ public class CommonProxy {
return new ResourceLocation(EnderIO.DOMAIN + TEXTURE_PATH + name + TEXTURE_EXT);
}
public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
conduitNetworkTickHandler = new ConduitNetworkTickHandler();
FMLCommonHandler.instance().bus().register(conduitNetworkTickHandler);
}
public void onServerStarted(FMLServerStartedEvent event) {
HyperCubeRegister.load();
ServerChannelRegister.load();
}
public void onServerStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
FMLCommonHandler.instance().bus().unregister(conduitNetworkTickHandler);
conduitNetworkTickHandler = null;
}
public final class TickTimer {
@SubscribeEvent
+14 -18
View File
@@ -38,7 +38,6 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -112,6 +111,7 @@ import crazypants.enderio.machine.generator.zombie.BlockZombieGenerator.BlockEnd
import crazypants.enderio.machine.generator.zombie.BlockZombieGenerator.BlockFrankenZombieGenerator;
import crazypants.enderio.machine.generator.zombie.PacketNutrientTank;
import crazypants.enderio.machine.hypercube.BlockHyperCube;
import crazypants.enderio.machine.hypercube.HyperCubeRegister;
import crazypants.enderio.machine.invpanel.BlockInventoryPanel;
import crazypants.enderio.machine.killera.BlockKillerJoe;
import crazypants.enderio.machine.light.BlockElectricLight;
@@ -894,18 +894,22 @@ public class EnderIO {
}
@EventHandler
public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
proxy.onServerAboutToStart(event);
public void serverStarted(FMLServerStartedEvent event) {
HyperCubeRegister.load();
ServerChannelRegister.load();
}
@SubscribeEvent
public void worldSaved(WorldEvent.Save event) {
// Only save together with the overworld, because this gets called for every dimension separately
if (event.world.provider != null && event.world.provider.dimensionId == 0) {
ServerChannelRegister.store();
}
}
@EventHandler
public void onServerStarted(FMLServerStartedEvent event) {
proxy.onServerStarted(event);
}
@EventHandler
public void onServerStopped(FMLServerStoppedEvent event) {
proxy.onServerStopped(event);
public void serverStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
}
@EventHandler
@@ -917,12 +921,4 @@ public class EnderIO {
}
}
}
@SubscribeEvent
public void worldSaved(WorldEvent.Save event) {
// Only save together with the overworld, because this gets called for every dimension separately
if (event.world.provider != null && event.world.provider.dimensionId == 0) {
ServerChannelRegister.store();
}
}
}
@@ -7,8 +7,6 @@ import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import crazypants.enderio.EnderIO;
// I=base type, I is the base class of the implementations accepted by the network
public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
@@ -66,7 +64,7 @@ public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
public void addConduit(I con) {
if (!conduits.contains(con)) {
if (conduits.isEmpty()) {
EnderIO.proxy.conduitNetworkTickHandler.registerNetwork(this);
ConduitNetworkTickHandler.instance.registerNetwork(this);
}
conduits.add(con);
}
@@ -77,7 +75,7 @@ public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
con.setNetwork(null);
}
conduits.clear();
EnderIO.proxy.conduitNetworkTickHandler.unregisterNetwork(this);
ConduitNetworkTickHandler.instance.unregisterNetwork(this);
}
public List<I> getConduits() {
@@ -32,6 +32,7 @@ import com.enderio.core.client.render.BoundingBox;
import com.enderio.core.common.util.BlockCoord;
import com.enderio.core.common.util.Util;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -92,6 +93,9 @@ public class BlockConduitBundle extends BlockEio
public static BlockConduitBundle create() {
MinecraftForge.EVENT_BUS.register(ConduitNetworkTickHandler.instance);
FMLCommonHandler.instance().bus().register(ConduitNetworkTickHandler.instance);
PacketHandler.INSTANCE
.registerMessage(PacketFluidLevel.class, PacketFluidLevel.class, PacketHandler.nextID(), Side.CLIENT);
PacketHandler.INSTANCE
@@ -10,15 +10,18 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
public class ConduitNetworkTickHandler {
public interface TickListener {
public static final ConduitNetworkTickHandler instance = new ConduitNetworkTickHandler();
void tickStart(TickEvent.ServerTickEvent evt);
public static interface TickListener {
void tickEnd(TickEvent.ServerTickEvent evt);
public void tickStart(TickEvent.ServerTickEvent evt);
public void tickEnd(TickEvent.ServerTickEvent evt);
}
private final List<TickListener> listeners = new ArrayList<>();
private final IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean> networks = new IdentityHashMap<>();
private final List<TickListener> listeners = new ArrayList<TickListener>();
private final IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean> networks = new IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean>();
public void addListener(TickListener listener) {
listeners.add(listener);
@@ -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;
@@ -16,7 +16,7 @@ import com.enderio.core.common.util.RoundRobinIterator;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.power.IPowerConduit;
@@ -212,7 +212,7 @@ public class CapBankNetwork implements ICapBankNetwork {
long curTime = world.getTotalWorldTime();
if (curTime != timeAtLastApply) {
timeAtLastApply = curTime;
EnderIO.proxy.conduitNetworkTickHandler.addListener(tickListener);
ConduitNetworkTickHandler.instance.addListener(tickListener);
}
}