-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay breaking leaves by a few ticks, fixes #6
- Loading branch information
Showing
7 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
- Use mutable BlockPos when checking tree to improve a bit performances. | ||
- Delay breaking leaves by a few ticks making (fixes #6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 44 additions & 2 deletions
46
src/main/java/fr/raksrinana/fallingtree/ScheduledLeafBreak.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,50 @@ | ||
package fr.raksrinana.fallingtree; | ||
|
||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IWorld; | ||
import net.minecraft.world.server.ServerWorld; | ||
import java.util.Objects; | ||
|
||
public class ScheduledLeafBreak{ | ||
public ScheduledLeafBreak(IWorld world, BlockPos neighborPos){} | ||
private final ServerWorld world; | ||
private final BlockPos blockPos; | ||
private int remainingTicks; | ||
|
||
public ScheduledLeafBreak(ServerWorld world, BlockPos blockPos, int remainingTicks){ | ||
this.world = world; | ||
this.blockPos = blockPos; | ||
this.remainingTicks = remainingTicks; | ||
} | ||
|
||
public void tick(){ | ||
this.remainingTicks--; | ||
} | ||
|
||
public int getRemainingTicks(){ | ||
return remainingTicks; | ||
} | ||
|
||
public BlockPos getBlockPos(){ | ||
return blockPos; | ||
} | ||
|
||
public ServerWorld getWorld(){ | ||
return world; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o){ | ||
if(this == o){ | ||
return true; | ||
} | ||
if(!(o instanceof ScheduledLeafBreak)){ | ||
return false; | ||
} | ||
ScheduledLeafBreak that = (ScheduledLeafBreak) o; | ||
return Objects.equals(getWorld(), that.getWorld()) && Objects.equals(getBlockPos(), that.getBlockPos()); | ||
} | ||
|
||
@Override | ||
public int hashCode(){ | ||
return Objects.hash(getWorld(), getBlockPos()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters