-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Theta-Dev/update_1.5
Update 1.5 -> 1.16.1
- Loading branch information
Showing
15 changed files
with
315 additions
and
199 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ mcp_mappings=20200723-1.16.1 | |
botania=1.16-398 | ||
|
||
version_major=1 | ||
version_minor=4 | ||
version_minor=5 |
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/thetadev/constructionwand/basics/pool/IPool.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,11 @@ | ||
package thetadev.constructionwand.basics.pool; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public interface IPool<T> | ||
{ | ||
void add(T element); | ||
@Nullable | ||
T draw(); | ||
void reset(); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/thetadev/constructionwand/basics/pool/OrderedPool.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,34 @@ | ||
package thetadev.constructionwand.basics.pool; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.ArrayList; | ||
|
||
public class OrderedPool<T> implements IPool<T> | ||
{ | ||
private final ArrayList<T> elements; | ||
private int index; | ||
|
||
public OrderedPool() { | ||
elements = new ArrayList<>(); | ||
reset(); | ||
} | ||
|
||
@Override | ||
public void add(T element) { | ||
elements.add(element); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public T draw() { | ||
if(index >= elements.size()) return null; | ||
T e = elements.get(index); | ||
index++; | ||
return e; | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
index = 0; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/thetadev/constructionwand/basics/pool/RandomPool.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,54 @@ | ||
package thetadev.constructionwand.basics.pool; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Random; | ||
|
||
public class RandomPool<T> implements IPool<T> | ||
{ | ||
private final Random rng; | ||
private final HashMap<T, Integer> elements; | ||
private HashSet<T> pool; | ||
|
||
public RandomPool(Random rng) { | ||
this.rng = rng; | ||
elements = new HashMap<>(); | ||
reset(); | ||
} | ||
|
||
@Override | ||
public void add(T element) { | ||
addWithWeight(element, 1); | ||
} | ||
|
||
public void addWithWeight(T element, int weight) { | ||
if(weight < 1) return; | ||
elements.merge(element, weight, Integer::sum); | ||
pool.add(element); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public T draw() { | ||
int allWeights = pool.stream().reduce(0, (partialRes, e) -> partialRes + elements.get(e), Integer::sum); | ||
if(allWeights < 1) return null; | ||
|
||
int random = rng.nextInt(allWeights); | ||
int accWeight = 0; | ||
|
||
for(T e : pool) { | ||
accWeight += elements.get(e); | ||
if(random < accWeight) { | ||
pool.remove(e); | ||
return e; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
pool = new HashSet<>(elements.keySet()); | ||
} | ||
} |
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
98 changes: 0 additions & 98 deletions
98
src/main/java/thetadev/constructionwand/job/JobHistory.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.