Skip to content

Commit

Permalink
Fix issues with breaking ice (#1587)
Browse files Browse the repository at this point in the history
* fix issues with breaking ice

* always return false

* add docs for Task#run
  • Loading branch information
TechLord22 authored Mar 16, 2023
1 parent 37a8bbb commit 6828cc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/java/gregtech/api/util/function/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
@FunctionalInterface
public interface Task {

/**
* Run the actions of this Task. Will be infinitely run each world tick until false is returned.
*
* @return {@code true} if the task should be run again, otherwise {@code false}
*/
boolean run();

}
5 changes: 3 additions & 2 deletions src/main/java/gregtech/common/ToolEventHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void onHarvestDrops(@Nonnull BlockEvent.HarvestDropsEvent event) {
EntityPlayer player = event.getHarvester();
if (player != null) {
ItemStack stack = player.getHeldItemMainhand();
if (!stack.hasTagCompound() || !(stack.getItem() instanceof IGTTool)) {
if (stack.isEmpty() || !stack.hasTagCompound() || !(stack.getItem() instanceof IGTTool)) {
return;
}
if (!event.isSilkTouching()) {
Expand All @@ -122,7 +122,8 @@ public static void onHarvestDrops(@Nonnull BlockEvent.HarvestDropsEvent event) {
if (flowingState == Blocks.FLOWING_WATER.getDefaultState()) {
world.setBlockToAir(icePos);
}
return true;
// only try once, so future water placement does not get eaten too
return false;
});
}
}
Expand Down

0 comments on commit 6828cc2

Please sign in to comment.