From 83f457978c72faa455b534126a39335f25800515 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 16 Oct 2025 00:28:25 -0700 Subject: [PATCH 1/3] Try and fix distribution pipe hang --- README.md | 1 + build.gradle | 2 +- .../item/ItemDogDeaggravator.java | 4 +-- .../pipes/PipeBehaviorDistribution.java | 36 ++++++++++++++++--- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3a5d1c69..a6f4325a 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Compiled binaries can be found in `build/libs`. ### Setting Up Eclipse ### 1. Install Eclipse JDK. +2. If your PC uses Java newer than 8 by default, update your `JAVA_HOME` environment variable to point to JDK 8. 2. Run the command `gradlew setupDecompWorkspace --refresh-dependencies eclipse` 3. In Eclipse, go to `File > Import... > General > Existing Projects into Workspace` 4. Hit Next. Click Browse... in the top right, and select the directory you cloned Additional Pipes into. Check the box next to AdditionalPipesBC in the Projects list. diff --git a/build.gradle b/build.gradle index 23e6ce2b..8084998a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle.forge' -version = "6.0.0.8" +version = "6.0.1" group= "com.buildcraft.additionalpipes" archivesBaseName = "additionalpipes" diff --git a/src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.java b/src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.java index 151a5737..1050d471 100644 --- a/src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.java +++ b/src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.java @@ -40,8 +40,8 @@ public ActionResult onItemRightClick(World world, EntityPlayer player { //this code adapted from EntityAIHurtByTarget.startExecuting() double horizontalRange = 16; - List list = world.getEntitiesWithinAABB(EntityWolf.class, new AxisAlignedBB(player.posX, player.posY, player.posZ, - player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).grow(horizontalRange, 10.0D, horizontalRange)); + List list = world.getEntitiesWithinAABB(EntityWolf.class, new AxisAlignedBB(player.posX, player.posY + 1.0D, player.posZ, + player.posX, player.posY + 1.0D, player.posZ).grow(horizontalRange, 10.0D, horizontalRange)); Iterator iterator = list.iterator(); int wolfCounter = 0; diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java index 2cd93908..941159f0 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java @@ -65,6 +65,25 @@ public int getTextureIndex(EnumFacing connection) return connection.ordinal(); } + /** + * @brief Event handler for the SideCheck event, which is called before the Split event. + */ + @PipeEventHandler + public void sideCheck(PipeEventItem.SideCheck sideCheckEvent) + { + // Disallow all sides that have a distData value of 0 (all items disallowed). + // This is important to do so that if all distData values for connected sides are 0, we will just drop the item as it has nowhere to go. + // Note that we could also "bounce" the item back out of the distribution pipe by handling the TryBounce event, but dropping them + // seems simpler for now. + for(int o = 0; o < distData.length; ++o) + { + if(distData[o] == 0) + { + sideCheckEvent.disallow(EnumFacing.VALUES[o]); + } + } + } + @PipeEventHandler public void splitStacks(PipeEventItem.Split splitEvent) { @@ -96,7 +115,13 @@ public void splitStacks(PipeEventItem.Split splitEvent) { if(getItemsLeftThisSide() <= 0) { - toNextOpenSide(); + if(!toNextOpenSide()) + { + Log.error("Failed to distribute itemstack. Allowing it to be routed randomly."); + entry.to.clear(); + newDistribution.add(entry); + break; + } } ItemEntry stackPartThisSide = new ItemEntry(null, entry.stack.copy(), entry.from); @@ -116,13 +141,14 @@ public void splitStacks(PipeEventItem.Split splitEvent) splitEvent.items.clear(); splitEvent.items.addAll(newDistribution); } - /** * Moves the pipe to the next open side. + * + * @return true if there is another open side that can accept an item stack, false otherwise. */ - private void toNextOpenSide() + private boolean toNextOpenSide() { EnumFacing lastDistSide = distSide; @@ -133,9 +159,11 @@ private void toNextOpenSide() if(distData[distSide.ordinal()] > 0 && pipe.isConnected(distSide)) { Log.debug("toNextOpenSide(): distSide changed: " + lastDistSide + "-> " + distSide); - return; + return true; } } + + return false; } /** From d4719788f998bd9d3ce196f68ca6c79c3cfbfa32 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 16 Oct 2025 00:42:50 -0700 Subject: [PATCH 2/3] Disable broken version check on ForgeGradle --- gradle.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a9a10fe0..6985b1c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx4096M mc_version=1.12.2 -jei_version=4.8.5.142 \ No newline at end of file +jei_version=4.8.5.142 +net.minecraftforge.gradle.disableUpdateChecker=true \ No newline at end of file From 04b7e6fe22c9bdd27b19ca0552a300faaee983f0 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 16 Oct 2025 00:45:10 -0700 Subject: [PATCH 3/3] Add comment, remove spammy log --- .../additionalpipes/pipes/PipeBehaviorDistribution.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java index 941159f0..378c999c 100644 --- a/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java +++ b/src/main/java/buildcraft/additionalpipes/pipes/PipeBehaviorDistribution.java @@ -117,6 +117,8 @@ public void splitStacks(PipeEventItem.Split splitEvent) { if(!toNextOpenSide()) { + // *shouldn't* be possible to get here due to the sideCheck() event handler, but keeping this logic just in case as + // otherwise we would hit an infinite hang. Log.error("Failed to distribute itemstack. Allowing it to be routed randomly."); entry.to.clear(); newDistribution.add(entry); @@ -149,16 +151,13 @@ public void splitStacks(PipeEventItem.Split splitEvent) * @return true if there is another open side that can accept an item stack, false otherwise. */ private boolean toNextOpenSide() - { - EnumFacing lastDistSide = distSide; - + { itemsThisSide = 0; for(int o = 0; o < distData.length; ++o) { distSide = EnumFacing.VALUES[(distSide.ordinal() + 1) % distData.length]; if(distData[distSide.ordinal()] > 0 && pipe.isConnected(distSide)) { - Log.debug("toNextOpenSide(): distSide changed: " + lastDistSide + "-> " + distSide); return true; } }