diff --git a/README.md b/README.md index 3a5d1c6..a6f4325 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 23e6ce2..8084998 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/gradle.properties b/gradle.properties index a9a10fe..6985b1c 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 diff --git a/src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.java b/src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.java index 151a573..1050d47 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 2cd9390..378c999 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,15 @@ public void splitStacks(PipeEventItem.Split splitEvent) { if(getItemsLeftThisSide() <= 0) { - toNextOpenSide(); + 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); + break; + } } ItemEntry stackPartThisSide = new ItemEntry(null, entry.stack.copy(), entry.from); @@ -116,26 +143,26 @@ 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() - { - EnumFacing lastDistSide = distSide; - + private boolean toNextOpenSide() + { 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; + return true; } } + + return false; } /**