-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring, Fixed multiplyChance dividing instead of multiplying. Close
- Loading branch information
1 parent
d025861
commit de6c40c
Showing
5 changed files
with
175 additions
and
162 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,2 @@ | ||
Improved block replacement performance | ||
Fixed multiplyChance dividing instead of multiplying |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/the_fireplace/wgblockreplacer/logic/ReplacementQueue.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package the_fireplace.wgblockreplacer.logic; | ||
|
||
import net.minecraft.world.World; | ||
import net.minecraft.world.chunk.Chunk; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import the_fireplace.wgblockreplacer.api.config.ConfigAccess; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public final class ReplacementQueue { | ||
private static final Map<Pair<World, Chunk>, Integer> TIMERS = new ConcurrentHashMap<>(); | ||
|
||
public static void tick() { | ||
for (Map.Entry<Pair<World, Chunk>, Integer> p : TIMERS.entrySet()) { | ||
if (p.getValue() <= 0) { | ||
TIMERS.remove(p.getKey()); | ||
Replacer.doReplacement(p.getKey().getLeft(), p.getKey().getRight()); | ||
} else { | ||
TIMERS.put(p.getKey(), p.getValue() - 1); | ||
} | ||
} | ||
} | ||
|
||
public static void add(World world, Chunk chunk) { | ||
Pair<World, Chunk> p = Pair.of(world, chunk); | ||
TIMERS.putIfAbsent(p, ConfigAccess.getInstance().getLateReplacementTicks()); | ||
} | ||
} |
Oops, something went wrong.