mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 11:09:06 +00:00
Cleanup
This commit is contained in:
@@ -40,7 +40,8 @@ public class AtomicAverage {
|
||||
/**
|
||||
* Create an average holder
|
||||
*
|
||||
* @param size the size of entries to keep
|
||||
* @param size
|
||||
* the size of entries to keep
|
||||
*/
|
||||
public AtomicAverage(int size) {
|
||||
values = new AtomicDoubleArray(size);
|
||||
@@ -55,14 +56,15 @@ public class AtomicAverage {
|
||||
/**
|
||||
* Put a value into the average (rolls over if full)
|
||||
*
|
||||
* @param i the value
|
||||
* @param i
|
||||
* the value
|
||||
*/
|
||||
public void put(double i) {
|
||||
|
||||
try {
|
||||
dirty = true;
|
||||
|
||||
if (brandNew) {
|
||||
if(brandNew) {
|
||||
DoubleArrayUtils.fill(values, i);
|
||||
lastSum = size() * i;
|
||||
brandNew = false;
|
||||
@@ -73,7 +75,7 @@ public class AtomicAverage {
|
||||
lastSum = (lastSum - current) + i;
|
||||
values.set(cursor, i);
|
||||
cursor = cursor + 1 < size() ? cursor + 1 : 0;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -85,7 +87,7 @@ public class AtomicAverage {
|
||||
* @return the average
|
||||
*/
|
||||
public double getAverage() {
|
||||
if (dirty) {
|
||||
if(dirty) {
|
||||
calculateAverage();
|
||||
return getAverage();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AtomicRollingSequence extends AtomicAverage {
|
||||
public double addLast(int amt) {
|
||||
double f = 0;
|
||||
|
||||
for (int i = 0; i < Math.min(values.length(), amt); i++) {
|
||||
for(int i = 0; i < Math.min(values.length(), amt); i++) {
|
||||
f += values.get(i);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AtomicRollingSequence extends AtomicAverage {
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
if (dirtyExtremes > (isPrecision() ? 0 : values.length())) {
|
||||
if(dirtyExtremes > (isPrecision() ? 0 : values.length())) {
|
||||
resetExtremes();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class AtomicRollingSequence extends AtomicAverage {
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
if (dirtyExtremes > (isPrecision() ? 0 : values.length())) {
|
||||
if(dirtyExtremes > (isPrecision() ? 0 : values.length())) {
|
||||
resetExtremes();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AtomicRollingSequence extends AtomicAverage {
|
||||
}
|
||||
|
||||
public double getMedian() {
|
||||
if (dirtyMedian) {
|
||||
if(dirtyMedian) {
|
||||
recalculateMedian();
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class AtomicRollingSequence extends AtomicAverage {
|
||||
max = Integer.MIN_VALUE;
|
||||
min = Integer.MAX_VALUE;
|
||||
|
||||
for (int i = 0; i < values.length(); i++) {
|
||||
for(int i = 0; i < values.length(); i++) {
|
||||
double v = values.get(i);
|
||||
max = M.max(max, v);
|
||||
min = M.min(min, v);
|
||||
|
||||
@@ -79,47 +79,47 @@ public class Board {
|
||||
|
||||
public void update() {
|
||||
// Checking if we are ready to start updating the Scoreboard.
|
||||
if (!ready) {
|
||||
if(!ready) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Making sure the player is connected.
|
||||
if (!player.isOnline()) {
|
||||
if(!player.isOnline()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Making sure the Scoreboard Provider is set.
|
||||
if (boardSettings == null) {
|
||||
if(boardSettings == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Getting their Scoreboard display from the Scoreboard Provider.
|
||||
final List<String> entries = boardSettings.getBoardProvider().getLines(player).stream().map(APPLY_COLOR_TRANSLATION).collect(Collectors.toList());
|
||||
|
||||
if (boardSettings.getScoreDirection() == ScoreDirection.UP) {
|
||||
if(boardSettings.getScoreDirection() == ScoreDirection.UP) {
|
||||
Collections.reverse(entries);
|
||||
}
|
||||
|
||||
// Setting the Scoreboard title
|
||||
String title = boardSettings.getBoardProvider().getTitle(player);
|
||||
if (title.length() > 32) {
|
||||
if(title.length() > 32) {
|
||||
Bukkit.getLogger().warning("The title " + title + " is over 32 characters in length, substringing to prevent errors.");
|
||||
title = title.substring(0, 32);
|
||||
}
|
||||
objective.setDisplayName(C.translateAlternateColorCodes('&', title));
|
||||
|
||||
// Clearing previous Scoreboard values if entry sizes don't match.
|
||||
if (this.getScoreboard().getEntries().size() != entries.size())
|
||||
if(this.getScoreboard().getEntries().size() != entries.size())
|
||||
this.getScoreboard().getEntries().forEach(this::removeEntry);
|
||||
|
||||
// Setting Scoreboard lines.
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
for(int i = 0; i < entries.size(); i++) {
|
||||
String str = entries.get(i);
|
||||
BoardEntry entry = BoardEntry.translateToEntry(str);
|
||||
Team team = getScoreboard().getTeam(CACHED_ENTRIES[i]);
|
||||
|
||||
if (team == null) {
|
||||
if(team == null) {
|
||||
team = this.getScoreboard().registerNewTeam(CACHED_ENTRIES[i]);
|
||||
team.addEntry(team.getName());
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class Board {
|
||||
team.setPrefix(entry.getPrefix());
|
||||
team.setSuffix(entry.getSuffix());
|
||||
|
||||
switch (boardSettings.getScoreDirection()) {
|
||||
switch(boardSettings.getScoreDirection()) {
|
||||
case UP -> objective.getScore(team.getName()).setScore(1 + i);
|
||||
case DOWN -> objective.getScore(team.getName()).setScore(15 - i);
|
||||
}
|
||||
|
||||
@@ -38,16 +38,16 @@ public class BoardEntry {
|
||||
}
|
||||
|
||||
public static BoardEntry translateToEntry(String input) {
|
||||
if (input.isEmpty()) {
|
||||
if(input.isEmpty()) {
|
||||
return new BoardEntry("", "");
|
||||
}
|
||||
if (input.length() <= 16) {
|
||||
if(input.length() <= 16) {
|
||||
return new BoardEntry(input, "");
|
||||
} else {
|
||||
String prefix = input.substring(0, 16);
|
||||
String suffix = "";
|
||||
|
||||
if (prefix.endsWith("\u00a7")) {
|
||||
if(prefix.endsWith("\u00a7")) {
|
||||
prefix = prefix.substring(0, prefix.length() - 1);
|
||||
suffix = "\u00a7" + suffix;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BoardManager {
|
||||
|
||||
public void setup(Player player) {
|
||||
Optional.ofNullable(scoreboards.remove(player.getUniqueId())).ifPresent(Board::resetScoreboard);
|
||||
if (player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
|
||||
if(player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
scoreboards.put(player.getUniqueId(), new Board(player, boardSettings));
|
||||
|
||||
@@ -24,8 +24,10 @@ import java.io.Serializable;
|
||||
/**
|
||||
* A Biset
|
||||
*
|
||||
* @param <A> the first object type
|
||||
* @param <B> the second object type
|
||||
* @param <A>
|
||||
* the first object type
|
||||
* @param <B>
|
||||
* the second object type
|
||||
* @author cyberpwn
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
@@ -37,8 +39,10 @@ public class GBiset<A, B> implements Serializable {
|
||||
/**
|
||||
* Create a new Biset
|
||||
*
|
||||
* @param a the first object
|
||||
* @param b the second object
|
||||
* @param a
|
||||
* the first object
|
||||
* @param b
|
||||
* the second object
|
||||
*/
|
||||
public GBiset(A a, B b) {
|
||||
this.a = a;
|
||||
@@ -57,7 +61,8 @@ public class GBiset<A, B> implements Serializable {
|
||||
/**
|
||||
* Set the first object
|
||||
*
|
||||
* @param a the first object A
|
||||
* @param a
|
||||
* the first object A
|
||||
*/
|
||||
public void setA(A a) {
|
||||
this.a = a;
|
||||
|
||||
@@ -24,24 +24,27 @@ import java.util.List;
|
||||
/**
|
||||
* Adapts a list of objects into a list of other objects
|
||||
*
|
||||
* @param <FROM> the from object in lists (the item INSIDE the list)
|
||||
* @param <TO> the to object in lists (the item INSIDE the list)
|
||||
* @param <FROM>
|
||||
* the from object in lists (the item INSIDE the list)
|
||||
* @param <TO>
|
||||
* the to object in lists (the item INSIDE the list)
|
||||
* @author cyberpwn
|
||||
*/
|
||||
public abstract class GListAdapter<FROM, TO> {
|
||||
/**
|
||||
* Adapts a list of FROM to a list of TO
|
||||
*
|
||||
* @param from the from list
|
||||
* @param from
|
||||
* the from list
|
||||
* @return the to list
|
||||
*/
|
||||
public List<TO> adapt(List<FROM> from) {
|
||||
List<TO> adapted = new KList<>();
|
||||
|
||||
for (FROM i : from) {
|
||||
for(FROM i : from) {
|
||||
TO t = onAdapt(i);
|
||||
|
||||
if (t != null) {
|
||||
if(t != null) {
|
||||
adapted.add(onAdapt(i));
|
||||
}
|
||||
}
|
||||
@@ -52,7 +55,8 @@ public abstract class GListAdapter<FROM, TO> {
|
||||
/**
|
||||
* Adapts a list object FROM to TO for use with the adapt method
|
||||
*
|
||||
* @param from the from object
|
||||
* @param from
|
||||
* the from object
|
||||
* @return the to object
|
||||
*/
|
||||
public abstract TO onAdapt(FROM from);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
public static KList<String> fromJSONAny(JSONArray oo) {
|
||||
KList<String> s = new KList<String>();
|
||||
|
||||
for (int i = 0; i < oo.length(); i++) {
|
||||
for(int i = 0; i < oo.length(); i++) {
|
||||
s.add(oo.get(i).toString());
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
public static KList<String> asStringList(List<?> oo) {
|
||||
KList<String> s = new KList<String>();
|
||||
|
||||
for (Object i : oo) {
|
||||
for(Object i : oo) {
|
||||
s.add(i.toString());
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public void addMultiple(T t, int c) {
|
||||
for (int i = 0; i < c; i++) {
|
||||
for(int i = 0; i < c; i++) {
|
||||
add(t);
|
||||
}
|
||||
}
|
||||
|
||||
private KList<T> add(Enumeration<T> e) {
|
||||
while (e.hasMoreElements()) {
|
||||
while(e.hasMoreElements()) {
|
||||
add(e.nextElement());
|
||||
}
|
||||
|
||||
@@ -119,8 +119,10 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* returned map. You must specify each key for each value in this list. In the
|
||||
* function, returning null will not add the keyval pair.
|
||||
*
|
||||
* @param <K> the inferred key type
|
||||
* @param f the function
|
||||
* @param <K>
|
||||
* the inferred key type
|
||||
* @param f
|
||||
* the function
|
||||
* @return the new map
|
||||
*/
|
||||
public <K> KMap<K, T> asValues(Function<T, K> f) {
|
||||
@@ -134,8 +136,10 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* returned map. You must specify each value for each key in this list. In the
|
||||
* function, returning null will not add the keyval pair.
|
||||
*
|
||||
* @param <V> the inferred value type
|
||||
* @param f the function
|
||||
* @param <V>
|
||||
* the inferred value type
|
||||
* @param f
|
||||
* the function
|
||||
* @return the new map
|
||||
*/
|
||||
public <V> KMap<T, V> asKeys(Function<T, V> f) {
|
||||
@@ -147,7 +151,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Cut this list into targetCount sublists
|
||||
*
|
||||
* @param targetCount the target count of sublists
|
||||
* @param targetCount
|
||||
* the target count of sublists
|
||||
* @return the list of sublists
|
||||
*/
|
||||
public KList<KList<T>> divide(int targetCount) {
|
||||
@@ -158,7 +163,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* Split this list into a list of sublists with roughly targetSize elements of T
|
||||
* per sublist
|
||||
*
|
||||
* @param targetSize the target size
|
||||
* @param targetSize
|
||||
* the target size
|
||||
* @return the list of sublists
|
||||
*/
|
||||
public KList<KList<T>> split(int targetSize) {
|
||||
@@ -166,8 +172,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
KList<KList<T>> gg = new KList<>();
|
||||
KList<T> b = new KList<>();
|
||||
|
||||
for (T i : this) {
|
||||
if (b.size() >= targetSize) {
|
||||
for(T i : this) {
|
||||
if(b.size() >= targetSize) {
|
||||
gg.add(b.copy());
|
||||
b.clear();
|
||||
}
|
||||
@@ -175,7 +181,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
b.add(i);
|
||||
}
|
||||
|
||||
if (!b.isEmpty()) {
|
||||
if(!b.isEmpty()) {
|
||||
gg.add(b);
|
||||
}
|
||||
|
||||
@@ -186,14 +192,15 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* Rewrite this list by checking each value and changing the value (or not).
|
||||
* Return null to remove the element in the function
|
||||
*
|
||||
* @param t the function
|
||||
* @param t
|
||||
* the function
|
||||
* @return the same list (not a copy)
|
||||
*/
|
||||
public KList<T> rewrite(Function<T, T> t) {
|
||||
KList<T> m = copy();
|
||||
clear();
|
||||
|
||||
for (T i : m) {
|
||||
for(T i : m) {
|
||||
addNonNull(t.apply(i));
|
||||
}
|
||||
|
||||
@@ -262,21 +269,22 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Tostring with a seperator for each item in the list
|
||||
*
|
||||
* @param split the seperator
|
||||
* @param split
|
||||
* the seperator
|
||||
* @return the string representing this object
|
||||
*/
|
||||
public String toString(String split) {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (size() == 1) {
|
||||
if(size() == 1) {
|
||||
return get(0) + "";
|
||||
}
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
|
||||
for (String i : toStringList()) {
|
||||
for(String i : toStringList()) {
|
||||
b.append(split).append(i == null ? "null" : i);
|
||||
}
|
||||
|
||||
@@ -295,9 +303,12 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Add the contents of the given list (v) into this list using a converter
|
||||
*
|
||||
* @param <V> the type of the forign list
|
||||
* @param v the forign (given) list
|
||||
* @param converter the converter that converts the forign type into this list type
|
||||
* @param <V>
|
||||
* the type of the forign list
|
||||
* @param v
|
||||
* the forign (given) list
|
||||
* @param converter
|
||||
* the converter that converts the forign type into this list type
|
||||
* @return this list (builder)
|
||||
*/
|
||||
public <V> KList<T> addFrom(List<V> v, Function<V, T> converter) {
|
||||
@@ -308,10 +319,6 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Convert this list into another list type. Such as GList<Integer> to
|
||||
* GList<String>. list.convert((i) -> "" + i);
|
||||
*
|
||||
* @param <V>
|
||||
* @param converter
|
||||
* @return
|
||||
*/
|
||||
public <V> KList<V> convert(Function<T, V> converter) {
|
||||
KList<V> v = new KList<V>();
|
||||
@@ -320,8 +327,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public KList<T> removeWhere(Predicate<T> t) {
|
||||
for (T i : copy()) {
|
||||
if (t.test(i)) {
|
||||
for(T i : copy()) {
|
||||
if(t.test(i)) {
|
||||
remove(i);
|
||||
}
|
||||
}
|
||||
@@ -332,11 +339,12 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Adds T to the list, ignores if null
|
||||
*
|
||||
* @param t the value to add
|
||||
* @param t
|
||||
* the value to add
|
||||
* @return the same list
|
||||
*/
|
||||
public KList<T> addNonNull(T t) {
|
||||
if (t != null) {
|
||||
if(t != null) {
|
||||
super.add(t);
|
||||
}
|
||||
|
||||
@@ -347,8 +355,10 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* Swaps the values of index a and b. For example "hello", "world", "!" swap(1,
|
||||
* 2) would change the list to "hello", "!", "world"
|
||||
*
|
||||
* @param a the first index
|
||||
* @param b the second index
|
||||
* @param a
|
||||
* the first index
|
||||
* @param b
|
||||
* the second index
|
||||
* @return the same list (builder), not a copy
|
||||
*/
|
||||
public KList<T> swapIndexes(int a, int b) {
|
||||
@@ -364,12 +374,13 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Remove a number of elements from the list
|
||||
*
|
||||
* @param t the elements
|
||||
* @param t
|
||||
* the elements
|
||||
* @return this list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> remove(T... t) {
|
||||
for (T i : t) {
|
||||
for(T i : t) {
|
||||
super.remove(i);
|
||||
}
|
||||
|
||||
@@ -379,7 +390,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Add another glist's contents to this one (addall builder)
|
||||
*
|
||||
* @param t the list
|
||||
* @param t
|
||||
* the list
|
||||
* @return the same list
|
||||
*/
|
||||
public KList<T> add(KList<T> t) {
|
||||
@@ -390,12 +402,13 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Add a number of values to this list
|
||||
*
|
||||
* @param t the list
|
||||
* @param t
|
||||
* the list
|
||||
* @return this list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> add(T... t) {
|
||||
for (T i : t) {
|
||||
for(T i : t) {
|
||||
super.add(i);
|
||||
}
|
||||
|
||||
@@ -405,7 +418,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
/**
|
||||
* Check if this list has an index at the given index
|
||||
*
|
||||
* @param index the given index
|
||||
* @param index
|
||||
* the given index
|
||||
* @return true if size > index
|
||||
*/
|
||||
public boolean hasIndex(int index) {
|
||||
@@ -465,7 +479,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* @return the popped off item or null if the list is empty
|
||||
*/
|
||||
public T pop() {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -478,7 +492,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
* @return the popped off item or null if the list is empty
|
||||
*/
|
||||
public T popLast() {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -486,11 +500,11 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public T popRandom() {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (size() == 1) {
|
||||
if(size() == 1) {
|
||||
return pop();
|
||||
}
|
||||
|
||||
@@ -498,11 +512,11 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public T popRandom(RNG rng) {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (size() == 1) {
|
||||
if(size() == 1) {
|
||||
return pop();
|
||||
}
|
||||
|
||||
@@ -512,7 +526,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
public KList<T> sub(int f, int t) {
|
||||
KList<T> g = new KList<>();
|
||||
|
||||
for (int i = f; i < M.min(size(), t); i++) {
|
||||
for(int i = f; i < M.min(size(), t); i++) {
|
||||
g.add(get(i));
|
||||
}
|
||||
|
||||
@@ -522,7 +536,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
public JSONArray toJSONStringArray() {
|
||||
JSONArray j = new JSONArray();
|
||||
|
||||
for (Object i : this) {
|
||||
for(Object i : this) {
|
||||
j.put(i.toString());
|
||||
}
|
||||
|
||||
@@ -531,7 +545,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(Object[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -540,7 +554,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(int[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -549,7 +563,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(double[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -558,7 +572,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(AtomicDoubleArray values) {
|
||||
for (int i = 0; i < values.length(); i++) {
|
||||
for(int i = 0; i < values.length(); i++) {
|
||||
add((T) ((Object) values.get(i)));
|
||||
}
|
||||
|
||||
@@ -567,7 +581,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(float[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -576,7 +590,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(byte[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -585,7 +599,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(short[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -594,7 +608,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(long[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -603,7 +617,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> forceAdd(boolean[] values) {
|
||||
for (Object i : values) {
|
||||
for(Object i : values) {
|
||||
add((T) i);
|
||||
}
|
||||
|
||||
@@ -619,11 +633,11 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public T getRandom() {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (size() == 1) {
|
||||
if(size() == 1) {
|
||||
return get(0);
|
||||
}
|
||||
|
||||
@@ -633,8 +647,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
public KList<T> popRandom(RNG rng, int c) {
|
||||
KList<T> m = new KList<>();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
if (isEmpty()) {
|
||||
for(int i = 0; i < c; i++) {
|
||||
if(isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -645,11 +659,11 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public T getRandom(RNG rng) {
|
||||
if (isEmpty()) {
|
||||
if(isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (size() == 1) {
|
||||
if(size() == 1) {
|
||||
return get(0);
|
||||
}
|
||||
|
||||
@@ -680,7 +694,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public boolean addIfMissing(T t) {
|
||||
if (!contains(t)) {
|
||||
if(!contains(t)) {
|
||||
add(t);
|
||||
return true;
|
||||
}
|
||||
@@ -689,8 +703,8 @@ public class KList<T> extends ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public void addAllIfMissing(KList<T> t) {
|
||||
for (T i : t) {
|
||||
if (!contains(i)) {
|
||||
for(T i : t) {
|
||||
if(!contains(i)) {
|
||||
add(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
}
|
||||
|
||||
public K getKey(V value) {
|
||||
for (KeyPair<K, V> i : keypair()) {
|
||||
if (i.getV().equals(value)) {
|
||||
for(KeyPair<K, V> i : keypair()) {
|
||||
if(i.getV().equals(value)) {
|
||||
return i.getK();
|
||||
}
|
||||
}
|
||||
@@ -56,9 +56,12 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
* Puts a value into a map-value-list based on the key such that if GMap<K,
|
||||
* GList<S>> where V is GList<S>
|
||||
*
|
||||
* @param <S> the list type in the value type
|
||||
* @param k the key to look for
|
||||
* @param vs the values to put into the list of the given key
|
||||
* @param <S>
|
||||
* the list type in the value type
|
||||
* @param k
|
||||
* the key to look for
|
||||
* @param vs
|
||||
* the values to put into the list of the given key
|
||||
* @return the same list (builder)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -66,12 +69,12 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
try {
|
||||
KMap<K, KList<S>> s = (KMap<K, KList<S>>) this;
|
||||
|
||||
if (!s.containsKey(k)) {
|
||||
if(!s.containsKey(k)) {
|
||||
s.put(k, new KList<S>());
|
||||
}
|
||||
|
||||
s.get(k).add(vs);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -96,9 +99,9 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
}
|
||||
});
|
||||
|
||||
for (V i : v) {
|
||||
for (K j : k()) {
|
||||
if (get(j).equals(i)) {
|
||||
for(V i : v) {
|
||||
for(K j : k()) {
|
||||
if(get(j).equals(i)) {
|
||||
k.add(j);
|
||||
}
|
||||
}
|
||||
@@ -128,9 +131,9 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
}
|
||||
});
|
||||
|
||||
for (V i : v) {
|
||||
for (K j : k()) {
|
||||
if (get(j).equals(i)) {
|
||||
for(V i : v) {
|
||||
for(K j : k()) {
|
||||
if(get(j).equals(i)) {
|
||||
k.add(j);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +146,8 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
/**
|
||||
* Put another map's values into this map
|
||||
*
|
||||
* @param m the map to insert
|
||||
* @param m
|
||||
* the map to insert
|
||||
* @return this map (builder)
|
||||
*/
|
||||
public KMap<K, V> put(Map<K, V> m) {
|
||||
@@ -163,13 +167,14 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
/**
|
||||
* Loop through each keyvalue set (copy of it) with the map parameter
|
||||
*
|
||||
* @param f the function
|
||||
* @param f
|
||||
* the function
|
||||
* @return the same gmap
|
||||
*/
|
||||
public KMap<K, V> rewrite(Consumer3<K, V, KMap<K, V>> f) {
|
||||
KMap<K, V> m = copy();
|
||||
|
||||
for (K i : m.k()) {
|
||||
for(K i : m.k()) {
|
||||
f.accept(i, get(i), this);
|
||||
}
|
||||
|
||||
@@ -179,11 +184,12 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
/**
|
||||
* Loop through each keyvalue set (copy of it)
|
||||
*
|
||||
* @param f the function
|
||||
* @param f
|
||||
* the function
|
||||
* @return the same gmap
|
||||
*/
|
||||
public KMap<K, V> each(Consumer2<K, V> f) {
|
||||
for (K i : k()) {
|
||||
for(K i : k()) {
|
||||
f.accept(i, get(i));
|
||||
}
|
||||
|
||||
@@ -199,7 +205,7 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
KMap<V, KList<K>> f = flip();
|
||||
KMap<V, K> m = new KMap<>();
|
||||
|
||||
for (V i : f.k()) {
|
||||
for(V i : f.k()) {
|
||||
m.putNonNull(i, m.isEmpty() ? null : m.get(0));
|
||||
}
|
||||
|
||||
@@ -214,12 +220,12 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
public KMap<V, KList<K>> flip() {
|
||||
KMap<V, KList<K>> flipped = new KMap<V, KList<K>>();
|
||||
|
||||
for (K i : keySet()) {
|
||||
if (i == null) {
|
||||
for(K i : keySet()) {
|
||||
if(i == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!flipped.containsKey(get(i))) {
|
||||
if(!flipped.containsKey(get(i))) {
|
||||
flipped.put(get(i), new KList<K>());
|
||||
}
|
||||
|
||||
@@ -245,9 +251,9 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
}
|
||||
});
|
||||
|
||||
for (K i : k) {
|
||||
for (V j : v()) {
|
||||
if (get(i).equals(j)) {
|
||||
for(K i : k) {
|
||||
for(V j : v()) {
|
||||
if(get(i).equals(j)) {
|
||||
v.add(j);
|
||||
}
|
||||
}
|
||||
@@ -268,9 +274,9 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
}
|
||||
});
|
||||
|
||||
for (K i : k) {
|
||||
for (V j : v()) {
|
||||
if (get(i).equals(j)) {
|
||||
for(K i : k) {
|
||||
for(V j : v()) {
|
||||
if(get(i).equals(j)) {
|
||||
v.add(j);
|
||||
}
|
||||
}
|
||||
@@ -288,7 +294,7 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
KList<K> k = new KList<K>();
|
||||
Enumeration<K> kk = keys();
|
||||
|
||||
while (kk.hasMoreElements()) {
|
||||
while(kk.hasMoreElements()) {
|
||||
K kkk = kk.nextElement();
|
||||
k.add(kkk);
|
||||
}
|
||||
@@ -308,9 +314,10 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
/**
|
||||
* Still works as it normally should except it returns itself (builder)
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value (single only supported)
|
||||
* @return
|
||||
* @param key
|
||||
* the key
|
||||
* @param value
|
||||
* the value (single only supported)
|
||||
*/
|
||||
public KMap<K, V> qput(K key, V value) {
|
||||
super.put(key, value);
|
||||
@@ -321,12 +328,14 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
* Works just like put, except it wont put anything unless the key and value are
|
||||
* nonnull
|
||||
*
|
||||
* @param key the nonnull key
|
||||
* @param value the nonnull value
|
||||
* @param key
|
||||
* the nonnull key
|
||||
* @param value
|
||||
* the nonnull value
|
||||
* @return the same map
|
||||
*/
|
||||
public KMap<K, V> putNonNull(K key, V value) {
|
||||
if (key != null || value != null) {
|
||||
if(key != null || value != null) {
|
||||
put(key, value);
|
||||
}
|
||||
|
||||
@@ -334,7 +343,7 @@ public class KMap<K, V> extends ConcurrentHashMap<K, V> {
|
||||
}
|
||||
|
||||
public V putThen(K key, V valueIfKeyNotPresent) {
|
||||
if (!containsKey(key)) {
|
||||
if(!containsKey(key)) {
|
||||
put(key, valueIfKeyNotPresent);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,10 @@ package com.volmit.iris.util.collection;
|
||||
/**
|
||||
* Represents a keypair
|
||||
*
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
* @param <K>
|
||||
* the key type
|
||||
* @param <V>
|
||||
* the value type
|
||||
* @author cyberpwn
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
@@ -33,8 +35,10 @@ public class KeyPair<K, V> {
|
||||
/**
|
||||
* Create a keypair
|
||||
*
|
||||
* @param k the key
|
||||
* @param v the value
|
||||
* @param k
|
||||
* the key
|
||||
* @param v
|
||||
* the value
|
||||
*/
|
||||
public KeyPair(K k, V v) {
|
||||
this.k = k;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class StateList {
|
||||
public StateList(String... states) {
|
||||
this.states = new KList<String>(states);
|
||||
|
||||
if (getBits() > 64) {
|
||||
if(getBits() > 64) {
|
||||
throw new RuntimeException("StateLists cannot exceed 64 bits! You are trying to use " + getBits() + " bits!");
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class StateList {
|
||||
public StateList(Enum<?>... states) {
|
||||
this.states = new KList<Enum<?>>().convert(Enum::name);
|
||||
|
||||
if (getBits() > 64) {
|
||||
if(getBits() > 64) {
|
||||
throw new RuntimeException("StateLists cannot exceed 64 bits! You are trying to use " + getBits() + " bits!");
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,8 @@ public class StateList {
|
||||
public KList<String> getEnabled(long list) {
|
||||
KList<String> f = new KList<>();
|
||||
|
||||
for (String i : states) {
|
||||
if (is(list, i)) {
|
||||
for(String i : states) {
|
||||
if(is(list, i)) {
|
||||
f.add(i);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class StateList {
|
||||
public long of(String... enabledStates) {
|
||||
long b = 0;
|
||||
|
||||
for (String i : enabledStates) {
|
||||
for(String i : enabledStates) {
|
||||
b |= getBit(i);
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ public class StateList {
|
||||
long bit = getBit(state);
|
||||
boolean is = is(list, state);
|
||||
|
||||
if (enabled && !is) {
|
||||
if(enabled && !is) {
|
||||
return list | bit;
|
||||
} else if (!enabled && is) {
|
||||
} else if(!enabled && is) {
|
||||
return list ^ bit;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,20 +39,20 @@ public class IrisContext {
|
||||
}
|
||||
|
||||
public static void touch(IrisContext c) {
|
||||
synchronized (context) {
|
||||
synchronized(context) {
|
||||
context.put(Thread.currentThread(), c);
|
||||
|
||||
if (cl.flip()) {
|
||||
if(cl.flip()) {
|
||||
dereference();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void dereference() {
|
||||
synchronized (context) {
|
||||
for (Thread i : context.k()) {
|
||||
if (!i.isAlive() || context.get(i).engine.isClosed()) {
|
||||
if (context.get(i).engine.isClosed()) {
|
||||
synchronized(context) {
|
||||
for(Thread i : context.k()) {
|
||||
if(!i.isAlive() || context.get(i).engine.isClosed()) {
|
||||
if(context.get(i).engine.isClosed()) {
|
||||
Iris.debug("Dereferenced Context<Engine> " + i.getName() + " " + i.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.bukkit.block.data.type.PointedDripstone;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -59,34 +58,34 @@ public class B {
|
||||
|
||||
private static IntSet buildFoliageCache() {
|
||||
IntSet b = new IntOpenHashSet();
|
||||
Arrays.stream(new Material[]{
|
||||
POPPY,
|
||||
DANDELION,
|
||||
CORNFLOWER,
|
||||
SWEET_BERRY_BUSH,
|
||||
CRIMSON_ROOTS,
|
||||
WARPED_ROOTS,
|
||||
NETHER_SPROUTS,
|
||||
ALLIUM,
|
||||
AZURE_BLUET,
|
||||
BLUE_ORCHID,
|
||||
OXEYE_DAISY,
|
||||
LILY_OF_THE_VALLEY,
|
||||
WITHER_ROSE,
|
||||
DARK_OAK_SAPLING,
|
||||
ACACIA_SAPLING,
|
||||
JUNGLE_SAPLING,
|
||||
BIRCH_SAPLING,
|
||||
SPRUCE_SAPLING,
|
||||
OAK_SAPLING,
|
||||
ORANGE_TULIP,
|
||||
PINK_TULIP,
|
||||
RED_TULIP,
|
||||
WHITE_TULIP,
|
||||
FERN,
|
||||
LARGE_FERN,
|
||||
GRASS,
|
||||
TALL_GRASS
|
||||
Arrays.stream(new Material[] {
|
||||
POPPY,
|
||||
DANDELION,
|
||||
CORNFLOWER,
|
||||
SWEET_BERRY_BUSH,
|
||||
CRIMSON_ROOTS,
|
||||
WARPED_ROOTS,
|
||||
NETHER_SPROUTS,
|
||||
ALLIUM,
|
||||
AZURE_BLUET,
|
||||
BLUE_ORCHID,
|
||||
OXEYE_DAISY,
|
||||
LILY_OF_THE_VALLEY,
|
||||
WITHER_ROSE,
|
||||
DARK_OAK_SAPLING,
|
||||
ACACIA_SAPLING,
|
||||
JUNGLE_SAPLING,
|
||||
BIRCH_SAPLING,
|
||||
SPRUCE_SAPLING,
|
||||
OAK_SAPLING,
|
||||
ORANGE_TULIP,
|
||||
PINK_TULIP,
|
||||
RED_TULIP,
|
||||
WHITE_TULIP,
|
||||
FERN,
|
||||
LARGE_FERN,
|
||||
GRASS,
|
||||
TALL_GRASS
|
||||
}).forEach((i) -> b.add(i.ordinal()));
|
||||
|
||||
return IntSets.unmodifiable(b);
|
||||
@@ -94,17 +93,17 @@ public class B {
|
||||
|
||||
private static IntSet buildDeepslateCache() {
|
||||
IntSet b = new IntOpenHashSet();
|
||||
Arrays.stream(new Material[]{
|
||||
DEEPSLATE,
|
||||
DEEPSLATE_BRICKS,
|
||||
DEEPSLATE_BRICK_SLAB,
|
||||
DEEPSLATE_BRICK_STAIRS,
|
||||
DEEPSLATE_BRICK_WALL,
|
||||
DEEPSLATE_TILE_SLAB,
|
||||
DEEPSLATE_TILES,
|
||||
DEEPSLATE_TILE_STAIRS,
|
||||
DEEPSLATE_TILE_WALL,
|
||||
CRACKED_DEEPSLATE_TILES
|
||||
Arrays.stream(new Material[] {
|
||||
DEEPSLATE,
|
||||
DEEPSLATE_BRICKS,
|
||||
DEEPSLATE_BRICK_SLAB,
|
||||
DEEPSLATE_BRICK_STAIRS,
|
||||
DEEPSLATE_BRICK_WALL,
|
||||
DEEPSLATE_TILE_SLAB,
|
||||
DEEPSLATE_TILES,
|
||||
DEEPSLATE_TILE_STAIRS,
|
||||
DEEPSLATE_TILE_WALL,
|
||||
CRACKED_DEEPSLATE_TILES
|
||||
}).forEach((i) -> b.add(i.ordinal()));
|
||||
|
||||
return IntSets.unmodifiable(b);
|
||||
@@ -142,61 +141,61 @@ public class B {
|
||||
|
||||
private static IntSet buildDecorantCache() {
|
||||
IntSet b = new IntOpenHashSet();
|
||||
Arrays.stream(new Material[]{
|
||||
GRASS,
|
||||
TALL_GRASS,
|
||||
FERN,
|
||||
LARGE_FERN,
|
||||
CORNFLOWER,
|
||||
SUNFLOWER,
|
||||
CHORUS_FLOWER,
|
||||
POPPY,
|
||||
DANDELION,
|
||||
OXEYE_DAISY,
|
||||
ORANGE_TULIP,
|
||||
PINK_TULIP,
|
||||
RED_TULIP,
|
||||
WHITE_TULIP,
|
||||
LILAC,
|
||||
DEAD_BUSH,
|
||||
SWEET_BERRY_BUSH,
|
||||
ROSE_BUSH,
|
||||
WITHER_ROSE,
|
||||
ALLIUM,
|
||||
BLUE_ORCHID,
|
||||
LILY_OF_THE_VALLEY,
|
||||
CRIMSON_FUNGUS,
|
||||
WARPED_FUNGUS,
|
||||
RED_MUSHROOM,
|
||||
BROWN_MUSHROOM,
|
||||
CRIMSON_ROOTS,
|
||||
AZURE_BLUET,
|
||||
WEEPING_VINES,
|
||||
WEEPING_VINES_PLANT,
|
||||
WARPED_ROOTS,
|
||||
NETHER_SPROUTS,
|
||||
TWISTING_VINES,
|
||||
TWISTING_VINES_PLANT,
|
||||
SUGAR_CANE,
|
||||
WHEAT,
|
||||
POTATOES,
|
||||
CARROTS,
|
||||
BEETROOTS,
|
||||
NETHER_WART,
|
||||
SEA_PICKLE,
|
||||
SEAGRASS,
|
||||
ACACIA_BUTTON,
|
||||
BIRCH_BUTTON,
|
||||
CRIMSON_BUTTON,
|
||||
DARK_OAK_BUTTON,
|
||||
JUNGLE_BUTTON,
|
||||
OAK_BUTTON,
|
||||
POLISHED_BLACKSTONE_BUTTON,
|
||||
SPRUCE_BUTTON,
|
||||
STONE_BUTTON,
|
||||
WARPED_BUTTON,
|
||||
TORCH,
|
||||
SOUL_TORCH
|
||||
Arrays.stream(new Material[] {
|
||||
GRASS,
|
||||
TALL_GRASS,
|
||||
FERN,
|
||||
LARGE_FERN,
|
||||
CORNFLOWER,
|
||||
SUNFLOWER,
|
||||
CHORUS_FLOWER,
|
||||
POPPY,
|
||||
DANDELION,
|
||||
OXEYE_DAISY,
|
||||
ORANGE_TULIP,
|
||||
PINK_TULIP,
|
||||
RED_TULIP,
|
||||
WHITE_TULIP,
|
||||
LILAC,
|
||||
DEAD_BUSH,
|
||||
SWEET_BERRY_BUSH,
|
||||
ROSE_BUSH,
|
||||
WITHER_ROSE,
|
||||
ALLIUM,
|
||||
BLUE_ORCHID,
|
||||
LILY_OF_THE_VALLEY,
|
||||
CRIMSON_FUNGUS,
|
||||
WARPED_FUNGUS,
|
||||
RED_MUSHROOM,
|
||||
BROWN_MUSHROOM,
|
||||
CRIMSON_ROOTS,
|
||||
AZURE_BLUET,
|
||||
WEEPING_VINES,
|
||||
WEEPING_VINES_PLANT,
|
||||
WARPED_ROOTS,
|
||||
NETHER_SPROUTS,
|
||||
TWISTING_VINES,
|
||||
TWISTING_VINES_PLANT,
|
||||
SUGAR_CANE,
|
||||
WHEAT,
|
||||
POTATOES,
|
||||
CARROTS,
|
||||
BEETROOTS,
|
||||
NETHER_WART,
|
||||
SEA_PICKLE,
|
||||
SEAGRASS,
|
||||
ACACIA_BUTTON,
|
||||
BIRCH_BUTTON,
|
||||
CRIMSON_BUTTON,
|
||||
DARK_OAK_BUTTON,
|
||||
JUNGLE_BUTTON,
|
||||
OAK_BUTTON,
|
||||
POLISHED_BLACKSTONE_BUTTON,
|
||||
SPRUCE_BUTTON,
|
||||
STONE_BUTTON,
|
||||
WARPED_BUTTON,
|
||||
TORCH,
|
||||
SOUL_TORCH
|
||||
}).forEach((i) -> b.add(i.ordinal()));
|
||||
b.addAll(foliageCache);
|
||||
|
||||
@@ -205,34 +204,34 @@ public class B {
|
||||
|
||||
private static IntSet buildLitCache() {
|
||||
IntSet b = new IntOpenHashSet();
|
||||
Arrays.stream(new Material[]{
|
||||
GLOWSTONE,
|
||||
AMETHYST_CLUSTER,
|
||||
SMALL_AMETHYST_BUD,
|
||||
MEDIUM_AMETHYST_BUD,
|
||||
LARGE_AMETHYST_BUD,
|
||||
END_ROD,
|
||||
SOUL_SAND,
|
||||
TORCH,
|
||||
REDSTONE_TORCH,
|
||||
SOUL_TORCH,
|
||||
REDSTONE_WALL_TORCH,
|
||||
WALL_TORCH,
|
||||
SOUL_WALL_TORCH,
|
||||
LANTERN,
|
||||
CANDLE,
|
||||
JACK_O_LANTERN,
|
||||
REDSTONE_LAMP,
|
||||
MAGMA_BLOCK,
|
||||
LIGHT,
|
||||
SHROOMLIGHT,
|
||||
SEA_LANTERN,
|
||||
SOUL_LANTERN,
|
||||
FIRE,
|
||||
SOUL_FIRE,
|
||||
SEA_PICKLE,
|
||||
BREWING_STAND,
|
||||
REDSTONE_ORE,
|
||||
Arrays.stream(new Material[] {
|
||||
GLOWSTONE,
|
||||
AMETHYST_CLUSTER,
|
||||
SMALL_AMETHYST_BUD,
|
||||
MEDIUM_AMETHYST_BUD,
|
||||
LARGE_AMETHYST_BUD,
|
||||
END_ROD,
|
||||
SOUL_SAND,
|
||||
TORCH,
|
||||
REDSTONE_TORCH,
|
||||
SOUL_TORCH,
|
||||
REDSTONE_WALL_TORCH,
|
||||
WALL_TORCH,
|
||||
SOUL_WALL_TORCH,
|
||||
LANTERN,
|
||||
CANDLE,
|
||||
JACK_O_LANTERN,
|
||||
REDSTONE_LAMP,
|
||||
MAGMA_BLOCK,
|
||||
LIGHT,
|
||||
SHROOMLIGHT,
|
||||
SEA_LANTERN,
|
||||
SOUL_LANTERN,
|
||||
FIRE,
|
||||
SOUL_FIRE,
|
||||
SEA_PICKLE,
|
||||
BREWING_STAND,
|
||||
REDSTONE_ORE,
|
||||
}).forEach((i) -> b.add(i.ordinal()));
|
||||
|
||||
return IntSets.unmodifiable(b);
|
||||
@@ -240,33 +239,33 @@ public class B {
|
||||
|
||||
private static IntSet buildStorageCache() {
|
||||
IntSet b = new IntOpenHashSet();
|
||||
Arrays.stream(new Material[]{
|
||||
CHEST,
|
||||
SMOKER,
|
||||
TRAPPED_CHEST,
|
||||
SHULKER_BOX,
|
||||
WHITE_SHULKER_BOX,
|
||||
ORANGE_SHULKER_BOX,
|
||||
MAGENTA_SHULKER_BOX,
|
||||
LIGHT_BLUE_SHULKER_BOX,
|
||||
YELLOW_SHULKER_BOX,
|
||||
LIME_SHULKER_BOX,
|
||||
PINK_SHULKER_BOX,
|
||||
GRAY_SHULKER_BOX,
|
||||
LIGHT_GRAY_SHULKER_BOX,
|
||||
CYAN_SHULKER_BOX,
|
||||
PURPLE_SHULKER_BOX,
|
||||
BLUE_SHULKER_BOX,
|
||||
BROWN_SHULKER_BOX,
|
||||
GREEN_SHULKER_BOX,
|
||||
RED_SHULKER_BOX,
|
||||
BLACK_SHULKER_BOX,
|
||||
BARREL,
|
||||
DISPENSER,
|
||||
DROPPER,
|
||||
HOPPER,
|
||||
FURNACE,
|
||||
BLAST_FURNACE
|
||||
Arrays.stream(new Material[] {
|
||||
CHEST,
|
||||
SMOKER,
|
||||
TRAPPED_CHEST,
|
||||
SHULKER_BOX,
|
||||
WHITE_SHULKER_BOX,
|
||||
ORANGE_SHULKER_BOX,
|
||||
MAGENTA_SHULKER_BOX,
|
||||
LIGHT_BLUE_SHULKER_BOX,
|
||||
YELLOW_SHULKER_BOX,
|
||||
LIME_SHULKER_BOX,
|
||||
PINK_SHULKER_BOX,
|
||||
GRAY_SHULKER_BOX,
|
||||
LIGHT_GRAY_SHULKER_BOX,
|
||||
CYAN_SHULKER_BOX,
|
||||
PURPLE_SHULKER_BOX,
|
||||
BLUE_SHULKER_BOX,
|
||||
BROWN_SHULKER_BOX,
|
||||
GREEN_SHULKER_BOX,
|
||||
RED_SHULKER_BOX,
|
||||
BLACK_SHULKER_BOX,
|
||||
BARREL,
|
||||
DISPENSER,
|
||||
DROPPER,
|
||||
HOPPER,
|
||||
FURNACE,
|
||||
BLAST_FURNACE
|
||||
}).forEach((i) -> b.add(i.ordinal()));
|
||||
|
||||
return IntSets.unmodifiable(b);
|
||||
@@ -275,12 +274,12 @@ public class B {
|
||||
public static BlockData toDeepSlateOre(BlockData block, BlockData ore) {
|
||||
int key = ore.getMaterial().ordinal();
|
||||
|
||||
if (isDeepSlate(block)) {
|
||||
if (normal2DeepslateCache.containsKey(key)) {
|
||||
if(isDeepSlate(block)) {
|
||||
if(normal2DeepslateCache.containsKey(key)) {
|
||||
return Material.values()[normal2DeepslateCache.get(key)].createBlockData();
|
||||
}
|
||||
} else {
|
||||
if (deepslate2NormalCache.containsKey(key)) {
|
||||
if(deepslate2NormalCache.containsKey(key)) {
|
||||
return Material.values()[deepslate2NormalCache.get(key)].createBlockData();
|
||||
}
|
||||
}
|
||||
@@ -306,39 +305,39 @@ public class B {
|
||||
}
|
||||
|
||||
public static boolean canPlaceOnto(Material mat, Material onto) {
|
||||
if ((onto.equals(CRIMSON_NYLIUM) || onto.equals(WARPED_NYLIUM)) &&
|
||||
(mat.equals(CRIMSON_FUNGUS) || mat.equals(CRIMSON_ROOTS) ||mat.equals(WARPED_FUNGUS) || mat.equals(WARPED_ROOTS) ) ){
|
||||
if((onto.equals(CRIMSON_NYLIUM) || onto.equals(WARPED_NYLIUM)) &&
|
||||
(mat.equals(CRIMSON_FUNGUS) || mat.equals(CRIMSON_ROOTS) || mat.equals(WARPED_FUNGUS) || mat.equals(WARPED_ROOTS))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isFoliage(mat)) {
|
||||
if (!isFoliagePlantable(onto)) {
|
||||
if(isFoliage(mat)) {
|
||||
if(!isFoliagePlantable(onto)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (onto.equals(Material.AIR) ||
|
||||
onto.equals(B.getMaterial("CAVE_AIR"))
|
||||
|| onto.equals(B.getMaterial("VOID_AIR"))) {
|
||||
if(onto.equals(Material.AIR) ||
|
||||
onto.equals(B.getMaterial("CAVE_AIR"))
|
||||
|| onto.equals(B.getMaterial("VOID_AIR"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH)) {
|
||||
if(onto.equals(Material.GRASS_BLOCK) && mat.equals(Material.DEAD_BUSH)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (onto.equals(Material.DIRT_PATH)) {
|
||||
if (!mat.isSolid()) {
|
||||
if(onto.equals(Material.DIRT_PATH)) {
|
||||
if(!mat.isSolid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (onto.equals(Material.ACACIA_LEAVES)
|
||||
|| onto.equals(Material.BIRCH_LEAVES)
|
||||
|| onto.equals(Material.DARK_OAK_LEAVES)
|
||||
|| onto.equals(Material.JUNGLE_LEAVES)
|
||||
|| onto.equals(Material.OAK_LEAVES)
|
||||
|| onto.equals(Material.SPRUCE_LEAVES)) {
|
||||
if(onto.equals(Material.ACACIA_LEAVES)
|
||||
|| onto.equals(Material.BIRCH_LEAVES)
|
||||
|| onto.equals(Material.DARK_OAK_LEAVES)
|
||||
|| onto.equals(Material.JUNGLE_LEAVES)
|
||||
|| onto.equals(Material.OAK_LEAVES)
|
||||
|| onto.equals(Material.SPRUCE_LEAVES)) {
|
||||
return mat.isSolid();
|
||||
}
|
||||
|
||||
@@ -347,25 +346,25 @@ public class B {
|
||||
|
||||
public static boolean isFoliagePlantable(BlockData d) {
|
||||
return d.getMaterial().equals(Material.GRASS_BLOCK)
|
||||
|| d.getMaterial().equals(Material.ROOTED_DIRT)
|
||||
|| d.getMaterial().equals(Material.DIRT)
|
||||
|| d.getMaterial().equals(Material.COARSE_DIRT)
|
||||
|| d.getMaterial().equals(Material.PODZOL);
|
||||
|| d.getMaterial().equals(Material.ROOTED_DIRT)
|
||||
|| d.getMaterial().equals(Material.DIRT)
|
||||
|| d.getMaterial().equals(Material.COARSE_DIRT)
|
||||
|| d.getMaterial().equals(Material.PODZOL);
|
||||
}
|
||||
|
||||
public static boolean isFoliagePlantable(Material d) {
|
||||
return d.equals(Material.GRASS_BLOCK)
|
||||
|| d.equals(Material.DIRT)
|
||||
|| d.equals(TALL_GRASS)
|
||||
|| d.equals(TALL_SEAGRASS)
|
||||
|| d.equals(LARGE_FERN)
|
||||
|| d.equals(SUNFLOWER)
|
||||
|| d.equals(PEONY)
|
||||
|| d.equals(LILAC)
|
||||
|| d.equals(ROSE_BUSH)
|
||||
|| d.equals(Material.ROOTED_DIRT)
|
||||
|| d.equals(Material.COARSE_DIRT)
|
||||
|| d.equals(Material.PODZOL);
|
||||
|| d.equals(Material.DIRT)
|
||||
|| d.equals(TALL_GRASS)
|
||||
|| d.equals(TALL_SEAGRASS)
|
||||
|| d.equals(LARGE_FERN)
|
||||
|| d.equals(SUNFLOWER)
|
||||
|| d.equals(PEONY)
|
||||
|| d.equals(LILAC)
|
||||
|| d.equals(ROSE_BUSH)
|
||||
|| d.equals(Material.ROOTED_DIRT)
|
||||
|| d.equals(Material.COARSE_DIRT)
|
||||
|| d.equals(Material.PODZOL);
|
||||
}
|
||||
|
||||
public static boolean isWater(BlockData b) {
|
||||
@@ -379,9 +378,9 @@ public class B {
|
||||
public static Material getMaterialOrNull(String bdx) {
|
||||
try {
|
||||
return Material.valueOf(bdx.trim().toUpperCase());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
if (clw.flip()) {
|
||||
if(clw.flip()) {
|
||||
Iris.warn("Unknown Material: " + bdx);
|
||||
}
|
||||
return null;
|
||||
@@ -391,7 +390,7 @@ public class B {
|
||||
public static Material getMaterial(String bdx) {
|
||||
Material m = getMaterialOrNull(bdx);
|
||||
|
||||
if (m == null) {
|
||||
if(m == null) {
|
||||
return AIR_MATERIAL;
|
||||
}
|
||||
|
||||
@@ -406,28 +405,28 @@ public class B {
|
||||
try {
|
||||
String bd = bdxf.trim();
|
||||
|
||||
if (bd.startsWith("minecraft:cauldron[level=")) {
|
||||
if(bd.startsWith("minecraft:cauldron[level=")) {
|
||||
bd = bd.replaceAll("\\Q:cauldron[\\E", ":water_cauldron[");
|
||||
}
|
||||
|
||||
if (bd.equals("minecraft:grass_path")) {
|
||||
if(bd.equals("minecraft:grass_path")) {
|
||||
return DIRT_PATH.createBlockData();
|
||||
}
|
||||
|
||||
BlockData bdx = parseBlockData(bd);
|
||||
|
||||
if (bdx == null) {
|
||||
if (clw.flip()) {
|
||||
if(bdx == null) {
|
||||
if(clw.flip()) {
|
||||
Iris.warn("Unknown Block Data '" + bd + "'");
|
||||
}
|
||||
return AIR;
|
||||
}
|
||||
|
||||
return bdx;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
if (clw.flip()) {
|
||||
if(clw.flip()) {
|
||||
Iris.warn("Unknown Block Data '" + bdxf + "'");
|
||||
}
|
||||
}
|
||||
@@ -438,7 +437,7 @@ public class B {
|
||||
public static BlockData get(String bdxf) {
|
||||
BlockData bd = getOrNull(bdxf);
|
||||
|
||||
if (bd != null) {
|
||||
if(bd != null) {
|
||||
return bd;
|
||||
}
|
||||
|
||||
@@ -453,84 +452,84 @@ public class B {
|
||||
try {
|
||||
BlockData bx = null;
|
||||
|
||||
if (!ix.startsWith("minecraft:")) {
|
||||
if (ix.startsWith("oraxen:") && Iris.linkOraxen.supported()) {
|
||||
if(!ix.startsWith("minecraft:")) {
|
||||
if(ix.startsWith("oraxen:") && Iris.linkOraxen.supported()) {
|
||||
bx = Iris.linkOraxen.getBlockDataFor(ix.split("\\Q:\\E")[1]);
|
||||
}
|
||||
|
||||
if (bx == null) {
|
||||
if(bx == null) {
|
||||
try {
|
||||
if (ix.contains(":")) {
|
||||
if(ix.contains(":")) {
|
||||
String[] v = ix.toLowerCase().split("\\Q:\\E");
|
||||
Supplier<BlockData> b = Iris.service(RegistrySVC.class).getCustomBlockRegistry().resolve(v[0], v[1]);
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
bx = b.get();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();// TODO: REMOVE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bx == null) {
|
||||
if(bx == null) {
|
||||
try {
|
||||
bx = createBlockData(ix.toLowerCase());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (bx == null) {
|
||||
if(bx == null) {
|
||||
try {
|
||||
bx = createBlockData("minecraft:" + ix.toLowerCase());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (bx == null) {
|
||||
if(bx == null) {
|
||||
try {
|
||||
bx = Material.valueOf(ix.toUpperCase()).createBlockData();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (bx == null) {
|
||||
if(bx == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (bx instanceof Leaves && IrisSettings.get().getGenerator().isPreventLeafDecay()) {
|
||||
if(bx instanceof Leaves && IrisSettings.get().getGenerator().isPreventLeafDecay()) {
|
||||
((Leaves) bx).setPersistent(true);
|
||||
} else if (bx instanceof Leaves) {
|
||||
} else if(bx instanceof Leaves) {
|
||||
((Leaves) bx).setPersistent(false);
|
||||
}
|
||||
|
||||
return bx;
|
||||
} catch (Throwable e) {
|
||||
if (clw.flip()) {
|
||||
} catch(Throwable e) {
|
||||
if(clw.flip()) {
|
||||
Iris.warn("Unknown Block Data: " + ix);
|
||||
}
|
||||
|
||||
String block = ix.contains(":") ? ix.split(":")[1].toLowerCase() : ix.toLowerCase();
|
||||
String state = block.contains("[") ? block.split("\\Q[\\E")[1].split("\\Q]\\E")[0] : "";
|
||||
Map<String, String> stateMap = new HashMap<>();
|
||||
if (!state.equals("")) {
|
||||
if(!state.equals("")) {
|
||||
Arrays.stream(state.split(",")).forEach(s -> stateMap.put(s.split("=")[0], s.split("=")[1]));
|
||||
}
|
||||
block = block.split("\\Q[\\E")[0];
|
||||
|
||||
switch (block) {
|
||||
switch(block) {
|
||||
case "cauldron" -> block = "water_cauldron";
|
||||
case "grass_path" -> block = "dirt_path";
|
||||
case "concrete" -> block = "white_concrete";
|
||||
case "wool" -> block = "white_wool";
|
||||
case "beetroots" -> {
|
||||
if (stateMap.containsKey("age")) {
|
||||
if(stateMap.containsKey("age")) {
|
||||
String updated = stateMap.get("age");
|
||||
switch (updated) {
|
||||
switch(updated) {
|
||||
case "7" -> updated = "3";
|
||||
case "3", "4", "5" -> updated = "2";
|
||||
case "1", "2" -> updated = "1";
|
||||
@@ -541,25 +540,25 @@ public class B {
|
||||
}
|
||||
|
||||
Map<String, String> newStates = new HashMap<>();
|
||||
for (String key : stateMap.keySet()) { //Iterate through every state and check if its valid
|
||||
for(String key : stateMap.keySet()) { //Iterate through every state and check if its valid
|
||||
try {
|
||||
String newState = block + "[" + key + "=" + stateMap.get(key) + "]";
|
||||
createBlockData(newState);
|
||||
newStates.put(key, stateMap.get(key));
|
||||
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
} catch(IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
//Combine all the "good" states again
|
||||
state = newStates.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(","));
|
||||
if (!state.equals("")) state = "[" + state + "]";
|
||||
if(!state.equals("")) state = "[" + state + "]";
|
||||
String newBlock = block + state;
|
||||
Iris.debug("Converting " + ix + " to " + newBlock);
|
||||
|
||||
try {
|
||||
return createBlockData(newBlock);
|
||||
} catch (Throwable e1) {
|
||||
} catch(Throwable e1) {
|
||||
Iris.reportError(e1);
|
||||
}
|
||||
|
||||
@@ -581,9 +580,9 @@ public class B {
|
||||
|
||||
public static boolean isUpdatable(BlockData mat) {
|
||||
return isLit(mat)
|
||||
|| isStorage(mat)
|
||||
|| (mat instanceof PointedDripstone
|
||||
&& ((PointedDripstone) mat).getThickness().equals(PointedDripstone.Thickness.TIP));
|
||||
|| isStorage(mat)
|
||||
|| (mat instanceof PointedDripstone
|
||||
&& ((PointedDripstone) mat).getThickness().equals(PointedDripstone.Thickness.TIP));
|
||||
}
|
||||
|
||||
public static boolean isFoliage(Material d) {
|
||||
@@ -601,10 +600,10 @@ public class B {
|
||||
public static KList<BlockData> get(KList<String> find) {
|
||||
KList<BlockData> b = new KList<>();
|
||||
|
||||
for (String i : find) {
|
||||
for(String i : find) {
|
||||
BlockData bd = get(i);
|
||||
|
||||
if (bd != null) {
|
||||
if(bd != null) {
|
||||
b.add(bd);
|
||||
}
|
||||
}
|
||||
@@ -621,7 +620,7 @@ public class B {
|
||||
}
|
||||
|
||||
public static boolean isAir(BlockData d) {
|
||||
if (d == null) {
|
||||
if(d == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -632,11 +631,11 @@ public class B {
|
||||
public synchronized static String[] getBlockTypes() {
|
||||
KList<String> bt = new KList<>();
|
||||
|
||||
for (Material i : Material.values()) {
|
||||
if (i.isBlock()) {
|
||||
for(Material i : Material.values()) {
|
||||
if(i.isBlock()) {
|
||||
String v = i.createBlockData().getAsString(true);
|
||||
|
||||
if (v.contains("[")) {
|
||||
if(v.contains("[")) {
|
||||
v = v.split("\\Q[\\E")[0];
|
||||
}
|
||||
|
||||
@@ -645,16 +644,16 @@ public class B {
|
||||
}
|
||||
|
||||
try {
|
||||
for (String i : Iris.linkOraxen.getItemTypes()) {
|
||||
for(String i : Iris.linkOraxen.getItemTypes()) {
|
||||
bt.add("oraxen:" + i);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
bt.addAll(Iris.service(RegistrySVC.class).getCustomBlockRegistry().compile());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -664,7 +663,7 @@ public class B {
|
||||
public static String[] getItemTypes() {
|
||||
KList<String> bt = new KList<>();
|
||||
|
||||
for (Material i : Material.values()) {
|
||||
for(Material i : Material.values()) {
|
||||
String v = i.name().toLowerCase().trim();
|
||||
bt.add(v);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ChunkCache<T> {
|
||||
public T compute(int x, int z, Function2<Integer, Integer, T> function) {
|
||||
T t = get(x & 15, z & 15);
|
||||
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
t = function.apply(x, z);
|
||||
set(x & 15, z & 15, t);
|
||||
}
|
||||
|
||||
@@ -49,11 +49,13 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* Construct a Cuboid given two Location objects which represent any two corners
|
||||
* of the Cuboid.
|
||||
*
|
||||
* @param l1 one of the corners
|
||||
* @param l2 the other corner
|
||||
* @param l1
|
||||
* one of the corners
|
||||
* @param l2
|
||||
* the other corner
|
||||
*/
|
||||
public Cuboid(Location l1, Location l2) {
|
||||
if (!l1.getWorld().equals(l2.getWorld())) {
|
||||
if(!l1.getWorld().equals(l2.getWorld())) {
|
||||
throw new IllegalArgumentException("locations must be on the same world");
|
||||
}
|
||||
|
||||
@@ -69,7 +71,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Construct a one-block Cuboid at the given Location of the Cuboid.
|
||||
*
|
||||
* @param l1 location of the Cuboid
|
||||
* @param l1
|
||||
* location of the Cuboid
|
||||
*/
|
||||
public Cuboid(Location l1) {
|
||||
this(l1, l1);
|
||||
@@ -78,7 +81,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param other the Cuboid to copy
|
||||
* @param other
|
||||
* the Cuboid to copy
|
||||
*/
|
||||
public Cuboid(Cuboid other) {
|
||||
this(other.getWorld().getName(), other.x1, other.y1, other.z1, other.x2, other.y2, other.z2);
|
||||
@@ -87,13 +91,20 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Construct a Cuboid in the given World and xyz co-ordinates
|
||||
*
|
||||
* @param world the Cuboid's world
|
||||
* @param x1 X co-ordinate of corner 1
|
||||
* @param y1 Y co-ordinate of corner 1
|
||||
* @param z1 Z co-ordinate of corner 1
|
||||
* @param x2 X co-ordinate of corner 2
|
||||
* @param y2 Y co-ordinate of corner 2
|
||||
* @param z2 Z co-ordinate of corner 2
|
||||
* @param world
|
||||
* the Cuboid's world
|
||||
* @param x1
|
||||
* X co-ordinate of corner 1
|
||||
* @param y1
|
||||
* Y co-ordinate of corner 1
|
||||
* @param z1
|
||||
* Z co-ordinate of corner 1
|
||||
* @param x2
|
||||
* X co-ordinate of corner 2
|
||||
* @param y2
|
||||
* Y co-ordinate of corner 2
|
||||
* @param z2
|
||||
* Z co-ordinate of corner 2
|
||||
*/
|
||||
public Cuboid(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
this.worldName = world.getName();
|
||||
@@ -108,13 +119,20 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Construct a Cuboid in the given world name and xyz co-ordinates.
|
||||
*
|
||||
* @param worldName the Cuboid's world name
|
||||
* @param x1 X co-ordinate of corner 1
|
||||
* @param y1 Y co-ordinate of corner 1
|
||||
* @param z1 Z co-ordinate of corner 1
|
||||
* @param x2 X co-ordinate of corner 2
|
||||
* @param y2 Y co-ordinate of corner 2
|
||||
* @param z2 Z co-ordinate of corner 2
|
||||
* @param worldName
|
||||
* the Cuboid's world name
|
||||
* @param x1
|
||||
* X co-ordinate of corner 1
|
||||
* @param y1
|
||||
* Y co-ordinate of corner 1
|
||||
* @param z1
|
||||
* Z co-ordinate of corner 1
|
||||
* @param x2
|
||||
* X co-ordinate of corner 2
|
||||
* @param y2
|
||||
* Y co-ordinate of corner 2
|
||||
* @param z2
|
||||
* Z co-ordinate of corner 2
|
||||
*/
|
||||
private Cuboid(String worldName, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
this.worldName = worldName;
|
||||
@@ -139,9 +157,9 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
public KList<Entity> getEntities() {
|
||||
KList<Entity> en = new KList<>();
|
||||
|
||||
for (Chunk i : getChunks()) {
|
||||
for (Entity j : i.getEntities()) {
|
||||
if (contains(j.getLocation())) {
|
||||
for(Chunk i : getChunks()) {
|
||||
for(Entity j : i.getEntities()) {
|
||||
if(contains(j.getLocation())) {
|
||||
en.add(j);
|
||||
}
|
||||
}
|
||||
@@ -153,8 +171,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Set the locations
|
||||
*
|
||||
* @param l1 a
|
||||
* @param l2 b
|
||||
* @param l1
|
||||
* a
|
||||
* @param l2
|
||||
* b
|
||||
*/
|
||||
public void set(Location l1, Location l2) {
|
||||
x1 = Math.min(l1.getBlockX(), l2.getBlockX());
|
||||
@@ -218,11 +238,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* Get the Cuboid's world.
|
||||
*
|
||||
* @return the World object representing this Cuboid's world
|
||||
* @throws IllegalStateException if the world is not loaded
|
||||
* @throws IllegalStateException
|
||||
* if the world is not loaded
|
||||
*/
|
||||
public World getWorld() {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) {
|
||||
if(world == null) {
|
||||
throw new IllegalStateException("world '" + worldName + "' is not loaded");
|
||||
}
|
||||
return world;
|
||||
@@ -342,12 +363,14 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* amounts will shrink the Cuboid in the given direction. Shrinking a cuboid's
|
||||
* face past the opposite face is not an error and will return a valid Cuboid.
|
||||
*
|
||||
* @param dir the direction in which to expand
|
||||
* @param amount the number of blocks by which to expand
|
||||
* @param dir
|
||||
* the direction in which to expand
|
||||
* @param amount
|
||||
* the number of blocks by which to expand
|
||||
* @return a new Cuboid expanded by the given direction and amount
|
||||
*/
|
||||
public Cuboid expand(CuboidDirection dir, int amount) {
|
||||
return switch (dir) {
|
||||
return switch(dir) {
|
||||
case North -> new Cuboid(worldName, x1 - amount, y1, z1, x2, y2, z2);
|
||||
case South -> new Cuboid(worldName, x1, y1, z1, x2 + amount, y2, z2);
|
||||
case East -> new Cuboid(worldName, x1, y1, z1 - amount, x2, y2, z2);
|
||||
@@ -371,8 +394,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Shift the Cuboid in the given direction by the given amount.
|
||||
*
|
||||
* @param dir the direction in which to shift
|
||||
* @param amount the number of blocks by which to shift
|
||||
* @param dir
|
||||
* the direction in which to shift
|
||||
* @param amount
|
||||
* the number of blocks by which to shift
|
||||
* @return a new Cuboid shifted by the given direction and amount
|
||||
*/
|
||||
public Cuboid shift(CuboidDirection dir, int amount) {
|
||||
@@ -382,13 +407,15 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Outset (grow) the Cuboid in the given direction by the given amount.
|
||||
*
|
||||
* @param dir the direction in which to outset (must be Horizontal, Vertical, or
|
||||
* Both)
|
||||
* @param amount the number of blocks by which to outset
|
||||
* @param dir
|
||||
* the direction in which to outset (must be Horizontal, Vertical, or
|
||||
* Both)
|
||||
* @param amount
|
||||
* the number of blocks by which to outset
|
||||
* @return a new Cuboid outset by the given direction and amount
|
||||
*/
|
||||
public Cuboid outset(CuboidDirection dir, int amount) {
|
||||
Cuboid c = switch (dir) {
|
||||
Cuboid c = switch(dir) {
|
||||
case Horizontal -> expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount);
|
||||
case Vertical -> expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount);
|
||||
case Both -> outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount);
|
||||
@@ -401,9 +428,11 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* Inset (shrink) the Cuboid in the given direction by the given amount.
|
||||
* Equivalent to calling outset() with a negative amount.
|
||||
*
|
||||
* @param dir the direction in which to inset (must be Horizontal, Vertical, or
|
||||
* Both)
|
||||
* @param amount the number of blocks by which to inset
|
||||
* @param dir
|
||||
* the direction in which to inset (must be Horizontal, Vertical, or
|
||||
* Both)
|
||||
* @param amount
|
||||
* the number of blocks by which to inset
|
||||
* @return a new Cuboid inset by the given direction and amount
|
||||
*/
|
||||
public Cuboid inset(CuboidDirection dir, int amount) {
|
||||
@@ -413,9 +442,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Return true if the point at (x,y,z) is contained within this Cuboid.
|
||||
*
|
||||
* @param x the X co-ordinate
|
||||
* @param y the Y co-ordinate
|
||||
* @param z the Z co-ordinate
|
||||
* @param x
|
||||
* the X co-ordinate
|
||||
* @param y
|
||||
* the Y co-ordinate
|
||||
* @param z
|
||||
* the Z co-ordinate
|
||||
* @return true if the given point is within this Cuboid, false otherwise
|
||||
*/
|
||||
public boolean contains(int x, int y, int z) {
|
||||
@@ -425,7 +457,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Check if the given Block is contained within this Cuboid.
|
||||
*
|
||||
* @param b the Block to check for
|
||||
* @param b
|
||||
* the Block to check for
|
||||
* @return true if the Block is within this Cuboid, false otherwise
|
||||
*/
|
||||
public boolean contains(Block b) {
|
||||
@@ -435,7 +468,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Check if the given Location is contained within this Cuboid.
|
||||
*
|
||||
* @param l the Location to check for
|
||||
* @param l
|
||||
* the Location to check for
|
||||
* @return true if the Location is within this Cuboid, false otherwise
|
||||
*/
|
||||
public boolean contains(Location l) {
|
||||
@@ -460,8 +494,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
public byte averageLightLevel() {
|
||||
long total = 0;
|
||||
int n = 0;
|
||||
for (Block b : this) {
|
||||
if (b.isEmpty()) {
|
||||
for(Block b : this) {
|
||||
if(b.isEmpty()) {
|
||||
total += b.getLightLevel();
|
||||
++n;
|
||||
}
|
||||
@@ -484,44 +518,45 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* no exterior empty space. E.g. a direction of Down will push the top face
|
||||
* downwards as much as possible.
|
||||
*
|
||||
* @param dir the direction in which to contract
|
||||
* @param dir
|
||||
* the direction in which to contract
|
||||
* @return a new Cuboid contracted in the given direction
|
||||
*/
|
||||
public Cuboid contract(CuboidDirection dir) {
|
||||
Cuboid face = getFace(dir.opposite());
|
||||
switch (dir) {
|
||||
switch(dir) {
|
||||
case Down -> {
|
||||
while (face.containsOnly(Material.AIR) && face.getLowerY() > this.getLowerY()) {
|
||||
while(face.containsOnly(Material.AIR) && face.getLowerY() > this.getLowerY()) {
|
||||
face = face.shift(CuboidDirection.Down, 1);
|
||||
}
|
||||
return new Cuboid(worldName, x1, y1, z1, x2, face.getUpperY(), z2);
|
||||
}
|
||||
case Up -> {
|
||||
while (face.containsOnly(Material.AIR) && face.getUpperY() < this.getUpperY()) {
|
||||
while(face.containsOnly(Material.AIR) && face.getUpperY() < this.getUpperY()) {
|
||||
face = face.shift(CuboidDirection.Up, 1);
|
||||
}
|
||||
return new Cuboid(worldName, x1, face.getLowerY(), z1, x2, y2, z2);
|
||||
}
|
||||
case North -> {
|
||||
while (face.containsOnly(Material.AIR) && face.getLowerX() > this.getLowerX()) {
|
||||
while(face.containsOnly(Material.AIR) && face.getLowerX() > this.getLowerX()) {
|
||||
face = face.shift(CuboidDirection.North, 1);
|
||||
}
|
||||
return new Cuboid(worldName, x1, y1, z1, face.getUpperX(), y2, z2);
|
||||
}
|
||||
case South -> {
|
||||
while (face.containsOnly(Material.AIR) && face.getUpperX() < this.getUpperX()) {
|
||||
while(face.containsOnly(Material.AIR) && face.getUpperX() < this.getUpperX()) {
|
||||
face = face.shift(CuboidDirection.South, 1);
|
||||
}
|
||||
return new Cuboid(worldName, face.getLowerX(), y1, z1, x2, y2, z2);
|
||||
}
|
||||
case East -> {
|
||||
while (face.containsOnly(Material.AIR) && face.getLowerZ() > this.getLowerZ()) {
|
||||
while(face.containsOnly(Material.AIR) && face.getLowerZ() > this.getLowerZ()) {
|
||||
face = face.shift(CuboidDirection.East, 1);
|
||||
}
|
||||
return new Cuboid(worldName, x1, y1, z1, x2, y2, face.getUpperZ());
|
||||
}
|
||||
case West -> {
|
||||
while (face.containsOnly(Material.AIR) && face.getUpperZ() < this.getUpperZ()) {
|
||||
while(face.containsOnly(Material.AIR) && face.getUpperZ() < this.getUpperZ()) {
|
||||
face = face.shift(CuboidDirection.West, 1);
|
||||
}
|
||||
return new Cuboid(worldName, x1, y1, face.getLowerZ(), x2, y2, z2);
|
||||
@@ -534,11 +569,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* Get the Cuboid representing the face of this Cuboid. The resulting Cuboid
|
||||
* will be one block thick in the axis perpendicular to the requested face.
|
||||
*
|
||||
* @param dir which face of the Cuboid to get
|
||||
* @param dir
|
||||
* which face of the Cuboid to get
|
||||
* @return the Cuboid representing this Cuboid's requested face
|
||||
*/
|
||||
public Cuboid getFace(CuboidDirection dir) {
|
||||
return switch (dir) {
|
||||
return switch(dir) {
|
||||
case Down -> new Cuboid(worldName, x1, y1, z1, x2, y1, z2);
|
||||
case Up -> new Cuboid(worldName, x1, y2, z1, x2, y2, z2);
|
||||
case North -> new Cuboid(worldName, x1, y1, z1, x1, y2, z2);
|
||||
@@ -552,12 +588,13 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Check if the Cuboid contains only blocks of the given type
|
||||
*
|
||||
* @param material the material to check for
|
||||
* @param material
|
||||
* the material to check for
|
||||
* @return true if this Cuboid contains only blocks of the given type
|
||||
*/
|
||||
public boolean containsOnly(Material material) {
|
||||
for (Block b : this) {
|
||||
if (b.getType() != material) {
|
||||
for(Block b : this) {
|
||||
if(b.getType() != material) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -567,11 +604,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Get the Cuboid big enough to hold both this Cuboid and the given one.
|
||||
*
|
||||
* @param other the other Cuboid to include
|
||||
* @param other
|
||||
* the other Cuboid to include
|
||||
* @return a new Cuboid large enough to hold this Cuboid and the given Cuboid
|
||||
*/
|
||||
public Cuboid getBoundingCuboid(Cuboid other) {
|
||||
if (other == null) {
|
||||
if(other == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -588,9 +626,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
/**
|
||||
* Get a block relative to the lower NE point of the Cuboid.
|
||||
*
|
||||
* @param x the X co-ordinate
|
||||
* @param y the Y co-ordinate
|
||||
* @param z the Z co-ordinate
|
||||
* @param x
|
||||
* the X co-ordinate
|
||||
* @param y
|
||||
* the Y co-ordinate
|
||||
* @param z
|
||||
* the Z co-ordinate
|
||||
* @return the block at the given position
|
||||
*/
|
||||
public Block getRelativeBlock(int x, int y, int z) {
|
||||
@@ -602,10 +643,14 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* This version of getRelativeBlock() should be used if being called many times,
|
||||
* to avoid excessive calls to getWorld().
|
||||
*
|
||||
* @param w the World
|
||||
* @param x the X co-ordinate
|
||||
* @param y the Y co-ordinate
|
||||
* @param z the Z co-ordinate
|
||||
* @param w
|
||||
* the World
|
||||
* @param x
|
||||
* the X co-ordinate
|
||||
* @param y
|
||||
* the Y co-ordinate
|
||||
* @param z
|
||||
* the Z co-ordinate
|
||||
* @return the block at the given position
|
||||
*/
|
||||
public Block getRelativeBlock(World w, int x, int y, int z) {
|
||||
@@ -626,8 +671,8 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
int x2 = getUpperX() & ~0xf;
|
||||
int z1 = getLowerZ() & ~0xf;
|
||||
int z2 = getUpperZ() & ~0xf;
|
||||
for (int x = x1; x <= x2; x += 16) {
|
||||
for (int z = z1; z <= z2; z += 16) {
|
||||
for(int x = x1; x <= x2; x += 16) {
|
||||
for(int z = z1; z <= z2; z += 16) {
|
||||
res.add(w.getChunkAt(x >> 4, z >> 4));
|
||||
}
|
||||
}
|
||||
@@ -693,7 +738,7 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
Unknown;
|
||||
|
||||
public CuboidDirection opposite() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case North -> South;
|
||||
case East -> West;
|
||||
case South -> North;
|
||||
@@ -737,9 +782,9 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
@Override
|
||||
public Block next() {
|
||||
Block b = w.getBlockAt(baseX + x, baseY + y, baseZ + z);
|
||||
if (++x >= sizeX) {
|
||||
if(++x >= sizeX) {
|
||||
x = 0;
|
||||
if (++y >= sizeY) {
|
||||
if(++y >= sizeY) {
|
||||
y = 0;
|
||||
++z;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,9 @@
|
||||
|
||||
package com.volmit.iris.util.data;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ public class DataPalette<T> {
|
||||
KList<T> palette = new KList<>();
|
||||
int s = din.readShort() - Short.MIN_VALUE;
|
||||
|
||||
for (int i = 0; i < s; i++) {
|
||||
for(int i = 0; i < s; i++) {
|
||||
palette.add(adapter.read(din));
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ public class DataPalette<T> {
|
||||
}
|
||||
|
||||
public T get(int index) {
|
||||
synchronized (palette) {
|
||||
if (!palette.hasIndex(index)) {
|
||||
synchronized(palette) {
|
||||
if(!palette.hasIndex(index)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ public class DataPalette<T> {
|
||||
public int getIndex(T t) {
|
||||
int v = 0;
|
||||
|
||||
synchronized (palette) {
|
||||
synchronized(palette) {
|
||||
v = palette.indexOf(t);
|
||||
|
||||
if (v == -1) {
|
||||
if(v == -1) {
|
||||
v = palette.size();
|
||||
palette.add(t);
|
||||
}
|
||||
@@ -76,10 +76,10 @@ public class DataPalette<T> {
|
||||
}
|
||||
|
||||
public void write(IOAdapter<T> adapter, DataOutputStream dos) throws IOException {
|
||||
synchronized (palette) {
|
||||
synchronized(palette) {
|
||||
dos.writeShort(getPalette().size() + Short.MIN_VALUE);
|
||||
|
||||
for (T t : palette) {
|
||||
for(T t : palette) {
|
||||
adapter.write(t, dos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,12 @@ public class Dimension {
|
||||
/**
|
||||
* Make a dimension
|
||||
*
|
||||
* @param width width of this (X)
|
||||
* @param height the height (Y)
|
||||
* @param depth the depth (Z)
|
||||
* @param width
|
||||
* width of this (X)
|
||||
* @param height
|
||||
* the height (Y)
|
||||
* @param depth
|
||||
* the depth (Z)
|
||||
*/
|
||||
public Dimension(int width, int height, int depth) {
|
||||
this.width = width;
|
||||
@@ -44,8 +47,10 @@ public class Dimension {
|
||||
/**
|
||||
* Make a dimension
|
||||
*
|
||||
* @param width width of this (X)
|
||||
* @param height the height (Y)
|
||||
* @param width
|
||||
* width of this (X)
|
||||
* @param height
|
||||
* the height (Y)
|
||||
*/
|
||||
public Dimension(int width, int height) {
|
||||
this.width = width;
|
||||
@@ -60,15 +65,15 @@ public class Dimension {
|
||||
* @return the direction of the flat pane or null
|
||||
*/
|
||||
public DimensionFace getPane() {
|
||||
if (width == 1) {
|
||||
if(width == 1) {
|
||||
return DimensionFace.X;
|
||||
}
|
||||
|
||||
if (height == 1) {
|
||||
if(height == 1) {
|
||||
return DimensionFace.Y;
|
||||
}
|
||||
|
||||
if (depth == 1) {
|
||||
if(depth == 1) {
|
||||
return DimensionFace.Z;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Arrays;
|
||||
|
||||
public class DoubleArrayUtils {
|
||||
public static void shiftRight(double[] values, double push) {
|
||||
if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1);
|
||||
if(values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1);
|
||||
|
||||
values[0] = push;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class DoubleArrayUtils {
|
||||
}
|
||||
|
||||
public static void fill(AtomicDoubleArray values, double value) {
|
||||
for (int i = 0; i < values.length(); i++) {
|
||||
for(int i = 0; i < values.length(); i++) {
|
||||
values.set(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ public class IrisBiomeStorage implements BiomeGrid {
|
||||
|
||||
public void inject(BiomeGrid grid) {
|
||||
// TODO: WARNING HEIGHT
|
||||
for (int i = 0; i < 256; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
for (int k = 0; k < 16; k++) {
|
||||
for(int i = 0; i < 256; i++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
for(int k = 0; k < 16; k++) {
|
||||
Biome b = getBiome(j, i, k);
|
||||
|
||||
if (b == null || b.equals(Biome.THE_VOID)) {
|
||||
if(b == null || b.equals(Biome.THE_VOID)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ public class KCache<K, V> implements MeteredCache {
|
||||
|
||||
private LoadingCache<K, V> create(CacheLoader<K, V> loader) {
|
||||
return Caffeine
|
||||
.newBuilder()
|
||||
.maximumSize(max)
|
||||
.softValues()
|
||||
.initialCapacity((int) (max))
|
||||
.build((k) -> loader == null ? null : loader.load(k));
|
||||
.newBuilder()
|
||||
.maximumSize(max)
|
||||
.softValues()
|
||||
.initialCapacity((int) (max))
|
||||
.build((k) -> loader == null ? null : loader.load(k));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@ public class MaterialBlock {
|
||||
/**
|
||||
* Create a materialblock
|
||||
*
|
||||
* @param material the material
|
||||
* @param data the data
|
||||
* @param material
|
||||
* the material
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public MaterialBlock(Material material, Byte data) {
|
||||
this.material = material;
|
||||
@@ -86,7 +88,7 @@ public class MaterialBlock {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (getData() == 0) {
|
||||
if(getData() == 0) {
|
||||
return getMaterial().toString();
|
||||
}
|
||||
|
||||
@@ -104,21 +106,21 @@ public class MaterialBlock {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
if(this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
if(obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
if(getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MaterialBlock other = (MaterialBlock) obj;
|
||||
if (data == null) {
|
||||
if (other.data != null) {
|
||||
if(data == null) {
|
||||
if(other.data != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!data.equals(other.data)) {
|
||||
} else if(!data.equals(other.data)) {
|
||||
return false;
|
||||
}
|
||||
return material == other.material;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class NibbleArray implements Writable {
|
||||
private static final int[] MASKS = new int[8];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < MASKS.length; i++) {
|
||||
for(int i = 0; i < MASKS.length; i++) {
|
||||
MASKS[i] = maskFor(i);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class NibbleArray implements Writable {
|
||||
}
|
||||
|
||||
public NibbleArray(int nibbleDepth, int capacity) {
|
||||
if (nibbleDepth > 8 || nibbleDepth < 1) {
|
||||
if(nibbleDepth > 8 || nibbleDepth < 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class NibbleArray implements Writable {
|
||||
}
|
||||
|
||||
public NibbleArray(int nibbleDepth, int capacity, NibbleArray existing) {
|
||||
if (nibbleDepth > 8 || nibbleDepth < 1) {
|
||||
if(nibbleDepth > 8 || nibbleDepth < 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class NibbleArray implements Writable {
|
||||
data = new byte[(neededBits + neededBits % 8) / 8];
|
||||
mask = (byte) maskFor(nibbleDepth);
|
||||
|
||||
for (int i = 0; i < Math.min(size, existing.size()); i++) {
|
||||
for(int i = 0; i < Math.min(size, existing.size()); i++) {
|
||||
set(i, existing.get(i));
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class NibbleArray implements Writable {
|
||||
public static int powerOfTwo(int power) {
|
||||
int result = 1;
|
||||
|
||||
for (int i = 0; i < power; i++) {
|
||||
for(int i = 0; i < power; i++) {
|
||||
result *= 2;
|
||||
}
|
||||
|
||||
@@ -119,13 +119,13 @@ public class NibbleArray implements Writable {
|
||||
}
|
||||
|
||||
public byte get(int index) {
|
||||
synchronized (lock) {
|
||||
synchronized(lock) {
|
||||
bitIndex = index * depth;
|
||||
byteIndex = bitIndex >> 3;
|
||||
bitInByte = bitIndex & 7;
|
||||
int value = data[byteIndex] >> bitInByte;
|
||||
|
||||
if (bitInByte + depth > 8) {
|
||||
if(bitInByte + depth > 8) {
|
||||
value |= data[byteIndex + 1] << bitInByte;
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ public class NibbleArray implements Writable {
|
||||
}
|
||||
|
||||
public void set(int index, byte nybble) {
|
||||
synchronized (lock) {
|
||||
synchronized(lock) {
|
||||
bitIndex = index * depth;
|
||||
byteIndex = bitIndex >> 3;
|
||||
bitInByte = bitIndex & 7;
|
||||
data[byteIndex] = (byte) (((~(data[byteIndex] & (mask << bitInByte)) & data[byteIndex]) | ((nybble & mask) << bitInByte)) & 0xff);
|
||||
|
||||
if (bitInByte + depth > 8) {
|
||||
if(bitInByte + depth > 8) {
|
||||
data[byteIndex + 1] = (byte) (((~(data[byteIndex + 1] & MASKS[bitInByte + depth - 8]) & data[byteIndex + 1]) | ((nybble & mask) >> (8 - bitInByte))) & 0xff);
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class NibbleArray implements Writable {
|
||||
public String toBitsString(ByteOrder byteOrder) {
|
||||
StringJoiner joiner = new StringJoiner(" ");
|
||||
|
||||
for (byte datum : data) {
|
||||
for(byte datum : data) {
|
||||
joiner.add(binaryString(datum, byteOrder));
|
||||
}
|
||||
|
||||
@@ -181,13 +181,13 @@ public class NibbleArray implements Writable {
|
||||
}
|
||||
|
||||
public void setAll(byte nibble) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
for(int i = 0; i < size; i++) {
|
||||
set(i, nibble);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAll(int nibble) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
for(int i = 0; i < size; i++) {
|
||||
set(i, (byte) nibble);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
o.writeByte(bpb + Byte.MIN_VALUE);
|
||||
o.writeByte(palette.size() + Byte.MIN_VALUE);
|
||||
|
||||
for (T i : palette) {
|
||||
for(T i : palette) {
|
||||
writeType(i, o);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
palette = new KList<>();
|
||||
int v = i.readByte() - Byte.MIN_VALUE;
|
||||
|
||||
for (int j = 0; j < v; j++) {
|
||||
for(int j = 0; j < v; j++) {
|
||||
palette.add(readType(i));
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
}
|
||||
|
||||
private final void expand() {
|
||||
if (bpb < 8) {
|
||||
if(bpb < 8) {
|
||||
changeBitsPerBlock(bpb + 1);
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException("The Data Palette can only handle at most 256 block types per 16x16x16 region. We cannot use more than 8 bits per block!");
|
||||
@@ -80,8 +80,8 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
int targetBits = bpb;
|
||||
int needed = palette.size();
|
||||
|
||||
for (int i = 1; i < bpb; i++) {
|
||||
if (Math.pow(2, i) > needed) {
|
||||
for(int i = 1; i < bpb; i++) {
|
||||
if(Math.pow(2, i) > needed) {
|
||||
targetBits = i;
|
||||
break;
|
||||
}
|
||||
@@ -106,11 +106,11 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
private final int getPaletteId(T d) {
|
||||
int index = palette.indexOf(d);
|
||||
|
||||
if (index == -1) {
|
||||
if(index == -1) {
|
||||
index = palette.size();
|
||||
palette.add(d);
|
||||
|
||||
if (palette.size() > Math.pow(2, bpb)) {
|
||||
if(palette.size() > Math.pow(2, bpb)) {
|
||||
expand();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,67 +34,67 @@ public class VanillaBiomeMap {
|
||||
|
||||
static {
|
||||
add(Biome.OCEAN, 0x000070, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.PLAINS, 0x8DB360, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.DESERT, 0xFA9418, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.WINDSWEPT_HILLS, 0x606060, Color.MONOCHROME, Luminosity.BRIGHT, null);
|
||||
add(Biome.FOREST, 0x056621, Color.GREEN, Luminosity.BRIGHT, null);
|
||||
add(Biome.PLAINS, 0x8DB360, Color.GREEN, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.DESERT, 0xFA9418, Color.YELLOW, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.WINDSWEPT_HILLS, 0x606060, Color.MONOCHROME, Luminosity.BRIGHT, null);
|
||||
add(Biome.FOREST, 0x056621, Color.GREEN, Luminosity.BRIGHT, null);
|
||||
add(Biome.TAIGA, 0x0B6659, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.SWAMP, 0x07F9B2, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM);
|
||||
add(Biome.SWAMP, 0x07F9B2, Color.ORANGE, Luminosity.DARK, SaturationType.MEDIUM);
|
||||
add(Biome.RIVER, 0x0000FF, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.NETHER_WASTES, 0xBF3B3B, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.THE_END, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.FROZEN_OCEAN, 0x7070D6, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.FROZEN_RIVER, 0xA0A0FF, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.SNOWY_PLAINS, 0xFFFFFF, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.MUSHROOM_FIELDS, 0xFF00FF, Color.PURPLE, Luminosity.BRIGHT, null);
|
||||
add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.NETHER_WASTES, 0xBF3B3B, Color.RED, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.THE_END, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.FROZEN_OCEAN, 0x7070D6, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.FROZEN_RIVER, 0xA0A0FF, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.SNOWY_PLAINS, 0xFFFFFF, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.MUSHROOM_FIELDS, 0xFF00FF, Color.PURPLE, Luminosity.BRIGHT, null);
|
||||
add(Biome.BEACH, 0xFADE55, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.JUNGLE, 0x537B09, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.SPARSE_JUNGLE, 0x628B17, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null);
|
||||
add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null);
|
||||
add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null);
|
||||
add(Biome.DEEP_OCEAN, 0x000030, Color.BLUE, Luminosity.DARK, null);
|
||||
add(Biome.STONY_SHORE, 0xA2A284, Color.GREEN, Luminosity.DARK, null);
|
||||
add(Biome.SNOWY_BEACH, 0xFAF0C0, Color.YELLOW, Luminosity.LIGHT, null);
|
||||
add(Biome.BIRCH_FOREST, 0x307444, Color.GREEN, Luminosity.LIGHT, null);
|
||||
add(Biome.DARK_FOREST, 0x40511A, Color.GREEN, Luminosity.DARK, null);
|
||||
add(Biome.SNOWY_TAIGA, 0x31554A, Color.BLUE, Luminosity.LIGHT, null);
|
||||
add(Biome.OLD_GROWTH_PINE_TAIGA, 0x596651, Color.ORANGE, Luminosity.LIGHT, null);
|
||||
add(Biome.SNOWY_TAIGA, 0x31554A, Color.BLUE, Luminosity.LIGHT, null);
|
||||
add(Biome.OLD_GROWTH_PINE_TAIGA, 0x596651, Color.ORANGE, Luminosity.LIGHT, null);
|
||||
add(Biome.WINDSWEPT_FOREST, 0x507050, Color.MONOCHROME, Luminosity.BRIGHT, null);
|
||||
add(Biome.SAVANNA, 0xBDB25F, Color.GREEN, Luminosity.LIGHT, null);
|
||||
add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null);
|
||||
add(Biome.SAVANNA, 0xBDB25F, Color.GREEN, Luminosity.LIGHT, null);
|
||||
add(Biome.SAVANNA_PLATEAU, 0xA79D64, Color.GREEN, Luminosity.LIGHT, null);
|
||||
add(Biome.BADLANDS, 0xD94515, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.WOODED_BADLANDS, 0xB09765, Color.ORANGE, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.SMALL_END_ISLANDS, 0xff1a8c, Color.PURPLE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.END_MIDLANDS, 0x8080FF, Color.YELLOW, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.END_HIGHLANDS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.END_BARRENS, 0x8080FF, Color.PURPLE, Luminosity.LIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.WARM_OCEAN, 0x0000AC, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW);
|
||||
add(Biome.LUKEWARM_OCEAN, 0x000090, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.COLD_OCEAN, 0x202070, Color.BLUE, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM);
|
||||
add(Biome.DEEP_COLD_OCEAN, 0x202038, Color.BLUE, Luminosity.DARK, SaturationType.HIGH);
|
||||
add(Biome.DEEP_FROZEN_OCEAN, 0x404090, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.THE_VOID, 0x000000, Color.MONOCHROME, Luminosity.DARK, null);
|
||||
add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x789878, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.FLOWER_FOREST, 0x2D8E49, Color.RED, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.ICE_SPIKES, 0xB4DCDC, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.DEEP_LUKEWARM_OCEAN, 0x000040, Color.BLUE, Luminosity.DARK, SaturationType.MEDIUM);
|
||||
add(Biome.DEEP_COLD_OCEAN, 0x202038, Color.BLUE, Luminosity.DARK, SaturationType.HIGH);
|
||||
add(Biome.DEEP_FROZEN_OCEAN, 0x404090, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.THE_VOID, 0x000000, Color.MONOCHROME, Luminosity.DARK, null);
|
||||
add(Biome.SUNFLOWER_PLAINS, 0xB5DB88, Color.GREEN, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.WINDSWEPT_GRAVELLY_HILLS, 0x789878, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.FLOWER_FOREST, 0x2D8E49, Color.RED, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.ICE_SPIKES, 0xB4DCDC, Color.BLUE, Luminosity.LIGHT, SaturationType.LOW);
|
||||
add(Biome.OLD_GROWTH_BIRCH_FOREST, 0x589C6C, Color.GREEN, Luminosity.LIGHT, null);
|
||||
add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x818E79, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH);
|
||||
add(Biome.WINDSWEPT_SAVANNA, 0xE5DA87, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
|
||||
add(Biome.ERODED_BADLANDS, 0xFF6D3D, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
|
||||
add(Biome.BAMBOO_JUNGLE, 0x768E14, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.SOUL_SAND_VALLEY, 0x5E3830, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.CRIMSON_FOREST, 0xDD0808, Color.RED, Luminosity.DARK, SaturationType.HIGH);
|
||||
add(Biome.WARPED_FOREST, 0x49907B, Color.BLUE, Luminosity.BRIGHT, null);
|
||||
add(Biome.OLD_GROWTH_SPRUCE_TAIGA, 0x818E79, Color.ORANGE, Luminosity.DARK, SaturationType.HIGH);
|
||||
add(Biome.WINDSWEPT_SAVANNA, 0xE5DA87, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
|
||||
add(Biome.ERODED_BADLANDS, 0xFF6D3D, Color.ORANGE, Luminosity.LIGHT, SaturationType.HIGH);
|
||||
add(Biome.BAMBOO_JUNGLE, 0x768E14, Color.GREEN, Luminosity.BRIGHT, SaturationType.HIGH);
|
||||
add(Biome.SOUL_SAND_VALLEY, 0x5E3830, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.CRIMSON_FOREST, 0xDD0808, Color.RED, Luminosity.DARK, SaturationType.HIGH);
|
||||
add(Biome.WARPED_FOREST, 0x49907B, Color.BLUE, Luminosity.BRIGHT, null);
|
||||
add(Biome.BASALT_DELTAS, 0x403636, Color.MONOCHROME, Luminosity.DARK, null);
|
||||
add(Biome.DRIPSTONE_CAVES, 0xcc6600, Color.ORANGE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.LUSH_CAVES, 0x003300, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.MEADOW, 0xff00ff, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW);
|
||||
add(Biome.GROVE, 0x80ff80, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.SNOWY_SLOPES, 0x00ffff, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.FROZEN_PEAKS, 0xA0A0A0, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.JAGGED_PEAKS, 0x3d7bc2, Color.MONOCHROME, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.STONY_PEAKS, 0x888888, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.CUSTOM, 0xffffff, Color.MONOCHROME, Luminosity.DARK, SaturationType.MONOCHROME);
|
||||
add(Biome.LUSH_CAVES, 0x003300, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.MEADOW, 0xff00ff, Color.BLUE, Luminosity.BRIGHT, SaturationType.LOW);
|
||||
add(Biome.GROVE, 0x80ff80, Color.GREEN, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.SNOWY_SLOPES, 0x00ffff, Color.BLUE, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.FROZEN_PEAKS, 0xA0A0A0, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.JAGGED_PEAKS, 0x3d7bc2, Color.MONOCHROME, Luminosity.BRIGHT, SaturationType.MEDIUM);
|
||||
add(Biome.STONY_PEAKS, 0x888888, Color.MONOCHROME, Luminosity.LIGHT, null);
|
||||
add(Biome.CUSTOM, 0xffffff, Color.MONOCHROME, Luminosity.DARK, SaturationType.MONOCHROME);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,12 @@ public final class Varint {
|
||||
* encode signed values. If values are known to be nonnegative,
|
||||
* {@link #writeUnsignedVarLong(long, DataOutput)} should be used.
|
||||
*
|
||||
* @param value value to encode
|
||||
* @param out to writeNodeData bytes to
|
||||
* @throws IOException if {@link DataOutput} throws {@link IOException}
|
||||
* @param value
|
||||
* value to encode
|
||||
* @param out
|
||||
* to writeNodeData bytes to
|
||||
* @throws IOException
|
||||
* if {@link DataOutput} throws {@link IOException}
|
||||
*/
|
||||
public static void writeSignedVarLong(long value, DataOutput out) throws IOException {
|
||||
// Great trick from http://code.google.com/apis/protocolbuffers/docs/encoding.html#types
|
||||
@@ -60,12 +63,15 @@ public final class Varint {
|
||||
* If values can be negative, use {@link #writeSignedVarLong(long, DataOutput)}
|
||||
* instead. This method treats negative input as like a large unsigned value.
|
||||
*
|
||||
* @param value value to encode
|
||||
* @param out to writeNodeData bytes to
|
||||
* @throws IOException if {@link DataOutput} throws {@link IOException}
|
||||
* @param value
|
||||
* value to encode
|
||||
* @param out
|
||||
* to writeNodeData bytes to
|
||||
* @throws IOException
|
||||
* if {@link DataOutput} throws {@link IOException}
|
||||
*/
|
||||
public static void writeUnsignedVarLong(long value, DataOutput out) throws IOException {
|
||||
while ((value & 0xFFFFFFFFFFFFFF80L) != 0L) {
|
||||
while((value & 0xFFFFFFFFFFFFFF80L) != 0L) {
|
||||
out.writeByte(((int) value & 0x7F) | 0x80);
|
||||
value >>>= 7;
|
||||
}
|
||||
@@ -84,7 +90,7 @@ public final class Varint {
|
||||
* @see #writeUnsignedVarLong(long, DataOutput)
|
||||
*/
|
||||
public static void writeUnsignedVarInt(int value, DataOutput out) throws IOException {
|
||||
while ((value & 0xFFFFFF80) != 0L) {
|
||||
while((value & 0xFFFFFF80) != 0L) {
|
||||
out.writeByte((value & 0x7F) | 0x80);
|
||||
value >>>= 7;
|
||||
}
|
||||
@@ -105,24 +111,27 @@ public final class Varint {
|
||||
public static byte[] writeUnsignedVarInt(int value) {
|
||||
byte[] byteArrayList = new byte[10];
|
||||
int i = 0;
|
||||
while ((value & 0xFFFFFF80) != 0L) {
|
||||
while((value & 0xFFFFFF80) != 0L) {
|
||||
byteArrayList[i++] = ((byte) ((value & 0x7F) | 0x80));
|
||||
value >>>= 7;
|
||||
}
|
||||
byteArrayList[i] = ((byte) (value & 0x7F));
|
||||
byte[] out = new byte[i + 1];
|
||||
for (; i >= 0; i--) {
|
||||
for(; i >= 0; i--) {
|
||||
out[i] = byteArrayList[i];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param in to read bytes from
|
||||
* @param in
|
||||
* to read bytes from
|
||||
* @return decode value
|
||||
* @throws IOException if {@link DataInput} throws {@link IOException}
|
||||
* @throws IllegalArgumentException if variable-length value does not terminate
|
||||
* after 9 bytes have been read
|
||||
* @throws IOException
|
||||
* if {@link DataInput} throws {@link IOException}
|
||||
* @throws IllegalArgumentException
|
||||
* if variable-length value does not terminate
|
||||
* after 9 bytes have been read
|
||||
* @see #writeSignedVarLong(long, DataOutput)
|
||||
*/
|
||||
public static long readSignedVarLong(DataInput in) throws IOException {
|
||||
@@ -136,21 +145,24 @@ public final class Varint {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param in to read bytes from
|
||||
* @param in
|
||||
* to read bytes from
|
||||
* @return decode value
|
||||
* @throws IOException if {@link DataInput} throws {@link IOException}
|
||||
* @throws IllegalArgumentException if variable-length value does not terminate
|
||||
* after 9 bytes have been read
|
||||
* @throws IOException
|
||||
* if {@link DataInput} throws {@link IOException}
|
||||
* @throws IllegalArgumentException
|
||||
* if variable-length value does not terminate
|
||||
* after 9 bytes have been read
|
||||
* @see #writeUnsignedVarLong(long, DataOutput)
|
||||
*/
|
||||
public static long readUnsignedVarLong(DataInput in) throws IOException {
|
||||
long value = 0L;
|
||||
int i = 0;
|
||||
long b;
|
||||
while (((b = in.readByte()) & 0x80L) != 0) {
|
||||
while(((b = in.readByte()) & 0x80L) != 0) {
|
||||
value |= (b & 0x7F) << i;
|
||||
i += 7;
|
||||
if (i > 63) {
|
||||
if(i > 63) {
|
||||
throw new IllegalArgumentException("Variable length quantity is too long");
|
||||
}
|
||||
}
|
||||
@@ -158,9 +170,11 @@ public final class Varint {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if variable-length value does not terminate
|
||||
* after 5 bytes have been read
|
||||
* @throws IOException if {@link DataInput} throws {@link IOException}
|
||||
* @throws IllegalArgumentException
|
||||
* if variable-length value does not terminate
|
||||
* after 5 bytes have been read
|
||||
* @throws IOException
|
||||
* if {@link DataInput} throws {@link IOException}
|
||||
* @see #readSignedVarLong(DataInput)
|
||||
*/
|
||||
public static int readSignedVarInt(DataInput in) throws IOException {
|
||||
@@ -174,19 +188,21 @@ public final class Varint {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if variable-length value does not terminate
|
||||
* after 5 bytes have been read
|
||||
* @throws IOException if {@link DataInput} throws {@link IOException}
|
||||
* @throws IllegalArgumentException
|
||||
* if variable-length value does not terminate
|
||||
* after 5 bytes have been read
|
||||
* @throws IOException
|
||||
* if {@link DataInput} throws {@link IOException}
|
||||
* @see #readUnsignedVarLong(DataInput)
|
||||
*/
|
||||
public static int readUnsignedVarInt(DataInput in) throws IOException {
|
||||
int value = 0;
|
||||
int i = 0;
|
||||
int b;
|
||||
while (((b = in.readByte()) & 0x80) != 0) {
|
||||
while(((b = in.readByte()) & 0x80) != 0) {
|
||||
value |= (b & 0x7F) << i;
|
||||
i += 7;
|
||||
if (i > 35) {
|
||||
if(i > 35) {
|
||||
throw new IllegalArgumentException("Variable length quantity is too long");
|
||||
}
|
||||
}
|
||||
@@ -207,14 +223,14 @@ public final class Varint {
|
||||
int value = 0;
|
||||
int i = 0;
|
||||
byte rb = Byte.MIN_VALUE;
|
||||
for (byte b : bytes) {
|
||||
for(byte b : bytes) {
|
||||
rb = b;
|
||||
if ((b & 0x80) == 0) {
|
||||
if((b & 0x80) == 0) {
|
||||
break;
|
||||
}
|
||||
value |= (b & 0x7f) << i;
|
||||
i += 7;
|
||||
if (i > 35) {
|
||||
if(i > 35) {
|
||||
throw new IllegalArgumentException("Variable length quantity is too long");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class WeightMap<T> extends KMap<T, Double> {
|
||||
private double lastWeight = 0;
|
||||
|
||||
public double getPercentChance(T t) {
|
||||
if (totalWeight() <= 0) {
|
||||
if(totalWeight() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class WeightMap<T> extends KMap<T, Double> {
|
||||
}
|
||||
|
||||
public double totalWeight() {
|
||||
if (!modified) {
|
||||
if(!modified) {
|
||||
return lastWeight;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WeightedRandom<T> {
|
||||
public T pullRandom() {
|
||||
int pull = random.nextInt(totalWeight);
|
||||
int index = 0;
|
||||
while (pull > 0) {
|
||||
while(pull > 0) {
|
||||
pull -= weightedObjects.get(index).getV();
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -24,27 +24,27 @@ import java.util.concurrent.atomic.AtomicLongArray;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
public class BitStorage {
|
||||
private static final int[] MAGIC = new int[]{
|
||||
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
||||
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
||||
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
||||
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
||||
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
||||
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
||||
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
||||
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
||||
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
||||
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
||||
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
||||
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
||||
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
||||
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
||||
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
||||
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
||||
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
||||
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
||||
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
||||
0, 5};
|
||||
private static final int[] MAGIC = new int[] {
|
||||
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
||||
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
||||
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
||||
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
||||
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
||||
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
||||
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
||||
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
||||
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
||||
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
||||
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
||||
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
||||
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
||||
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
||||
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
||||
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
||||
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
||||
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
||||
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
||||
0, 5};
|
||||
|
||||
private final AtomicLongArray data;
|
||||
private final int bits;
|
||||
@@ -60,12 +60,12 @@ public class BitStorage {
|
||||
}
|
||||
|
||||
private static AtomicLongArray atomic(long[] data) {
|
||||
if (data == null) {
|
||||
if(data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AtomicLongArray d = new AtomicLongArray(data.length);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for(int i = 0; i < data.length; i++) {
|
||||
d.set(i, data[i]);
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ public class BitStorage {
|
||||
}
|
||||
|
||||
private static long[] atomic(AtomicLongArray data) {
|
||||
if (data == null) {
|
||||
if(data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long[] d = new long[data.length()];
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
for(int i = 0; i < data.length(); i++) {
|
||||
d[i] = data.get(i);
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ public class BitStorage {
|
||||
this.divideAdd = MAGIC[var3 + 1];
|
||||
this.divideShift = MAGIC[var3 + 2];
|
||||
int var4 = (length + this.valuesPerLong - 1) / this.valuesPerLong;
|
||||
if (data != null) {
|
||||
if (data.length() != var4) {
|
||||
if(data != null) {
|
||||
if(data.length() != var4) {
|
||||
throw new RuntimeException("NO!");
|
||||
}
|
||||
this.data = data;
|
||||
@@ -159,12 +159,12 @@ public class BitStorage {
|
||||
|
||||
public void getAll(IntConsumer var0) {
|
||||
int var1 = 0;
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
for(int i = 0; i < data.length(); i++) {
|
||||
long var5 = data.get(i);
|
||||
for (int var7 = 0; var7 < this.valuesPerLong; var7++) {
|
||||
for(int var7 = 0; var7 < this.valuesPerLong; var7++) {
|
||||
var0.accept((int) (var5 & this.mask));
|
||||
var5 >>= this.bits;
|
||||
if (++var1 >= this.size)
|
||||
if(++var1 >= this.size)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
|
||||
|
||||
public K byId(int var0) {
|
||||
if (var0 < 0 || var0 >= this.byId.length()) {
|
||||
if(var0 < 0 || var0 >= this.byId.length()) {
|
||||
return null;
|
||||
}
|
||||
return this.byId.get(var0);
|
||||
}
|
||||
|
||||
private int getValue(int var0) {
|
||||
if (var0 == -1) {
|
||||
if(var0 == -1) {
|
||||
return -1;
|
||||
}
|
||||
return this.values.get(var0);
|
||||
@@ -76,7 +76,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
}
|
||||
|
||||
private int nextId() {
|
||||
while (nextId < byId.length() && byId.get(nextId) != null) {
|
||||
while(nextId < byId.length() && byId.get(nextId) != null) {
|
||||
nextId++;
|
||||
}
|
||||
return nextId;
|
||||
@@ -90,8 +90,8 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
this.byId = new AtomicReferenceArray<>(var0);
|
||||
this.nextId = 0;
|
||||
this.size = 0;
|
||||
for (int var3 = 0; var3 < var1.length(); var3++) {
|
||||
if (var1.get(var3) != null) {
|
||||
for(int var3 = 0; var3 < var1.length(); var3++) {
|
||||
if(var1.get(var3) != null) {
|
||||
addMapping(var1.get(var3), var2.get(var3));
|
||||
}
|
||||
}
|
||||
@@ -99,9 +99,9 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
|
||||
public void addMapping(K var0, int var1) {
|
||||
int var2 = Math.max(var1, this.size + 1);
|
||||
if (var2 >= this.keys.length() * 0.8F) {
|
||||
if(var2 >= this.keys.length() * 0.8F) {
|
||||
int i = this.keys.length() << 1;
|
||||
while (i < var1)
|
||||
while(i < var1)
|
||||
i <<= 1;
|
||||
grow(i);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
this.values.set(var3, var1);
|
||||
this.byId.set(var1, var0);
|
||||
this.size++;
|
||||
if (var1 == this.nextId)
|
||||
if(var1 == this.nextId)
|
||||
this.nextId++;
|
||||
}
|
||||
|
||||
@@ -120,19 +120,19 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
|
||||
private int indexOf(K var0, int var1) {
|
||||
int var2;
|
||||
for (var2 = var1; var2 < this.keys.length(); var2++) {
|
||||
if (this.keys.get(var2) == null) {
|
||||
for(var2 = var1; var2 < this.keys.length(); var2++) {
|
||||
if(this.keys.get(var2) == null) {
|
||||
return 0;
|
||||
}
|
||||
if (this.keys.get(var2).equals(var0))
|
||||
if(this.keys.get(var2).equals(var0))
|
||||
return var2;
|
||||
if (this.keys.get(var2) == EMPTY_SLOT)
|
||||
if(this.keys.get(var2) == EMPTY_SLOT)
|
||||
return -1;
|
||||
}
|
||||
for (var2 = 0; var2 < var1; var2++) {
|
||||
if (this.keys.get(var2).equals(var0))
|
||||
for(var2 = 0; var2 < var1; var2++) {
|
||||
if(this.keys.get(var2).equals(var0))
|
||||
return var2;
|
||||
if (this.keys.get(var2) == EMPTY_SLOT)
|
||||
if(this.keys.get(var2) == EMPTY_SLOT)
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
@@ -140,12 +140,12 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
|
||||
private int findEmpty(int var0) {
|
||||
int var1;
|
||||
for (var1 = var0; var1 < this.keys.length(); var1++) {
|
||||
if (this.keys.get(var1) == EMPTY_SLOT)
|
||||
for(var1 = var0; var1 < this.keys.length(); var1++) {
|
||||
if(this.keys.get(var1) == EMPTY_SLOT)
|
||||
return var1;
|
||||
}
|
||||
for (var1 = 0; var1 < var0; var1++) {
|
||||
if (this.keys.get(var1) == EMPTY_SLOT)
|
||||
for(var1 = 0; var1 < var0; var1++) {
|
||||
if(this.keys.get(var1) == EMPTY_SLOT)
|
||||
return var1;
|
||||
}
|
||||
throw new RuntimeException("Overflowed :(");
|
||||
@@ -169,12 +169,12 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
||||
|
||||
public void clear() {
|
||||
|
||||
for (int i = 0; i < Math.max(keys.length(), byId.length()); i++) {
|
||||
if (i < keys.length() - 1) {
|
||||
for(int i = 0; i < Math.max(keys.length(), byId.length()); i++) {
|
||||
if(i < keys.length() - 1) {
|
||||
keys.set(i, null);
|
||||
}
|
||||
|
||||
if (i < byId.length() - 1) {
|
||||
if(i < byId.length() - 1) {
|
||||
byId.set(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class GlobalPalette<T> implements Palette<T> {
|
||||
|
||||
public GlobalPalette(T... f) {
|
||||
IdMapper<T> mapper = new IdMapper<>();
|
||||
for (T i : f) {
|
||||
for(T i : f) {
|
||||
mapper.add(i);
|
||||
}
|
||||
registry = mapper;
|
||||
|
||||
@@ -37,14 +37,14 @@ public class HashMapPalette<T> implements Palette<T> {
|
||||
}
|
||||
|
||||
public int idFor(T var0) {
|
||||
if (var0 == null) {
|
||||
if(var0 == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.values.computeIfAbsent(var0, (k) -> {
|
||||
int newId = id++;
|
||||
|
||||
if (newId >= 1 << this.bits) {
|
||||
if(newId >= 1 << this.bits) {
|
||||
Iris.info(newId + " to...");
|
||||
newId = this.resizeHandler.onResize(this.bits + 1, var0);
|
||||
Iris.info(newId + "..");
|
||||
|
||||
@@ -49,11 +49,11 @@ public class IdMapper<T> implements IdMap<T> {
|
||||
|
||||
public void addMapping(T var0, int var1) {
|
||||
this.tToId.put(var0, Integer.valueOf(var1));
|
||||
while (this.idToT.size() <= var1) {
|
||||
while(this.idToT.size() <= var1) {
|
||||
this.idToT.add(null);
|
||||
}
|
||||
this.idToT.set(var1, var0);
|
||||
if (this.nextId <= var1)
|
||||
if(this.nextId <= var1)
|
||||
this.nextId = var1 + 1;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class IdMapper<T> implements IdMap<T> {
|
||||
}
|
||||
|
||||
public final T byId(int var0) {
|
||||
if (var0 >= 0 && var0 < this.idToT.size()) {
|
||||
if(var0 >= 0 && var0 < this.idToT.size()) {
|
||||
return this.idToT.get(var0);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -35,17 +35,17 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
|
||||
public int idFor(T var0) {
|
||||
int var1;
|
||||
for (var1 = 0; var1 < size; var1++) {
|
||||
if (values.get(var1) == null && var0 == null) {
|
||||
for(var1 = 0; var1 < size; var1++) {
|
||||
if(values.get(var1) == null && var0 == null) {
|
||||
return var1;
|
||||
}
|
||||
|
||||
if (values.get(var1) != null && values.get(var1).equals(var0)) {
|
||||
if(values.get(var1) != null && values.get(var1).equals(var0)) {
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
var1 = size;
|
||||
if (var1 < values.length()) {
|
||||
if(var1 < values.length()) {
|
||||
values.set(var1, var0);
|
||||
size++;
|
||||
return var1;
|
||||
@@ -54,7 +54,7 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
}
|
||||
|
||||
public T valueFor(int var0) {
|
||||
if (var0 >= 0 && var0 < size) {
|
||||
if(var0 >= 0 && var0 < size) {
|
||||
return this.values.get(var0);
|
||||
}
|
||||
return null;
|
||||
@@ -66,7 +66,7 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public void read(List<T> fromList) {
|
||||
for (int i = 0; i < fromList.size(); i++) {
|
||||
for(int i = 0; i < fromList.size(); i++) {
|
||||
values.set(i, fromList.get(i));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public void write(List<T> toList) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
for(int i = 0; i < size; i++) {
|
||||
T v = values.get(i);
|
||||
toList.add(v);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ public class Mth {
|
||||
|
||||
private static final float[] SIN;
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{
|
||||
0, 1, 28, 2, 29, 14, 24, 3, 30, 22,
|
||||
20, 15, 25, 17, 4, 8, 31, 27, 13, 23,
|
||||
21, 19, 16, 7, 26, 12, 18, 6, 11, 5,
|
||||
10, 9};
|
||||
private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[] {
|
||||
0, 1, 28, 2, 29, 14, 24, 3, 30, 22,
|
||||
20, 15, 25, 17, 4, 8, 31, 27, 13, 23,
|
||||
21, 19, 16, 7, 26, 12, 18, 6, 11, 5,
|
||||
10, 9};
|
||||
private static final double ONE_SIXTH = 0.16666666666666666D;
|
||||
private static final int FRAC_EXP = 8;
|
||||
private static final int LUT_SIZE = 257;
|
||||
@@ -55,13 +55,13 @@ public class Mth {
|
||||
|
||||
static {
|
||||
SIN = make(new float[65536], var0 -> {
|
||||
for (int var1 = 0; var1 < var0.length; var1++)
|
||||
for(int var1 = 0; var1 < var0.length; var1++)
|
||||
var0[var1] = (float) Math.sin(var1 * Math.PI * 2.0D / 65536.0D);
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
for (int var0 = 0; var0 < 257; var0++) {
|
||||
for(int var0 = 0; var0 < 257; var0++) {
|
||||
double var1 = var0 / 256.0D;
|
||||
double var3 = Math.asin(var1);
|
||||
COS_TAB[var0] = Math.cos(var3);
|
||||
@@ -132,65 +132,65 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static byte clamp(byte var0, byte var1, byte var2) {
|
||||
if (var0 < var1)
|
||||
if(var0 < var1)
|
||||
return var1;
|
||||
if (var0 > var2)
|
||||
if(var0 > var2)
|
||||
return var2;
|
||||
return var0;
|
||||
}
|
||||
|
||||
public static int clamp(int var0, int var1, int var2) {
|
||||
if (var0 < var1)
|
||||
if(var0 < var1)
|
||||
return var1;
|
||||
if (var0 > var2)
|
||||
if(var0 > var2)
|
||||
return var2;
|
||||
return var0;
|
||||
}
|
||||
|
||||
public static long clamp(long var0, long var2, long var4) {
|
||||
if (var0 < var2)
|
||||
if(var0 < var2)
|
||||
return var2;
|
||||
if (var0 > var4)
|
||||
if(var0 > var4)
|
||||
return var4;
|
||||
return var0;
|
||||
}
|
||||
|
||||
public static float clamp(float var0, float var1, float var2) {
|
||||
if (var0 < var1)
|
||||
if(var0 < var1)
|
||||
return var1;
|
||||
if (var0 > var2)
|
||||
if(var0 > var2)
|
||||
return var2;
|
||||
return var0;
|
||||
}
|
||||
|
||||
public static double clamp(double var0, double var2, double var4) {
|
||||
if (var0 < var2)
|
||||
if(var0 < var2)
|
||||
return var2;
|
||||
if (var0 > var4)
|
||||
if(var0 > var4)
|
||||
return var4;
|
||||
return var0;
|
||||
}
|
||||
|
||||
public static double clampedLerp(double var0, double var2, double var4) {
|
||||
if (var4 < 0.0D)
|
||||
if(var4 < 0.0D)
|
||||
return var0;
|
||||
if (var4 > 1.0D)
|
||||
if(var4 > 1.0D)
|
||||
return var2;
|
||||
return lerp(var4, var0, var2);
|
||||
}
|
||||
|
||||
public static float clampedLerp(float var0, float var1, float var2) {
|
||||
if (var2 < 0.0F)
|
||||
if(var2 < 0.0F)
|
||||
return var0;
|
||||
if (var2 > 1.0F)
|
||||
if(var2 > 1.0F)
|
||||
return var1;
|
||||
return lerp(var2, var0, var1);
|
||||
}
|
||||
|
||||
public static double absMax(double var0, double var2) {
|
||||
if (var0 < 0.0D)
|
||||
if(var0 < 0.0D)
|
||||
var0 = -var0;
|
||||
if (var2 < 0.0D)
|
||||
if(var2 < 0.0D)
|
||||
var2 = -var2;
|
||||
return (var0 > var2) ? var0 : var2;
|
||||
}
|
||||
@@ -200,26 +200,26 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int nextInt(Random var0, int var1, int var2) {
|
||||
if (var1 >= var2)
|
||||
if(var1 >= var2)
|
||||
return var1;
|
||||
return var0.nextInt(var2 - var1 + 1) + var1;
|
||||
}
|
||||
|
||||
public static float nextFloat(Random var0, float var1, float var2) {
|
||||
if (var1 >= var2)
|
||||
if(var1 >= var2)
|
||||
return var1;
|
||||
return var0.nextFloat() * (var2 - var1) + var1;
|
||||
}
|
||||
|
||||
public static double nextDouble(Random var0, double var1, double var3) {
|
||||
if (var1 >= var3)
|
||||
if(var1 >= var3)
|
||||
return var1;
|
||||
return var0.nextDouble() * (var3 - var1) + var1;
|
||||
}
|
||||
|
||||
public static double average(long[] var0) {
|
||||
long var1 = 0L;
|
||||
for (long var6 : var0)
|
||||
for(long var6 : var0)
|
||||
var1 += var6;
|
||||
return var1 / var0.length;
|
||||
}
|
||||
@@ -246,27 +246,27 @@ public class Mth {
|
||||
|
||||
public static int wrapDegrees(int var0) {
|
||||
int var1 = var0 % 360;
|
||||
if (var1 >= 180)
|
||||
if(var1 >= 180)
|
||||
var1 -= 360;
|
||||
if (var1 < -180)
|
||||
if(var1 < -180)
|
||||
var1 += 360;
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static float wrapDegrees(float var0) {
|
||||
float var1 = var0 % 360.0F;
|
||||
if (var1 >= 180.0F)
|
||||
if(var1 >= 180.0F)
|
||||
var1 -= 360.0F;
|
||||
if (var1 < -180.0F)
|
||||
if(var1 < -180.0F)
|
||||
var1 += 360.0F;
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static double wrapDegrees(double var0) {
|
||||
double var2 = var0 % 360.0D;
|
||||
if (var2 >= 180.0D)
|
||||
if(var2 >= 180.0D)
|
||||
var2 -= 360.0D;
|
||||
if (var2 < -180.0D)
|
||||
if(var2 < -180.0D)
|
||||
var2 += 360.0D;
|
||||
return var2;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class Mth {
|
||||
|
||||
public static float approach(float var0, float var1, float var2) {
|
||||
var2 = abs(var2);
|
||||
if (var0 < var1)
|
||||
if(var0 < var1)
|
||||
return clamp(var0 + var2, var0, var1);
|
||||
return clamp(var0 - var2, var1, var0);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class Mth {
|
||||
public static double getDouble(String var0, double var1) {
|
||||
try {
|
||||
return Double.parseDouble(var0);
|
||||
} catch (Throwable var3) {
|
||||
} catch(Throwable var3) {
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
@@ -404,16 +404,16 @@ public class Mth {
|
||||
|
||||
public static double atan2(double var0, double var2) {
|
||||
double var4 = var2 * var2 + var0 * var0;
|
||||
if (Double.isNaN(var4))
|
||||
if(Double.isNaN(var4))
|
||||
return Double.NaN;
|
||||
boolean var6 = (var0 < 0.0D);
|
||||
if (var6)
|
||||
if(var6)
|
||||
var0 = -var0;
|
||||
boolean var7 = (var2 < 0.0D);
|
||||
if (var7)
|
||||
if(var7)
|
||||
var2 = -var2;
|
||||
boolean var8 = (var0 > var2);
|
||||
if (var8) {
|
||||
if(var8) {
|
||||
double d = var2;
|
||||
var2 = var0;
|
||||
var0 = d;
|
||||
@@ -429,11 +429,11 @@ public class Mth {
|
||||
double var20 = var0 * var16 - var2 * var18;
|
||||
double var22 = (6.0D + var20 * var20) * var20 * 0.16666666666666666D;
|
||||
double var24 = var14 + var22;
|
||||
if (var8)
|
||||
if(var8)
|
||||
var24 = 1.5707963267948966D - var24;
|
||||
if (var7)
|
||||
if(var7)
|
||||
var24 = Math.PI - var24;
|
||||
if (var6)
|
||||
if(var6)
|
||||
var24 = -var24;
|
||||
return var24;
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public class Mth {
|
||||
float var5 = var2 * (1.0F - var1);
|
||||
float var6 = var2 * (1.0F - var4 * var1);
|
||||
float var7 = var2 * (1.0F - (1.0F - var4) * var1);
|
||||
switch (var3) {
|
||||
switch(var3) {
|
||||
case 0:
|
||||
var8 = var2;
|
||||
var9 = var7;
|
||||
@@ -545,20 +545,20 @@ public class Mth {
|
||||
|
||||
public static double[] cumulativeSum(double... var0) {
|
||||
float var1 = 0.0F;
|
||||
for (double var5 : var0)
|
||||
for(double var5 : var0)
|
||||
var1 = (float) (var1 + var5);
|
||||
int var2;
|
||||
for (var2 = 0; var2 < var0.length; var2++)
|
||||
for(var2 = 0; var2 < var0.length; var2++)
|
||||
var0[var2] = var0[var2] / var1;
|
||||
for (var2 = 0; var2 < var0.length; var2++)
|
||||
for(var2 = 0; var2 < var0.length; var2++)
|
||||
var0[var2] = ((var2 == 0) ? 0.0D : var0[var2 - 1]) + var0[var2];
|
||||
return var0;
|
||||
}
|
||||
|
||||
public static int getRandomForDistributionIntegral(Random var0, double[] var1) {
|
||||
double var2 = var0.nextDouble();
|
||||
for (int var4 = 0; var4 < var1.length; var4++) {
|
||||
if (var2 < var1[var4])
|
||||
for(int var4 = 0; var4 < var1.length; var4++) {
|
||||
if(var2 < var1[var4])
|
||||
return var4;
|
||||
}
|
||||
return var1.length;
|
||||
@@ -567,10 +567,10 @@ public class Mth {
|
||||
public static double[] binNormalDistribution(double var0, double var2, double var4, int var6, int var7) {
|
||||
double[] var8 = new double[var7 - var6 + 1];
|
||||
int var9 = 0;
|
||||
for (int var10 = var6; var10 <= var7; var10++) {
|
||||
for(int var10 = var6; var10 <= var7; var10++) {
|
||||
var8[var9] = Math.max(0.0D, var0 *
|
||||
|
||||
StrictMath.exp(-(var10 - var4) * (var10 - var4) / 2.0D * var2 * var2));
|
||||
StrictMath.exp(-(var10 - var4) * (var10 - var4) / 2.0D * var2 * var2));
|
||||
var9++;
|
||||
}
|
||||
return var8;
|
||||
@@ -579,11 +579,11 @@ public class Mth {
|
||||
public static double[] binBiModalNormalDistribution(double var0, double var2, double var4, double var6, double var8, double var10, int var12, int var13) {
|
||||
double[] var14 = new double[var13 - var12 + 1];
|
||||
int var15 = 0;
|
||||
for (int var16 = var12; var16 <= var13; var16++) {
|
||||
for(int var16 = var12; var16 <= var13; var16++) {
|
||||
var14[var15] = Math.max(0.0D, var0 *
|
||||
|
||||
StrictMath.exp(-(var16 - var4) * (var16 - var4) / 2.0D * var2 * var2) + var6 *
|
||||
StrictMath.exp(-(var16 - var10) * (var16 - var10) / 2.0D * var8 * var8));
|
||||
StrictMath.exp(-(var16 - var4) * (var16 - var4) / 2.0D * var2 * var2) + var6 *
|
||||
StrictMath.exp(-(var16 - var10) * (var16 - var10) / 2.0D * var8 * var8));
|
||||
var15++;
|
||||
}
|
||||
return var14;
|
||||
@@ -592,7 +592,7 @@ public class Mth {
|
||||
public static double[] binLogDistribution(double var0, double var2, int var4, int var5) {
|
||||
double[] var6 = new double[var5 - var4 + 1];
|
||||
int var7 = 0;
|
||||
for (int var8 = var4; var8 <= var5; var8++) {
|
||||
for(int var8 = var4; var8 <= var5; var8++) {
|
||||
var6[var7] = Math.max(var0 * StrictMath.log(var8) + var2, 0.0D);
|
||||
var7++;
|
||||
}
|
||||
@@ -610,15 +610,15 @@ public class Mth {
|
||||
public static double lerp2(double var0, double var2, double var4, double var6, double var8, double var10) {
|
||||
return lerp(var2,
|
||||
|
||||
lerp(var0, var4, var6),
|
||||
lerp(var0, var8, var10));
|
||||
lerp(var0, var4, var6),
|
||||
lerp(var0, var8, var10));
|
||||
}
|
||||
|
||||
public static double lerp3(double var0, double var2, double var4, double var6, double var8, double var10, double var12, double var14, double var16, double var18, double var20) {
|
||||
return lerp(var4,
|
||||
|
||||
lerp2(var0, var2, var6, var8, var10, var12),
|
||||
lerp2(var0, var2, var14, var16, var18, var20));
|
||||
lerp2(var0, var2, var6, var8, var10, var12),
|
||||
lerp2(var0, var2, var14, var16, var18, var20));
|
||||
}
|
||||
|
||||
public static double smoothstep(double var0) {
|
||||
@@ -630,7 +630,7 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int sign(double var0) {
|
||||
if (var0 == 0.0D)
|
||||
if(var0 == 0.0D)
|
||||
return 0;
|
||||
return (var0 > 0.0D) ? 1 : -1;
|
||||
}
|
||||
@@ -646,18 +646,18 @@ public class Mth {
|
||||
@Deprecated
|
||||
public static float rotlerp(float var0, float var1, float var2) {
|
||||
float var3 = var1 - var0;
|
||||
while (var3 < -180.0F)
|
||||
while(var3 < -180.0F)
|
||||
var3 += 360.0F;
|
||||
while (var3 >= 180.0F)
|
||||
while(var3 >= 180.0F)
|
||||
var3 -= 360.0F;
|
||||
return var0 + var2 * var3;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static float rotWrap(double var0) {
|
||||
while (var0 >= 180.0D)
|
||||
while(var0 >= 180.0D)
|
||||
var0 -= 360.0D;
|
||||
while (var0 < -180.0D)
|
||||
while(var0 < -180.0D)
|
||||
var0 += 360.0D;
|
||||
return (float) var0;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface PaletteType<T> {
|
||||
|
||||
default void writeList(DataOutputStream dos, List<T> list) throws IOException {
|
||||
Varint.writeUnsignedVarInt(list.size(), dos);
|
||||
for (T i : list) {
|
||||
for(T i : list) {
|
||||
writePaletteNode(dos, i);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public interface PaletteType<T> {
|
||||
int v = Varint.readUnsignedVarInt(din);
|
||||
List<T> t = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < v; i++) {
|
||||
for(int i = 0; i < v; i++) {
|
||||
t.add(readPaletteNode(din));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
||||
}
|
||||
|
||||
private void setBits(int var0) {
|
||||
if (var0 == this.bits) {
|
||||
if(var0 == this.bits) {
|
||||
return;
|
||||
}
|
||||
this.bits = var0;
|
||||
if (this.bits <= 4) {
|
||||
if(this.bits <= 4) {
|
||||
this.bits = 4;
|
||||
this.palette = new LinearPalette<>(this.bits, this);
|
||||
} else {
|
||||
@@ -62,9 +62,9 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
||||
BitStorage var2 = this.storage;
|
||||
Palette<T> var3 = this.palette;
|
||||
setBits(var0);
|
||||
for (int var4 = 0; var4 < var2.getSize(); var4++) {
|
||||
for(int var4 = 0; var4 < var2.getSize(); var4++) {
|
||||
T var5 = var3.valueFor(var2.get(var4));
|
||||
if (var5 != null) {
|
||||
if(var5 != null) {
|
||||
set(var4, var5);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
||||
private void set(int var0, T var1) {
|
||||
int var2 = this.palette.idFor(var1);
|
||||
|
||||
if (M.r(0.003)) {
|
||||
if(M.r(0.003)) {
|
||||
Iris.info("ID for " + var1 + " is " + var2 + " Palette: " + palette.getSize());
|
||||
}
|
||||
|
||||
@@ -110,17 +110,17 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
||||
|
||||
public void read(List<T> palette, long[] data) {
|
||||
int var2 = Math.max(4, Mth.ceillog2(palette.size()));
|
||||
if (var2 != this.bits) {
|
||||
if(var2 != this.bits) {
|
||||
setBits(var2);
|
||||
}
|
||||
|
||||
this.palette.read(palette);
|
||||
int var3 = data.length * 64 / 4096;
|
||||
if (var3 == this.bits) {
|
||||
if(var3 == this.bits) {
|
||||
System.arraycopy(data, 0, this.storage.getRaw(), 0, data.length);
|
||||
} else {
|
||||
BitStorage var4 = new BitStorage(var3, 4096, data);
|
||||
for (int var5 = 0; var5 < 4096; var5++) {
|
||||
for(int var5 = 0; var5 < 4096; var5++) {
|
||||
this.storage.set(var5, var4.get(var5));
|
||||
}
|
||||
}
|
||||
@@ -131,9 +131,9 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
||||
T var4 = null;
|
||||
int var5 = 0;
|
||||
int[] var6 = new int[4096];
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
for(int i = 0; i < 4096; i++) {
|
||||
T t = get(i);
|
||||
if (t != var4) {
|
||||
if(t != var4) {
|
||||
var4 = t;
|
||||
var5 = var3.idFor(t);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public class PalettedContainer<T> implements PaletteResize<T> {
|
||||
var3.write(toList);
|
||||
int var8 = Math.max(4, Mth.ceillog2(toList.size()));
|
||||
BitStorage var9 = new BitStorage(var8, 4096);
|
||||
for (int var10 = 0; var10 < var6.length; var10++) {
|
||||
for(int var10 = 0; var10 < var6.length; var10++) {
|
||||
var9.set(var10, var6[var10]);
|
||||
}
|
||||
return var9.getRaw();
|
||||
|
||||
@@ -31,12 +31,12 @@ public class DecreeContext {
|
||||
}
|
||||
|
||||
public static void touch(VolmitSender c) {
|
||||
synchronized (context) {
|
||||
synchronized(context) {
|
||||
context.put(Thread.currentThread(), c);
|
||||
|
||||
if (cl.flip()) {
|
||||
for (Thread i : context.k()) {
|
||||
if (!i.isAlive()) {
|
||||
if(cl.flip()) {
|
||||
for(Thread i : context.k()) {
|
||||
if(!i.isAlive()) {
|
||||
context.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ public interface DecreeContextHandler<T> {
|
||||
|
||||
try {
|
||||
Iris.initialize("com.volmit.iris.util.decree.context").forEach((i)
|
||||
-> contextHandlers.put(((DecreeContextHandler<?>) i).getType(), (DecreeContextHandler<?>) i));
|
||||
} catch (Throwable e) {
|
||||
-> contextHandlers.put(((DecreeContextHandler<?>) i).getType(), (DecreeContextHandler<?>) i));
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public interface DecreeExecutor {
|
||||
}
|
||||
|
||||
default Engine engine() {
|
||||
if (sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) {
|
||||
if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) {
|
||||
PlatformChunkGenerator gen = IrisToolbelt.access(sender().player().getWorld());
|
||||
if (gen != null) {
|
||||
if(gen != null) {
|
||||
return gen.getEngine();
|
||||
}
|
||||
}
|
||||
@@ -46,14 +46,14 @@ public interface DecreeExecutor {
|
||||
}
|
||||
|
||||
default PlatformChunkGenerator access() {
|
||||
if (sender().isPlayer()) {
|
||||
if(sender().isPlayer()) {
|
||||
return IrisToolbelt.access(world());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
default World world() {
|
||||
if (sender().isPlayer()) {
|
||||
if(sender().isPlayer()) {
|
||||
return sender().player().getWorld();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DecreeNode {
|
||||
this.instance = instance;
|
||||
this.method = method;
|
||||
this.decree = method.getDeclaredAnnotation(Decree.class);
|
||||
if (decree == null) {
|
||||
if(decree == null) {
|
||||
throw new RuntimeException("Cannot instantiate DecreeNode on method " + method.getName() + " in " + method.getDeclaringClass().getCanonicalName() + " not annotated by @Decree");
|
||||
}
|
||||
}
|
||||
@@ -50,9 +50,9 @@ public class DecreeNode {
|
||||
KList<DecreeParameter> required = new KList<>();
|
||||
KList<DecreeParameter> optional = new KList<>();
|
||||
|
||||
for (Parameter i : method.getParameters()) {
|
||||
for(Parameter i : method.getParameters()) {
|
||||
DecreeParameter p = new DecreeParameter(i);
|
||||
if (p.isRequired()) {
|
||||
if(p.isRequired()) {
|
||||
required.add(p);
|
||||
} else {
|
||||
optional.add(p);
|
||||
@@ -80,8 +80,8 @@ public class DecreeNode {
|
||||
KList<String> d = new KList<>();
|
||||
d.add(getName());
|
||||
|
||||
for (String i : decree.aliases()) {
|
||||
if (i.isEmpty()) {
|
||||
for(String i : decree.aliases()) {
|
||||
if(i.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,12 @@ public enum DecreeOrigin {
|
||||
/**
|
||||
* Check if the origin is valid for a sender
|
||||
*
|
||||
* @param sender The sender to check
|
||||
* @param sender
|
||||
* The sender to check
|
||||
* @return True if valid for origin
|
||||
*/
|
||||
public boolean validFor(VolmitSender sender) {
|
||||
if (sender.isPlayer()) {
|
||||
if(sender.isPlayer()) {
|
||||
return this.equals(PLAYER) || this.equals(BOTH);
|
||||
} else {
|
||||
return this.equals(CONSOLE) || this.equals(BOTH);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DecreeParameter {
|
||||
public DecreeParameter(Parameter parameter) {
|
||||
this.parameter = parameter;
|
||||
this.param = parameter.getDeclaredAnnotation(Param.class);
|
||||
if (param == null) {
|
||||
if(param == null) {
|
||||
throw new RuntimeException("Cannot instantiate DecreeParameter on " + parameter.getName() + " in method " + parameter.getDeclaringExecutable().getName() + "(...) in class " + parameter.getDeclaringExecutable().getDeclaringClass().getCanonicalName() + " not annotated by @Param");
|
||||
}
|
||||
}
|
||||
@@ -44,12 +44,12 @@ public class DecreeParameter {
|
||||
public DecreeParameterHandler<?> getHandler() {
|
||||
return handlerCache.aquire(() -> {
|
||||
try {
|
||||
if (param.customHandler().equals(DummyHandler.class)) {
|
||||
if(param.customHandler().equals(DummyHandler.class)) {
|
||||
return DecreeSystem.getHandler(getType());
|
||||
}
|
||||
|
||||
return param.customHandler().getConstructor().newInstance();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public class DecreeParameter {
|
||||
public KList<String> getNames() {
|
||||
KList<String> d = new KList<>();
|
||||
|
||||
for (String i : param.aliases()) {
|
||||
if (i.isEmpty()) {
|
||||
for(String i : param.aliases()) {
|
||||
if(i.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DecreeParameter {
|
||||
KList<?> ff = getHandler().getPossibilities();
|
||||
ff = ff != null ? ff : new KList<>();
|
||||
KList<String> f = ff.convert((i) -> getHandler().toStringForce(i));
|
||||
if (f.isEmpty()) {
|
||||
if(f.isEmpty()) {
|
||||
f = new KList<>();
|
||||
f.add(getHandler().getRandomDefault());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public interface DecreeParameterHandler<T> {
|
||||
/**
|
||||
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
|
||||
*
|
||||
* @param t The input of the designated type to convert to a String
|
||||
* @param t
|
||||
* The input of the designated type to convert to a String
|
||||
* @return The resulting string
|
||||
*/
|
||||
String toString(T t);
|
||||
@@ -46,7 +47,8 @@ public interface DecreeParameterHandler<T> {
|
||||
/**
|
||||
* Forces conversion to the designated type before converting to a string using {@link #toString(T t)}
|
||||
*
|
||||
* @param t The object to convert to string (that should be of this type)
|
||||
* @param t
|
||||
* The object to convert to string (that should be of this type)
|
||||
* @return The resulting string.
|
||||
*/
|
||||
default String toStringForce(Object t) {
|
||||
@@ -56,9 +58,11 @@ public interface DecreeParameterHandler<T> {
|
||||
/**
|
||||
* Should parse a String into the designated type
|
||||
*
|
||||
* @param in The string to parse
|
||||
* @param in
|
||||
* The string to parse
|
||||
* @return The value extracted from the string, of the designated type
|
||||
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
* @throws DecreeParsingException
|
||||
* Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
*/
|
||||
default T parse(String in) throws DecreeParsingException {
|
||||
return parse(in, false);
|
||||
@@ -67,17 +71,21 @@ public interface DecreeParameterHandler<T> {
|
||||
/**
|
||||
* Should parse a String into the designated type. You can force it to not throw a whichexception
|
||||
*
|
||||
* @param in The string to parse
|
||||
* @param force force an option instead of throwing decreewhich
|
||||
* @param in
|
||||
* The string to parse
|
||||
* @param force
|
||||
* force an option instead of throwing decreewhich
|
||||
* @return The value extracted from the string, of the designated type
|
||||
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
* @throws DecreeParsingException
|
||||
* Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
*/
|
||||
T parse(String in, boolean force) throws DecreeParsingException;
|
||||
|
||||
/**
|
||||
* Returns whether a certain type is supported by this handler<br>
|
||||
*
|
||||
* @param type The type to check
|
||||
* @param type
|
||||
* The type to check
|
||||
* @return True if supported, false if not
|
||||
*/
|
||||
boolean supports(Class<?> type);
|
||||
@@ -85,11 +93,12 @@ public interface DecreeParameterHandler<T> {
|
||||
/**
|
||||
* The possible entries for the inputted string (support for autocomplete on partial entries)
|
||||
*
|
||||
* @param input The inputted string to check against
|
||||
* @param input
|
||||
* The inputted string to check against
|
||||
* @return A {@link KList} of possibilities
|
||||
*/
|
||||
default KList<T> getPossibilities(String input) {
|
||||
if (input.trim().isEmpty()) {
|
||||
if(input.trim().isEmpty()) {
|
||||
KList<T> f = getPossibilities();
|
||||
return f == null ? new KList<>() : f;
|
||||
}
|
||||
@@ -98,23 +107,23 @@ public interface DecreeParameterHandler<T> {
|
||||
KList<T> possible = getPossibilities();
|
||||
KList<T> matches = new KList<>();
|
||||
|
||||
if (possible == null || possible.isEmpty()) {
|
||||
if(possible == null || possible.isEmpty()) {
|
||||
return matches;
|
||||
}
|
||||
|
||||
if (input.isEmpty()) {
|
||||
if(input.isEmpty()) {
|
||||
return getPossibilities();
|
||||
}
|
||||
|
||||
KList<String> converted = possible.convert(v -> toString(v).trim());
|
||||
|
||||
for (int i = 0; i < converted.size(); i++) {
|
||||
for(int i = 0; i < converted.size(); i++) {
|
||||
String g = converted.get(i);
|
||||
// if
|
||||
// G == I or
|
||||
// I in G or
|
||||
// G in I
|
||||
if (g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase())) {
|
||||
if(g.equalsIgnoreCase(input) || g.toLowerCase().contains(input.toLowerCase()) || input.toLowerCase().contains(g.toLowerCase())) {
|
||||
matches.add(possible.get(i));
|
||||
}
|
||||
}
|
||||
@@ -130,28 +139,28 @@ public interface DecreeParameterHandler<T> {
|
||||
double multiplier = 1;
|
||||
String in = g.get();
|
||||
boolean valid = true;
|
||||
while (valid) {
|
||||
while(valid) {
|
||||
boolean trim = false;
|
||||
if (in.toLowerCase().endsWith("k")) {
|
||||
if(in.toLowerCase().endsWith("k")) {
|
||||
multiplier *= 1000;
|
||||
trim = true;
|
||||
} else if (in.toLowerCase().endsWith("m")) {
|
||||
} else if(in.toLowerCase().endsWith("m")) {
|
||||
multiplier *= 1000000;
|
||||
trim = true;
|
||||
} else if (in.toLowerCase().endsWith("h")) {
|
||||
} else if(in.toLowerCase().endsWith("h")) {
|
||||
multiplier *= 100;
|
||||
trim = true;
|
||||
} else if (in.toLowerCase().endsWith("c")) {
|
||||
} else if(in.toLowerCase().endsWith("c")) {
|
||||
multiplier *= 16;
|
||||
trim = true;
|
||||
} else if (in.toLowerCase().endsWith("r")) {
|
||||
} else if(in.toLowerCase().endsWith("r")) {
|
||||
multiplier *= (16 * 32);
|
||||
trim = true;
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (trim) {
|
||||
if(trim) {
|
||||
in = in.substring(0, in.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,20 +47,20 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
static KList<String> enhanceArgs(String[] args, boolean trim) {
|
||||
KList<String> a = new KList<>();
|
||||
|
||||
if (args.length == 0) {
|
||||
if(args.length == 0) {
|
||||
return a;
|
||||
}
|
||||
|
||||
StringBuilder flat = new StringBuilder();
|
||||
for (String i : args) {
|
||||
if (trim) {
|
||||
if (i.trim().isEmpty()) {
|
||||
for(String i : args) {
|
||||
if(trim) {
|
||||
if(i.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
flat.append(" ").append(i.trim());
|
||||
} else {
|
||||
if (i.endsWith(" ")) {
|
||||
if(i.endsWith(" ")) {
|
||||
flat.append(" ").append(i.trim()).append(" ");
|
||||
}
|
||||
}
|
||||
@@ -70,29 +70,29 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
StringBuilder arg = new StringBuilder();
|
||||
boolean quoting = false;
|
||||
|
||||
for (int x = 0; x < flat.length(); x++) {
|
||||
for(int x = 0; x < flat.length(); x++) {
|
||||
char i = flat.charAt(x);
|
||||
char j = x < flat.length() - 1 ? flat.charAt(x + 1) : i;
|
||||
boolean hasNext = x < flat.length();
|
||||
|
||||
if (i == ' ' && !quoting) {
|
||||
if (!arg.toString().trim().isEmpty() && trim) {
|
||||
if(i == ' ' && !quoting) {
|
||||
if(!arg.toString().trim().isEmpty() && trim) {
|
||||
a.add(arg.toString().trim());
|
||||
arg = new StringBuilder();
|
||||
}
|
||||
} else if (i == '"') {
|
||||
if (!quoting && (arg.length() == 0)) {
|
||||
} else if(i == '"') {
|
||||
if(!quoting && (arg.length() == 0)) {
|
||||
quoting = true;
|
||||
} else if (quoting) {
|
||||
} else if(quoting) {
|
||||
quoting = false;
|
||||
|
||||
if (hasNext && j == ' ') {
|
||||
if (!arg.toString().trim().isEmpty() && trim) {
|
||||
if(hasNext && j == ' ') {
|
||||
if(!arg.toString().trim().isEmpty() && trim) {
|
||||
a.add(arg.toString().trim());
|
||||
arg = new StringBuilder();
|
||||
}
|
||||
} else if (!hasNext) {
|
||||
if (!arg.toString().trim().isEmpty() && trim) {
|
||||
} else if(!hasNext) {
|
||||
if(!arg.toString().trim().isEmpty() && trim) {
|
||||
a.add(arg.toString().trim());
|
||||
arg = new StringBuilder();
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
if (!arg.toString().trim().isEmpty() && trim) {
|
||||
if(!arg.toString().trim().isEmpty() && trim) {
|
||||
a.add(arg.toString().trim());
|
||||
}
|
||||
|
||||
@@ -113,12 +113,13 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
/**
|
||||
* Get the handler for the specified type
|
||||
*
|
||||
* @param type The type to handle
|
||||
* @param type
|
||||
* The type to handle
|
||||
* @return The corresponding {@link DecreeParameterHandler}, or null
|
||||
*/
|
||||
static DecreeParameterHandler<?> getHandler(Class<?> type) {
|
||||
for (DecreeParameterHandler<?> i : handlers) {
|
||||
if (i.supports(type)) {
|
||||
for(DecreeParameterHandler<?> i : handlers) {
|
||||
if(i.supports(type)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -128,8 +129,6 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
|
||||
/**
|
||||
* The root class to start command searching from
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
VirtualDecreeCommand getRoot();
|
||||
|
||||
@@ -145,8 +144,8 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
KList<String> v = getRoot().tabComplete(enhanced, enhanced.toString(" "));
|
||||
v.removeDuplicates();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if(sender instanceof Player) {
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f));
|
||||
}
|
||||
}
|
||||
@@ -156,16 +155,16 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!sender.hasPermission("iris.all")) {
|
||||
if(!sender.hasPermission("iris.all")) {
|
||||
sender.sendMessage("You lack the Permission 'iris.all'");
|
||||
return true;
|
||||
}
|
||||
|
||||
J.aBukkit(() -> {
|
||||
if (!call(new VolmitSender(sender), args)) {
|
||||
if(!call(new VolmitSender(sender), args)) {
|
||||
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if (sender instanceof Player) {
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if(sender instanceof Player) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 0.25f);
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 0.2f, 0.45f);
|
||||
}
|
||||
@@ -173,8 +172,8 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter {
|
||||
|
||||
sender.sendMessage(C.RED + "Unknown Iris Command");
|
||||
} else {
|
||||
if (IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if (sender instanceof Player) {
|
||||
if(IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
if(sender instanceof Player) {
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_AMETHYST_CLUSTER_BREAK, 0.77f, 1.65f);
|
||||
((Player) sender).playSound(((Player) sender).getLocation(), Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, 0.125f, 2.99f);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ public @interface Decree {
|
||||
DecreeOrigin origin() default DecreeOrigin.BOTH;
|
||||
|
||||
/**
|
||||
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))<br>
|
||||
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of
|
||||
* method))<br>
|
||||
* Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})<br>
|
||||
* If someone uses /plugin foo and you specify alias="f" here, /plugin f will do the exact same.
|
||||
*/
|
||||
|
||||
@@ -53,7 +53,8 @@ public @interface Param {
|
||||
String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))<br>
|
||||
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of
|
||||
* method))<br>
|
||||
* Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})<br>
|
||||
* If someone uses /plugin foo bar=baz and you specify alias="b" here, /plugin foo b=baz will do the exact same.
|
||||
*/
|
||||
|
||||
@@ -29,9 +29,9 @@ public class BiomeContextHandler implements DecreeContextHandler<IrisBiome> {
|
||||
}
|
||||
|
||||
public IrisBiome handle(VolmitSender sender) {
|
||||
if (sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
if(sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getBiomeOrMantle(sender.player().getLocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ public class DimensionContextHandler implements DecreeContextHandler<IrisDimensi
|
||||
}
|
||||
|
||||
public IrisDimension handle(VolmitSender sender) {
|
||||
if (sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
if(sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getDimension();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ public class GeneratorContextHandler implements DecreeContextHandler<IrisGenerat
|
||||
|
||||
@Override
|
||||
public IrisGenerator handle(VolmitSender sender) {
|
||||
if (sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
if(sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
Engine engine = IrisToolbelt.access(sender.player().getWorld()).getEngine();
|
||||
return engine.getData().getGeneratorLoader().load(engine.getBiome(sender.player().getLocation()).getGenerators().getRandom().getGenerator());
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ public class RegionContextHandler implements DecreeContextHandler<IrisRegion> {
|
||||
}
|
||||
|
||||
public IrisRegion handle(VolmitSender sender) {
|
||||
if (sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
if(sender.isPlayer()
|
||||
&& IrisToolbelt.isIrisWorld(sender.player().getWorld())
|
||||
&& IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) {
|
||||
return IrisToolbelt.access(sender.player().getWorld()).getEngine().getRegion(sender.player().getLocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
|
||||
KMap<String, IrisBiome> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) {
|
||||
for(IrisBiome j : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -56,18 +56,18 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
|
||||
|
||||
@Override
|
||||
public IrisBiome parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
if(in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisBiome> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Biome \"" + in + "\"");
|
||||
}
|
||||
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
|
||||
KList<BlockVector> vx = new KList<>();
|
||||
VolmitSender s = DecreeContext.get();
|
||||
|
||||
if (s.isPlayer()) {
|
||||
if(s.isPlayer()) {
|
||||
vx.add(s.player().getLocation().toVector().toBlockVector());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
|
||||
|
||||
@Override
|
||||
public String toString(BlockVector v) {
|
||||
if (v.getY() == 0) {
|
||||
if(v.getY() == 0) {
|
||||
return Form.f(v.getBlockX(), 2) + "," + Form.f(v.getBlockZ(), 2);
|
||||
}
|
||||
|
||||
@@ -55,43 +55,43 @@ public class BlockVectorHandler implements DecreeParameterHandler<BlockVector> {
|
||||
@Override
|
||||
public BlockVector parse(String in, boolean force) throws DecreeParsingException {
|
||||
try {
|
||||
if (in.contains(",")) {
|
||||
if(in.contains(",")) {
|
||||
String[] comp = in.split("\\Q,\\E");
|
||||
|
||||
if (comp.length == 2) {
|
||||
if(comp.length == 2) {
|
||||
return new BlockVector(Integer.parseInt(comp[0].trim()), 0, Integer.parseInt(comp[1].trim()));
|
||||
} else if (comp.length == 3) {
|
||||
} else if(comp.length == 3) {
|
||||
return new BlockVector(Integer.parseInt(comp[0].trim()),
|
||||
Integer.parseInt(comp[1].trim()),
|
||||
Integer.parseInt(comp[2].trim()));
|
||||
Integer.parseInt(comp[1].trim()),
|
||||
Integer.parseInt(comp[2].trim()));
|
||||
} else {
|
||||
throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3.");
|
||||
}
|
||||
} else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
|
||||
if (!DecreeContext.get().isPlayer()) {
|
||||
} else if(in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
|
||||
if(!DecreeContext.get().isPlayer()) {
|
||||
throw new DecreeParsingException("You cannot specify me,self,here as a console.");
|
||||
}
|
||||
|
||||
return DecreeContext.get().player().getLocation().toVector().toBlockVector();
|
||||
} else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
|
||||
if (!DecreeContext.get().isPlayer()) {
|
||||
} else if(in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
|
||||
if(!DecreeContext.get().isPlayer()) {
|
||||
throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console.");
|
||||
}
|
||||
|
||||
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector().toBlockVector();
|
||||
} else if (in.trim().toLowerCase().startsWith("player:")) {
|
||||
} else if(in.trim().toLowerCase().startsWith("player:")) {
|
||||
String v = in.trim().split("\\Q:\\E")[1];
|
||||
|
||||
|
||||
KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v);
|
||||
|
||||
if (px != null && px.isNotEmpty()) {
|
||||
if(px != null && px.isNotEmpty()) {
|
||||
return ((Player) px.get(0)).getLocation().toVector().toBlockVector();
|
||||
} else if (px == null || px.isEmpty()) {
|
||||
} else if(px == null || px.isEmpty()) {
|
||||
throw new DecreeParsingException("Cannot find player: " + v);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ public class BooleanHandler implements DecreeParameterHandler<Boolean> {
|
||||
@Override
|
||||
public Boolean parse(String in, boolean force) throws DecreeParsingException {
|
||||
try {
|
||||
if (in.equals("null") || in.equals("other") || in.equals("flip")) {
|
||||
if(in.equals("null") || in.equals("other") || in.equals("flip")) {
|
||||
return null;
|
||||
}
|
||||
return Boolean.parseBoolean(in);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse boolean \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ByteHandler implements DecreeParameterHandler<Byte> {
|
||||
public Byte parse(String in, boolean force) throws DecreeParsingException {
|
||||
try {
|
||||
return Byte.parseByte(in);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse byte \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ package com.volmit.iris.util.decree.handlers;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisCave;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPool;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
@@ -37,10 +35,10 @@ public class CaveHandler implements DecreeParameterHandler<IrisCave> {
|
||||
KMap<String, IrisCave> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisCave j : data.getCaveLoader().loadAll(data.getCaveLoader().getPossibleKeys())) {
|
||||
for(IrisCave j : data.getCaveLoader().loadAll(data.getCaveLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -58,16 +56,17 @@ public class CaveHandler implements DecreeParameterHandler<IrisCave> {
|
||||
|
||||
@Override
|
||||
public IrisCave parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
if(in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisCave> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Cave \"" + in + "\"");
|
||||
}try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Cave\"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
|
||||
KMap<String, IrisDimension> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) {
|
||||
for(IrisDimension j : data.getDimensionLoader().loadAll(data.getDimensionLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -58,11 +58,12 @@ public class DimensionHandler implements DecreeParameterHandler<IrisDimension> {
|
||||
public IrisDimension parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisDimension> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Dimension \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class DoubleHandler implements DecreeParameterHandler<Double> {
|
||||
AtomicReference<String> r = new AtomicReference<>(in);
|
||||
double m = getMultiplier(r);
|
||||
return Double.parseDouble(r.get()) * m;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse double \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
|
||||
KMap<String, IrisEntity> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) {
|
||||
for(IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
|
||||
/**
|
||||
* Converting the type back to a string (inverse of the {@link #parse(String) parse} method)
|
||||
*
|
||||
* @param entity The input of the designated type to convert to a String
|
||||
* @param entity
|
||||
* The input of the designated type to convert to a String
|
||||
* @return The resulting string
|
||||
*/
|
||||
@Override
|
||||
@@ -69,19 +70,22 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
|
||||
/**
|
||||
* Should parse a String into the designated type
|
||||
*
|
||||
* @param in The string to parse
|
||||
* @param in
|
||||
* The string to parse
|
||||
* @return The value extracted from the string, of the designated type
|
||||
* @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
* @throws DecreeParsingException
|
||||
* Thrown when the parsing fails (ex: "oop" translated to an integer throws this)
|
||||
*/
|
||||
@Override
|
||||
public IrisEntity parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisEntity> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Entity \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
@@ -89,7 +93,8 @@ public class EntityHandler implements DecreeParameterHandler<IrisEntity> {
|
||||
/**
|
||||
* Returns whether a certain type is supported by this handler<br>
|
||||
*
|
||||
* @param type The type to check
|
||||
* @param type
|
||||
* The type to check
|
||||
* @return True if supported, false if not
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class FloatHandler implements DecreeParameterHandler<Float> {
|
||||
AtomicReference<String> r = new AtomicReference<>(in);
|
||||
double m = getMultiplier(r);
|
||||
return (float) (Float.parseFloat(r.get()) * m);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse float \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
|
||||
KMap<String, IrisGenerator> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) {
|
||||
for(IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -58,11 +58,12 @@ public class GeneratorHandler implements DecreeParameterHandler<IrisGenerator> {
|
||||
public IrisGenerator parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisGenerator> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Generator \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class IntegerHandler implements DecreeParameterHandler<Integer> {
|
||||
AtomicReference<String> r = new AtomicReference<>(in);
|
||||
double m = getMultiplier(r);
|
||||
return (int) (Integer.valueOf(r.get()).doubleValue() * m);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse integer \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class JigsawPieceHandler implements DecreeParameterHandler<IrisJigsawPiec
|
||||
KMap<String, IrisJigsawPiece> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisJigsawPiece j : data.getJigsawPieceLoader().loadAll(data.getJigsawPieceLoader().getPossibleKeys())) {
|
||||
for(IrisJigsawPiece j : data.getJigsawPieceLoader().loadAll(data.getJigsawPieceLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -56,16 +56,17 @@ public class JigsawPieceHandler implements DecreeParameterHandler<IrisJigsawPiec
|
||||
|
||||
@Override
|
||||
public IrisJigsawPiece parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
if(in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisJigsawPiece> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Jigsaw Piece \"" + in + "\"");
|
||||
}try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Jigsaw Piece \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.engine.object.IrisJigsawPool;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@@ -36,10 +35,10 @@ public class JigsawPoolHandler implements DecreeParameterHandler<IrisJigsawPool>
|
||||
KMap<String, IrisJigsawPool> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisJigsawPool j : data.getJigsawPoolLoader().loadAll(data.getJigsawPoolLoader().getPossibleKeys())) {
|
||||
for(IrisJigsawPool j : data.getJigsawPoolLoader().loadAll(data.getJigsawPoolLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -57,16 +56,17 @@ public class JigsawPoolHandler implements DecreeParameterHandler<IrisJigsawPool>
|
||||
|
||||
@Override
|
||||
public IrisJigsawPool parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
if(in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisJigsawPool> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Jigsaw Pool \"" + in + "\"");
|
||||
}try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Jigsaw Pool \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class JigsawStructureHandler implements DecreeParameterHandler<IrisJigsaw
|
||||
KMap<String, IrisJigsawStructure> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisJigsawStructure j : data.getJigsawStructureLoader().loadAll(data.getJigsawStructureLoader().getPossibleKeys())) {
|
||||
for(IrisJigsawStructure j : data.getJigsawStructureLoader().loadAll(data.getJigsawStructureLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -56,16 +56,17 @@ public class JigsawStructureHandler implements DecreeParameterHandler<IrisJigsaw
|
||||
|
||||
@Override
|
||||
public IrisJigsawStructure parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
if(in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisJigsawStructure> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Jigsaw Structure \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Jigsaw Structure \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LongHandler implements DecreeParameterHandler<Long> {
|
||||
AtomicReference<String> r = new AtomicReference<>(in);
|
||||
double m = getMultiplier(r);
|
||||
return (long) (Long.valueOf(r.get()).doubleValue() * m);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse long \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,12 @@ public class PlayerHandler implements DecreeParameterHandler<Player> {
|
||||
public Player parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<Player> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Player \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
||||
KMap<String, IrisRegion> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) {
|
||||
for(IrisRegion j : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -56,16 +56,17 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
|
||||
|
||||
@Override
|
||||
public IrisRegion parse(String in, boolean force) throws DecreeParsingException {
|
||||
if (in.equals("null")) {
|
||||
if(in.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
KList<IrisRegion> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Region \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
||||
KMap<String, IrisScript> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) {
|
||||
for(IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
@@ -58,11 +58,12 @@ public class ScriptHandler implements DecreeParameterHandler<IrisScript> {
|
||||
public IrisScript parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<IrisScript> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Script \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ShortHandler implements DecreeParameterHandler<Short> {
|
||||
AtomicReference<String> r = new AtomicReference<>(in);
|
||||
double m = getMultiplier(r);
|
||||
return (short) (Short.valueOf(r.get()).doubleValue() * m);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to parse short \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,6 @@ public class StringHandler implements DecreeParameterHandler<String> {
|
||||
@Override
|
||||
public String getRandomDefault() {
|
||||
return new KList<String>().qadd("text").qadd("string")
|
||||
.qadd("blah").qadd("derp").qadd("yolo").getRandom();
|
||||
.qadd("blah").qadd("derp").qadd("yolo").getRandom();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.bukkit.util.Vector;
|
||||
public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
private static final KList<String> randoms = new KList<>(
|
||||
"here",
|
||||
"0,0,0",
|
||||
"0,0",
|
||||
"look",
|
||||
"player:<name>"
|
||||
"here",
|
||||
"0,0,0",
|
||||
"0,0",
|
||||
"look",
|
||||
"player:<name>"
|
||||
);
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
@Override
|
||||
public String toString(Vector v) {
|
||||
if (v.getY() == 0) {
|
||||
if(v.getY() == 0) {
|
||||
return Form.f(v.getX(), 2) + "," + Form.f(v.getZ(), 2);
|
||||
}
|
||||
|
||||
@@ -56,43 +56,43 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
@Override
|
||||
public Vector parse(String in, boolean force) throws DecreeParsingException {
|
||||
try {
|
||||
if (in.contains(",")) {
|
||||
if(in.contains(",")) {
|
||||
String[] comp = in.split("\\Q,\\E");
|
||||
|
||||
if (comp.length == 2) {
|
||||
if(comp.length == 2) {
|
||||
return new BlockVector(Double.parseDouble(comp[0].trim()), 0, Double.parseDouble(comp[1].trim()));
|
||||
} else if (comp.length == 3) {
|
||||
} else if(comp.length == 3) {
|
||||
return new BlockVector(Double.parseDouble(comp[0].trim()),
|
||||
Double.parseDouble(comp[1].trim()),
|
||||
Double.parseDouble(comp[2].trim()));
|
||||
Double.parseDouble(comp[1].trim()),
|
||||
Double.parseDouble(comp[2].trim()));
|
||||
} else {
|
||||
throw new DecreeParsingException("Could not parse components for vector. You have " + comp.length + " components. Expected 2 or 3.");
|
||||
}
|
||||
} else if (in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
|
||||
if (!DecreeContext.get().isPlayer()) {
|
||||
} else if(in.equalsIgnoreCase("here") || in.equalsIgnoreCase("me") || in.equalsIgnoreCase("self")) {
|
||||
if(!DecreeContext.get().isPlayer()) {
|
||||
throw new DecreeParsingException("You cannot specify me,self,here as a console.");
|
||||
}
|
||||
|
||||
return DecreeContext.get().player().getLocation().toVector();
|
||||
} else if (in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
|
||||
if (!DecreeContext.get().isPlayer()) {
|
||||
} else if(in.equalsIgnoreCase("look") || in.equalsIgnoreCase("cursor") || in.equalsIgnoreCase("crosshair")) {
|
||||
if(!DecreeContext.get().isPlayer()) {
|
||||
throw new DecreeParsingException("You cannot specify look,cursor,crosshair as a console.");
|
||||
}
|
||||
|
||||
return DecreeContext.get().player().getTargetBlockExact(256, FluidCollisionMode.NEVER).getLocation().toVector();
|
||||
} else if (in.trim().toLowerCase().startsWith("player:")) {
|
||||
} else if(in.trim().toLowerCase().startsWith("player:")) {
|
||||
String v = in.trim().split("\\Q:\\E")[1];
|
||||
|
||||
|
||||
KList<?> px = DecreeSystem.getHandler(Player.class).getPossibilities(v);
|
||||
|
||||
if (px != null && px.isNotEmpty()) {
|
||||
if(px != null && px.isNotEmpty()) {
|
||||
return ((Player) px.get(0)).getLocation().toVector();
|
||||
} else if (px == null || px.isEmpty()) {
|
||||
} else if(px == null || px.isEmpty()) {
|
||||
throw new DecreeParsingException("Cannot find player: " + v);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to get Vector for \"" + in + "\" because of an uncaught exception: " + e);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public class WorldHandler implements DecreeParameterHandler<World> {
|
||||
@Override
|
||||
public KList<World> getPossibilities() {
|
||||
KList<World> options = new KList<>();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
if (!world.getName().toLowerCase().startsWith("iris/")) {
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
if(!world.getName().toLowerCase().startsWith("iris/")) {
|
||||
options.add(world);
|
||||
}
|
||||
}
|
||||
@@ -47,11 +47,12 @@ public class WorldHandler implements DecreeParameterHandler<World> {
|
||||
public World parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<World> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find World \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class ObjectHandler implements DecreeParameterHandler<String> {
|
||||
KList<String> p = new KList<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
for(File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
IrisData data = IrisData.get(i);
|
||||
p.add(data.getObjectLoader().getPossibleKeys());
|
||||
}
|
||||
@@ -52,11 +52,12 @@ public class ObjectHandler implements DecreeParameterHandler<String> {
|
||||
public String parse(String in, boolean force) throws DecreeParsingException {
|
||||
KList<String> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
if(options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Object \"" + in + "\"");
|
||||
} try {
|
||||
}
|
||||
try {
|
||||
return options.stream().filter((i) -> toString(i).equalsIgnoreCase(in)).collect(Collectors.toList()).get(0);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
throw new DecreeParsingException("Unable to filter which Biome \"" + in + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.volmit.iris.util.decree.virtual;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.service.CommandSVC;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
@@ -28,7 +27,6 @@ import com.volmit.iris.util.decree.DecreeContext;
|
||||
import com.volmit.iris.util.decree.DecreeContextHandler;
|
||||
import com.volmit.iris.util.decree.DecreeNode;
|
||||
import com.volmit.iris.util.decree.DecreeParameter;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.annotations.Decree;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.format.C;
|
||||
@@ -38,17 +36,11 @@ import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@@ -57,13 +49,13 @@ public class VirtualDecreeCommand {
|
||||
private final VirtualDecreeCommand parent;
|
||||
private final KList<VirtualDecreeCommand> nodes;
|
||||
private final DecreeNode node;
|
||||
String[] gradients = new String[]{
|
||||
"<gradient:#f5bc42:#45b32d>",
|
||||
"<gradient:#1ed43f:#1ecbd4>",
|
||||
"<gradient:#1e2ad4:#821ed4>",
|
||||
"<gradient:#d41ea7:#611ed4>",
|
||||
"<gradient:#1ed473:#1e55d4>",
|
||||
"<gradient:#6ad41e:#9a1ed4>"
|
||||
String[] gradients = new String[] {
|
||||
"<gradient:#f5bc42:#45b32d>",
|
||||
"<gradient:#1ed43f:#1ecbd4>",
|
||||
"<gradient:#1e2ad4:#821ed4>",
|
||||
"<gradient:#d41ea7:#611ed4>",
|
||||
"<gradient:#1ed473:#1e55d4>",
|
||||
"<gradient:#6ad41e:#9a1ed4>"
|
||||
};
|
||||
private ChronoLatch cl = new ChronoLatch(1000);
|
||||
|
||||
@@ -81,19 +73,19 @@ public class VirtualDecreeCommand {
|
||||
public static VirtualDecreeCommand createRoot(VirtualDecreeCommand parent, Object v) throws Throwable {
|
||||
VirtualDecreeCommand c = new VirtualDecreeCommand(v.getClass(), parent, new KList<>(), null);
|
||||
|
||||
for (Field i : v.getClass().getDeclaredFields()) {
|
||||
if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isTransient(i.getModifiers()) || Modifier.isVolatile(i.getModifiers())) {
|
||||
for(Field i : v.getClass().getDeclaredFields()) {
|
||||
if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isTransient(i.getModifiers()) || Modifier.isVolatile(i.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!i.getType().isAnnotationPresent(Decree.class)) {
|
||||
if(!i.getType().isAnnotationPresent(Decree.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
i.setAccessible(true);
|
||||
Object childRoot = i.get(v);
|
||||
|
||||
if (childRoot == null) {
|
||||
if(childRoot == null) {
|
||||
childRoot = i.getType().getConstructor().newInstance();
|
||||
i.set(v, childRoot);
|
||||
}
|
||||
@@ -101,12 +93,12 @@ public class VirtualDecreeCommand {
|
||||
c.getNodes().add(createRoot(c, childRoot));
|
||||
}
|
||||
|
||||
for (Method i : v.getClass().getDeclaredMethods()) {
|
||||
if (Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers())) {
|
||||
for(Method i : v.getClass().getDeclaredMethods()) {
|
||||
if(Modifier.isStatic(i.getModifiers()) || Modifier.isFinal(i.getModifiers()) || Modifier.isPrivate(i.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!i.isAnnotationPresent(Decree.class)) {
|
||||
if(!i.isAnnotationPresent(Decree.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -119,11 +111,11 @@ public class VirtualDecreeCommand {
|
||||
public void cacheAll() {
|
||||
VolmitSender sender = new VolmitSender(new CommandDummy());
|
||||
|
||||
if (isNode()) {
|
||||
if(isNode()) {
|
||||
sender.sendDecreeHelpNode(this);
|
||||
}
|
||||
|
||||
for (VirtualDecreeCommand j : nodes) {
|
||||
for(VirtualDecreeCommand j : nodes) {
|
||||
j.cacheAll();
|
||||
}
|
||||
}
|
||||
@@ -132,7 +124,7 @@ public class VirtualDecreeCommand {
|
||||
KList<String> n = new KList<>();
|
||||
VirtualDecreeCommand cursor = this;
|
||||
|
||||
while (cursor.getParent() != null) {
|
||||
while(cursor.getParent() != null) {
|
||||
cursor = cursor.getParent();
|
||||
n.add(cursor.getName());
|
||||
}
|
||||
@@ -157,15 +149,15 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
public KList<String> getNames() {
|
||||
if (isNode()) {
|
||||
if(isNode()) {
|
||||
return getNode().getNames();
|
||||
}
|
||||
|
||||
Decree dc = getType().getDeclaredAnnotation(Decree.class);
|
||||
KList<String> d = new KList<>();
|
||||
d.add(dc.name());
|
||||
for (String i : dc.aliases()) {
|
||||
if (i.isEmpty()) {
|
||||
for(String i : dc.aliases()) {
|
||||
if(i.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -189,27 +181,27 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
private boolean invokeTabComplete(KList<String> args, KList<Integer> skip, KList<String> tabs, String raw) {
|
||||
if (isStudio() && !IrisSettings.get().getStudio().isStudio()) {
|
||||
if(isStudio() && !IrisSettings.get().getStudio().isStudio()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isNode()) {
|
||||
if(isNode()) {
|
||||
tab(args, tabs);
|
||||
skip.add(hashCode());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.isEmpty()) {
|
||||
if(args.isEmpty()) {
|
||||
tab(args, tabs);
|
||||
return true;
|
||||
}
|
||||
|
||||
String head = args.get(0);
|
||||
|
||||
if (args.size() > 1 || head.endsWith(" ")) {
|
||||
if(args.size() > 1 || head.endsWith(" ")) {
|
||||
VirtualDecreeCommand match = matchNode(head, skip);
|
||||
|
||||
if (match != null) {
|
||||
if(match != null) {
|
||||
args.pop();
|
||||
return match.invokeTabComplete(args, skip, tabs, raw);
|
||||
}
|
||||
@@ -228,18 +220,18 @@ public class VirtualDecreeCommand {
|
||||
Runnable la = () -> {
|
||||
|
||||
};
|
||||
for (String a : args) {
|
||||
for(String a : args) {
|
||||
la.run();
|
||||
last = a;
|
||||
la = () -> {
|
||||
if (isNode()) {
|
||||
if(isNode()) {
|
||||
String sea = a.contains("=") ? a.split("\\Q=\\E")[0] : a;
|
||||
sea = sea.trim();
|
||||
|
||||
searching:
|
||||
for (DecreeParameter i : getNode().getParameters()) {
|
||||
for (String m : i.getNames()) {
|
||||
if (m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase())) {
|
||||
for(DecreeParameter i : getNode().getParameters()) {
|
||||
for(String m : i.getNames()) {
|
||||
if(m.equalsIgnoreCase(sea) || m.toLowerCase().contains(sea.toLowerCase()) || sea.toLowerCase().contains(m.toLowerCase())) {
|
||||
ignore.add(i);
|
||||
continue searching;
|
||||
}
|
||||
@@ -249,37 +241,37 @@ public class VirtualDecreeCommand {
|
||||
};
|
||||
}
|
||||
|
||||
if (last != null) {
|
||||
if (isNode()) {
|
||||
for (DecreeParameter i : getNode().getParameters()) {
|
||||
if (ignore.contains(i)) {
|
||||
if(last != null) {
|
||||
if(isNode()) {
|
||||
for(DecreeParameter i : getNode().getParameters()) {
|
||||
if(ignore.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int g = 0;
|
||||
|
||||
if (last.contains("=")) {
|
||||
if(last.contains("=")) {
|
||||
String[] vv = last.trim().split("\\Q=\\E");
|
||||
String vx = vv.length == 2 ? vv[1] : "";
|
||||
for (String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v))) {
|
||||
for(String f : i.getHandler().getPossibilities(vx).convert((v) -> i.getHandler().toStringForce(v))) {
|
||||
g++;
|
||||
tabs.add(i.getName() + "=" + f);
|
||||
}
|
||||
} else {
|
||||
for (String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v))) {
|
||||
for(String f : i.getHandler().getPossibilities("").convert((v) -> i.getHandler().toStringForce(v))) {
|
||||
g++;
|
||||
tabs.add(i.getName() + "=" + f);
|
||||
}
|
||||
}
|
||||
|
||||
if (g == 0) {
|
||||
if(g == 0) {
|
||||
tabs.add(i.getName() + "=");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (VirtualDecreeCommand i : getNodes()) {
|
||||
for(VirtualDecreeCommand i : getNodes()) {
|
||||
String m = i.getName();
|
||||
if (m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase())) {
|
||||
if(m.equalsIgnoreCase(last) || m.toLowerCase().contains(last.toLowerCase()) || last.toLowerCase().contains(m.toLowerCase())) {
|
||||
tabs.addAll(i.getNames());
|
||||
}
|
||||
}
|
||||
@@ -289,8 +281,11 @@ public class VirtualDecreeCommand {
|
||||
|
||||
/**
|
||||
* Maps the input a player typed to the parameters of this command
|
||||
* @param sender The sender
|
||||
* @param in The input
|
||||
*
|
||||
* @param sender
|
||||
* The sender
|
||||
* @param in
|
||||
* The input
|
||||
* @return A map of all the parameter names and their values
|
||||
*/
|
||||
private KMap<String, Object> map(VolmitSender sender, KList<String> in) {
|
||||
@@ -301,7 +296,7 @@ public class VirtualDecreeCommand {
|
||||
KList<String> knownInputs = new KList<>(in.stream().filter(s -> s.contains("=")).collect(Collectors.toList()));
|
||||
|
||||
//Loop known inputs
|
||||
for (int x = 0; x < knownInputs.size(); x++) {
|
||||
for(int x = 0; x < knownInputs.size(); x++) {
|
||||
String stringParam = knownInputs.get(x);
|
||||
int original = in.indexOf(stringParam);
|
||||
|
||||
@@ -311,9 +306,9 @@ public class VirtualDecreeCommand {
|
||||
DecreeParameter param = null;
|
||||
|
||||
//Find decree parameter from string param
|
||||
for (DecreeParameter j : getNode().getParameters()) {
|
||||
for (String k : j.getNames()) {
|
||||
if (k.equalsIgnoreCase(key)) {
|
||||
for(DecreeParameter j : getNode().getParameters()) {
|
||||
for(String k : j.getNames()) {
|
||||
if(k.equalsIgnoreCase(key)) {
|
||||
param = j;
|
||||
break;
|
||||
}
|
||||
@@ -321,10 +316,10 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
//If it failed, see if we can find it by checking if the names contain the param
|
||||
if (param == null) {
|
||||
for (DecreeParameter j : getNode().getParameters()) {
|
||||
for (String k : j.getNames()) {
|
||||
if (k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase())) {
|
||||
if(param == null) {
|
||||
for(DecreeParameter j : getNode().getParameters()) {
|
||||
for(String k : j.getNames()) {
|
||||
if(k.toLowerCase().contains(key.toLowerCase()) || key.toLowerCase().contains(k.toLowerCase())) {
|
||||
param = j;
|
||||
break;
|
||||
}
|
||||
@@ -333,7 +328,7 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
//Still failed to find, error them
|
||||
if (param == null) {
|
||||
if(param == null) {
|
||||
Iris.debug("Can't find parameter key for " + key + "=" + value + " in " + getPath());
|
||||
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + key);
|
||||
unknownInputs.add(value); //Add the value to the unknowns and see if we can assume it later
|
||||
@@ -344,7 +339,7 @@ public class VirtualDecreeCommand {
|
||||
|
||||
try {
|
||||
data.put(key, param.getHandler().parse(value, nowhich.contains(original))); //Parse and put
|
||||
} catch (DecreeParsingException e) {
|
||||
} catch(DecreeParsingException e) {
|
||||
Iris.debug("Can't parse parameter value for " + key + "=" + value + " in " + getPath() + " using handler " + param.getHandler().getClass().getSimpleName());
|
||||
sender.sendMessage(C.RED + "Cannot convert \"" + value + "\" into a " + param.getType().getSimpleName());
|
||||
e.printStackTrace();
|
||||
@@ -356,7 +351,7 @@ public class VirtualDecreeCommand {
|
||||
KList<DecreeParameter> decreeParameters = new KList<>(getNode().getParameters().stream().filter(param -> !data.contains(param.getName())).collect(Collectors.toList()));
|
||||
|
||||
//Loop Unknown inputs
|
||||
for (int x = 0; x < unknownInputs.size(); x++) {
|
||||
for(int x = 0; x < unknownInputs.size(); x++) {
|
||||
String stringParam = unknownInputs.get(x);
|
||||
int original = in.indexOf(stringParam);
|
||||
try {
|
||||
@@ -364,13 +359,13 @@ public class VirtualDecreeCommand {
|
||||
|
||||
try {
|
||||
data.put(par.getName(), par.getHandler().parse(stringParam, nowhich.contains(original)));
|
||||
} catch (DecreeParsingException e) {
|
||||
} catch(DecreeParsingException e) {
|
||||
Iris.debug("Can't parse parameter value for " + par.getName() + "=" + stringParam + " in " + getPath() + " using handler " + par.getHandler().getClass().getSimpleName());
|
||||
sender.sendMessage(C.RED + "Cannot convert \"" + stringParam + "\" into a " + par.getType().getSimpleName());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
sender.sendMessage(C.YELLOW + "Unknown Parameter: " + stringParam + " (" + Form.getNumberSuffixThStRd(x + 1) + " argument)");
|
||||
}
|
||||
}
|
||||
@@ -383,15 +378,15 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
public boolean invoke(VolmitSender sender, KList<String> args, KList<Integer> skip) {
|
||||
if (isStudio() && !IrisSettings.get().getStudio().isStudio()) {
|
||||
if(isStudio() && !IrisSettings.get().getStudio().isStudio()) {
|
||||
sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)");
|
||||
return false;
|
||||
}
|
||||
|
||||
Iris.debug("@ " + getPath() + " with " + args.toString(", "));
|
||||
if (isNode()) {
|
||||
if(isNode()) {
|
||||
Iris.debug("Invoke " + getPath() + "(" + args.toString(",") + ") at ");
|
||||
if (invokeNode(sender, map(sender, args))) {
|
||||
if(invokeNode(sender, map(sender, args))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -399,13 +394,13 @@ public class VirtualDecreeCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.isEmpty()) {
|
||||
if(args.isEmpty()) {
|
||||
sender.sendDecreeHelp(this);
|
||||
|
||||
return true;
|
||||
} else if (args.size() == 1) {
|
||||
for (String i : args) {
|
||||
if (i.startsWith("help=")) {
|
||||
} else if(args.size() == 1) {
|
||||
for(String i : args) {
|
||||
if(i.startsWith("help=")) {
|
||||
sender.sendDecreeHelp(this, Integer.parseInt(i.split("\\Q=\\E")[1]) - 1);
|
||||
return true;
|
||||
}
|
||||
@@ -415,7 +410,7 @@ public class VirtualDecreeCommand {
|
||||
String head = args.get(0);
|
||||
VirtualDecreeCommand match = matchNode(head, skip);
|
||||
|
||||
if (match != null) {
|
||||
if(match != null) {
|
||||
args.pop();
|
||||
return match.invoke(sender, args, skip);
|
||||
}
|
||||
@@ -426,33 +421,33 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
private boolean invokeNode(VolmitSender sender, KMap<String, Object> map) {
|
||||
if (map == null) {
|
||||
if(map == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object[] params = new Object[getNode().getMethod().getParameterCount()];
|
||||
int vm = 0;
|
||||
for (DecreeParameter i : getNode().getParameters()) {
|
||||
for(DecreeParameter i : getNode().getParameters()) {
|
||||
Object value = map.get(i.getName());
|
||||
|
||||
try {
|
||||
if (value == null && i.hasDefault()) {
|
||||
if(value == null && i.hasDefault()) {
|
||||
value = i.getDefaultValue();
|
||||
}
|
||||
} catch (DecreeParsingException e) {
|
||||
} catch(DecreeParsingException e) {
|
||||
Iris.debug("Can't parse parameter value for " + i.getName() + "=" + i.getParam().defaultValue() + " in " + getPath() + " using handler " + i.getHandler().getClass().getSimpleName());
|
||||
sender.sendMessage(C.RED + "Cannot convert \"" + i.getParam().defaultValue() + "\" into a " + i.getType().getSimpleName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender.isPlayer() && i.isContextual() && value == null) {
|
||||
if(sender.isPlayer() && i.isContextual() && value == null) {
|
||||
Iris.debug("Contextual!");
|
||||
DecreeContextHandler<?> ch = DecreeContextHandler.contextHandlers.get(i.getType());
|
||||
|
||||
if (ch != null) {
|
||||
if(ch != null) {
|
||||
value = ch.handle(sender);
|
||||
|
||||
if (value != null) {
|
||||
if(value != null) {
|
||||
Iris.debug("Parameter \"" + i.getName() + "\" derived a value of \"" + i.getHandler().toStringForce(value) + "\" from " + ch.getClass().getSimpleName());
|
||||
} else {
|
||||
Iris.debug("Parameter \"" + i.getName() + "\" could not derive a value from \"" + ch.getClass().getSimpleName());
|
||||
@@ -462,16 +457,16 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (i.hasDefault() && value == null) {
|
||||
if(i.hasDefault() && value == null) {
|
||||
try {
|
||||
Iris.debug("Parameter \"" + i.getName() + "\" is using default value \"" + i.getParam().defaultValue() + "\"");
|
||||
value = i.getDefaultValue();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (i.isRequired() && value == null) {
|
||||
if(i.isRequired() && value == null) {
|
||||
sender.sendMessage(C.RED + "Missing argument \"" + i.getName() + "\" (" + i.getType().getSimpleName() + ") as the " + Form.getNumberSuffixThStRd(vm + 1) + " argument.");
|
||||
sender.sendDecreeHelpNode(this);
|
||||
return false;
|
||||
@@ -487,13 +482,13 @@ public class VirtualDecreeCommand {
|
||||
DecreeContext.touch(sender);
|
||||
getNode().getMethod().setAccessible(true);
|
||||
getNode().getMethod().invoke(getNode().getInstance(), params);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Failed to execute <INSERT REAL NODE HERE>"); // TODO:
|
||||
}
|
||||
};
|
||||
|
||||
if (getNode().isSync()) {
|
||||
if(getNode().isSync()) {
|
||||
J.s(rx);
|
||||
} else {
|
||||
rx.run();
|
||||
@@ -505,19 +500,19 @@ public class VirtualDecreeCommand {
|
||||
public KList<VirtualDecreeCommand> matchAllNodes(String in) {
|
||||
KList<VirtualDecreeCommand> g = new KList<>();
|
||||
|
||||
if (in.trim().isEmpty()) {
|
||||
if(in.trim().isEmpty()) {
|
||||
g.addAll(nodes);
|
||||
return g;
|
||||
}
|
||||
|
||||
for (VirtualDecreeCommand i : nodes) {
|
||||
if (i.matches(in)) {
|
||||
for(VirtualDecreeCommand i : nodes) {
|
||||
if(i.matches(in)) {
|
||||
g.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (VirtualDecreeCommand i : nodes) {
|
||||
if (i.deepMatches(in)) {
|
||||
for(VirtualDecreeCommand i : nodes) {
|
||||
if(i.deepMatches(in)) {
|
||||
g.add(i);
|
||||
}
|
||||
}
|
||||
@@ -527,26 +522,26 @@ public class VirtualDecreeCommand {
|
||||
}
|
||||
|
||||
public VirtualDecreeCommand matchNode(String in, KList<Integer> skip) {
|
||||
if (in.trim().isEmpty()) {
|
||||
if(in.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (VirtualDecreeCommand i : nodes) {
|
||||
if (skip.contains(i.hashCode())) {
|
||||
for(VirtualDecreeCommand i : nodes) {
|
||||
if(skip.contains(i.hashCode())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i.matches(in)) {
|
||||
if(i.matches(in)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (VirtualDecreeCommand i : nodes) {
|
||||
if (skip.contains(i.hashCode())) {
|
||||
for(VirtualDecreeCommand i : nodes) {
|
||||
if(skip.contains(i.hashCode())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i.deepMatches(in)) {
|
||||
if(i.deepMatches(in)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -557,8 +552,8 @@ public class VirtualDecreeCommand {
|
||||
public boolean deepMatches(String in) {
|
||||
KList<String> a = getNames();
|
||||
|
||||
for (String i : a) {
|
||||
if (i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase())) {
|
||||
for(String i : a) {
|
||||
if(i.toLowerCase().contains(in.toLowerCase()) || in.toLowerCase().contains(i.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -573,7 +568,7 @@ public class VirtualDecreeCommand {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof VirtualDecreeCommand)) {
|
||||
if(!(obj instanceof VirtualDecreeCommand)) {
|
||||
return false;
|
||||
}
|
||||
return this.hashCode() == obj.hashCode();
|
||||
@@ -582,8 +577,8 @@ public class VirtualDecreeCommand {
|
||||
public boolean matches(String in) {
|
||||
KList<String> a = getNames();
|
||||
|
||||
for (String i : a) {
|
||||
if (i.equalsIgnoreCase(in)) {
|
||||
for(String i : a) {
|
||||
if(i.equalsIgnoreCase(in)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ public enum C {
|
||||
* need to dynamically convert colour codes from your custom format.
|
||||
*/
|
||||
public static final char COLOR_CHAR = '\u00A7';
|
||||
public final static C[] COLORCYCLE = new C[]{C.GOLD, C.YELLOW, C.GREEN, C.AQUA, C.LIGHT_PURPLE, C.AQUA, C.GREEN, C.YELLOW, C.GOLD, C.RED};
|
||||
public final static C[] COLORCYCLE = new C[] {C.GOLD, C.YELLOW, C.GREEN, C.AQUA, C.LIGHT_PURPLE, C.AQUA, C.GREEN, C.YELLOW, C.GOLD, C.RED};
|
||||
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]");
|
||||
private final static C[] COLORS = new C[]{C.BLACK, C.DARK_BLUE, C.DARK_GREEN, C.DARK_AQUA, C.DARK_RED, C.DARK_PURPLE, C.GOLD, C.GRAY, C.DARK_GRAY, C.BLUE, C.GREEN, C.AQUA, C.RED, C.LIGHT_PURPLE, C.YELLOW, C.WHITE};
|
||||
private final static C[] COLORS = new C[] {C.BLACK, C.DARK_BLUE, C.DARK_GREEN, C.DARK_AQUA, C.DARK_RED, C.DARK_PURPLE, C.GOLD, C.GRAY, C.DARK_GRAY, C.BLUE, C.GREEN, C.AQUA, C.RED, C.LIGHT_PURPLE, C.YELLOW, C.WHITE};
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private final static Map<Integer, C> BY_ID = new HashMap<>();
|
||||
private final static Map<Character, C> BY_CHAR = new HashMap<>();
|
||||
@@ -316,7 +316,7 @@ public enum C {
|
||||
}
|
||||
|
||||
static {
|
||||
for (C color : values()) {
|
||||
for(C color : values()) {
|
||||
BY_ID.put(color.intCode, color);
|
||||
BY_CHAR.put(color.code, color);
|
||||
}
|
||||
@@ -345,15 +345,15 @@ public enum C {
|
||||
this.token = token.equalsIgnoreCase("^") ? "<" + name().toLowerCase(Locale.ROOT) + ">" : token;
|
||||
this.intCode = intCode;
|
||||
this.isFormat = isFormat;
|
||||
this.toString = new String(new char[]{COLOR_CHAR, code});
|
||||
this.toString = new String(new char[] {COLOR_CHAR, code});
|
||||
}
|
||||
|
||||
public static float[] spin(float[] c, int shift) {
|
||||
return new float[]{spin(c[0], shift), spinc(c[1], shift), spinc(c[2], shift)};
|
||||
return new float[] {spin(c[0], shift), spinc(c[1], shift), spinc(c[2], shift)};
|
||||
}
|
||||
|
||||
public static float[] spin(float[] c, int a, int b, int d) {
|
||||
return new float[]{spin(c[0], a), spinc(c[1], b), spinc(c[2], d)};
|
||||
return new float[] {spin(c[0], a), spinc(c[1], b), spinc(c[2], d)};
|
||||
}
|
||||
|
||||
public static float spin(float c, int shift) {
|
||||
@@ -385,21 +385,21 @@ public enum C {
|
||||
StringBuilder b = new StringBuilder();
|
||||
boolean c = false;
|
||||
|
||||
for (char i : msg.toCharArray()) {
|
||||
if (c) {
|
||||
for(char i : msg.toCharArray()) {
|
||||
if(c) {
|
||||
c = false;
|
||||
|
||||
C o = C.getByChar(i);
|
||||
|
||||
if (hrad != 0 || srad != 0 || vrad != 0) {
|
||||
if (pulse > 0) {
|
||||
if(hrad != 0 || srad != 0 || vrad != 0) {
|
||||
if(pulse > 0) {
|
||||
b.append(VolmitSender.pulse(spinToHex(o, hrad, srad, vrad), spinToHex(o, -hrad, -srad, -vrad), pulse));
|
||||
} else {
|
||||
b.append("<gradient:")
|
||||
.append(spinToHex(o, hrad, srad, vrad))
|
||||
.append(":")
|
||||
.append(spinToHex(o, -hrad, -srad, -vrad))
|
||||
.append(">");
|
||||
.append(spinToHex(o, hrad, srad, vrad))
|
||||
.append(":")
|
||||
.append(spinToHex(o, -hrad, -srad, -vrad))
|
||||
.append(">");
|
||||
}
|
||||
} else {
|
||||
b.append(C.getByChar(i).token);
|
||||
@@ -408,7 +408,7 @@ public enum C {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == C.COLOR_CHAR) {
|
||||
if(i == C.COLOR_CHAR) {
|
||||
c = true;
|
||||
continue;
|
||||
}
|
||||
@@ -426,7 +426,8 @@ public enum C {
|
||||
/**
|
||||
* Gets the color represented by the specified color code
|
||||
*
|
||||
* @param code Code to check
|
||||
* @param code
|
||||
* Code to check
|
||||
* @return Associative {@link org.bukkit.ChatColor} with the given code, or null
|
||||
* if it doesn't exist
|
||||
*/
|
||||
@@ -434,7 +435,7 @@ public enum C {
|
||||
try {
|
||||
C c = BY_CHAR.get(code);
|
||||
return c == null ? C.WHITE : c;
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
Iris.reportError(e);
|
||||
return C.WHITE;
|
||||
}
|
||||
@@ -443,7 +444,8 @@ public enum C {
|
||||
/**
|
||||
* Gets the color represented by the specified color code
|
||||
*
|
||||
* @param code Code to check
|
||||
* @param code
|
||||
* Code to check
|
||||
* @return Associative {@link org.bukkit.ChatColor} with the given code, or null
|
||||
* if it doesn't exist
|
||||
*/
|
||||
@@ -453,7 +455,7 @@ public enum C {
|
||||
Validate.isTrue(code.length() > 0, "Code must have at least one char");
|
||||
|
||||
return BY_CHAR.get(code.charAt(0));
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
Iris.reportError(e);
|
||||
return C.WHITE;
|
||||
}
|
||||
@@ -462,11 +464,12 @@ public enum C {
|
||||
/**
|
||||
* Strips the given message of all color codes
|
||||
*
|
||||
* @param input String to strip of color
|
||||
* @param input
|
||||
* String to strip of color
|
||||
* @return A copy of the input string, without any coloring
|
||||
*/
|
||||
public static String stripColor(final String input) {
|
||||
if (input == null) {
|
||||
if(input == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -476,11 +479,12 @@ public enum C {
|
||||
/**
|
||||
* DyeColor to ChatColor
|
||||
*
|
||||
* @param dclr the dye color
|
||||
* @param dclr
|
||||
* the dye color
|
||||
* @return the color
|
||||
*/
|
||||
public static C dyeToChat(DyeColor dclr) {
|
||||
if (dyeChatMap.containsKey(dclr)) {
|
||||
if(dyeChatMap.containsKey(dclr)) {
|
||||
return dyeChatMap.get(dclr);
|
||||
}
|
||||
|
||||
@@ -488,8 +492,8 @@ public enum C {
|
||||
}
|
||||
|
||||
public static DyeColor chatToDye(ChatColor color) {
|
||||
for (Map.Entry<DyeColor, C> entry : dyeChatMap.entrySet()) {
|
||||
if (entry.getValue().toString().equals(color.toString())) {
|
||||
for(Map.Entry<DyeColor, C> entry : dyeChatMap.entrySet()) {
|
||||
if(entry.getValue().toString().equals(color.toString())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
@@ -499,7 +503,7 @@ public enum C {
|
||||
|
||||
@SuppressWarnings("unlikely-arg-type")
|
||||
public static String chatToHex(C clr) {
|
||||
if (chatHexMap.containsKey(clr)) {
|
||||
if(chatHexMap.containsKey(clr)) {
|
||||
return chatHexMap.get(clr);
|
||||
}
|
||||
|
||||
@@ -507,7 +511,7 @@ public enum C {
|
||||
}
|
||||
|
||||
public static String dyeToHex(DyeColor clr) {
|
||||
if (dyeHexMap.containsKey(clr)) {
|
||||
if(dyeHexMap.containsKey(clr)) {
|
||||
return dyeHexMap.get(clr);
|
||||
}
|
||||
|
||||
@@ -515,20 +519,20 @@ public enum C {
|
||||
}
|
||||
|
||||
public static Color hexToColor(String hex) {
|
||||
if (hex.startsWith("#")) {
|
||||
if(hex.startsWith("#")) {
|
||||
hex = hex.substring(1);
|
||||
}
|
||||
|
||||
if (hex.contains("x")) {
|
||||
if(hex.contains("x")) {
|
||||
hex = hex.substring(hex.indexOf("x"));
|
||||
}
|
||||
|
||||
if (hex.length() != 6 && hex.length() != 3) {
|
||||
if(hex.length() != 6 && hex.length() != 3) {
|
||||
return null;
|
||||
}
|
||||
int sz = hex.length() / 3, mult = 1 << ((2 - sz) * 4), x = 0;
|
||||
|
||||
for (int i = 0, z = 0; z < hex.length(); ++i, z += sz) {
|
||||
for(int i = 0, z = 0; z < hex.length(); ++i, z += sz) {
|
||||
x |= (mult * Integer.parseInt(hex.substring(z, z + sz), 16)) << (i * 8);
|
||||
}
|
||||
|
||||
@@ -537,13 +541,13 @@ public enum C {
|
||||
|
||||
public static Color rgbToColor(String rgb) {
|
||||
String[] parts = rgb.split("[^0-9]+");
|
||||
if (parts.length < 3) {
|
||||
if(parts.length < 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = 0, i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for(i = 0; i < 3; ++i) {
|
||||
x |= Integer.parseInt(parts[i]) << (i * 8);
|
||||
}
|
||||
|
||||
@@ -555,13 +559,13 @@ public enum C {
|
||||
|
||||
str.append("<table><tr><td>Chat Color</td><td>Color</td></tr>");
|
||||
|
||||
for (Map.Entry<C, String> e : chatHexMap.entrySet()) {
|
||||
for(Map.Entry<C, String> e : chatHexMap.entrySet()) {
|
||||
str.append(String.format("<tr><td style='color: %2$s;'>%1$s</td>" + "<td style='color: %2$s;'>Test String</td></tr>", e.getKey().name(), e.getValue()));
|
||||
}
|
||||
|
||||
str.append("</table>");
|
||||
str.append("<table><tr><td>Dye Color</td><td>Color</td></tr>");
|
||||
for (Map.Entry<DyeColor, String> e : dyeHexMap.entrySet()) {
|
||||
for(Map.Entry<DyeColor, String> e : dyeHexMap.entrySet()) {
|
||||
str.append(String.format("<tr><td style='color: %2$s;'>%1$s</td>" + "<td style='color: %2$s;'>Test String</td></tr>", e.getKey().name(), e.getValue()));
|
||||
}
|
||||
|
||||
@@ -576,18 +580,20 @@ public enum C {
|
||||
* alternate color code character will only be replaced if it is immediately
|
||||
* followed by 0-9, A-F, a-f, K-O, k-o, R or r.
|
||||
*
|
||||
* @param altColorChar The alternate color code character to replace. Ex: {@literal &}
|
||||
* @param textToTranslate Text containing the alternate color code character.
|
||||
* @param altColorChar
|
||||
* The alternate color code character to replace. Ex: {@literal &}
|
||||
* @param textToTranslate
|
||||
* Text containing the alternate color code character.
|
||||
* @return Text containing the ChatColor.COLOR_CODE color code character.
|
||||
*/
|
||||
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
|
||||
if (textToTranslate == null) {
|
||||
if(textToTranslate == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
char[] b = textToTranslate.toCharArray();
|
||||
for (int i = 0; i < b.length - 1; i++) {
|
||||
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
|
||||
for(int i = 0; i < b.length - 1; i++) {
|
||||
if(b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
|
||||
b[i] = C.COLOR_CHAR;
|
||||
b[i + 1] = Character.toLowerCase(b[i + 1]);
|
||||
}
|
||||
@@ -596,8 +602,8 @@ public enum C {
|
||||
}
|
||||
|
||||
public static C fromItemMeta(byte c) {
|
||||
for (C i : C.values()) {
|
||||
if (i.getItemMeta() == c) {
|
||||
for(C i : C.values()) {
|
||||
if(i.getItemMeta() == c) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -612,7 +618,8 @@ public enum C {
|
||||
/**
|
||||
* Gets the ChatColors used at the end of the given input string.
|
||||
*
|
||||
* @param input Input string to retrieve the colors from.
|
||||
* @param input
|
||||
* Input string to retrieve the colors from.
|
||||
* @return Any remaining ChatColors to pass onto the next line.
|
||||
*/
|
||||
public static String getLastColors(String input) {
|
||||
@@ -620,17 +627,17 @@ public enum C {
|
||||
int length = input.length();
|
||||
|
||||
// Search backwards from the end as it is faster
|
||||
for (int index = length - 1; index > -1; index--) {
|
||||
for(int index = length - 1; index > -1; index--) {
|
||||
char section = input.charAt(index);
|
||||
if (section == COLOR_CHAR && index < length - 1) {
|
||||
if(section == COLOR_CHAR && index < length - 1) {
|
||||
char c = input.charAt(index + 1);
|
||||
C color = getByChar(c);
|
||||
|
||||
if (color != null) {
|
||||
if(color != null) {
|
||||
result.insert(0, color);
|
||||
|
||||
// Once we find a color or reset we can stop searching
|
||||
if (color.isColor() || color.equals(RESET)) {
|
||||
if(color.isColor() || color.equals(RESET)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -699,7 +706,7 @@ public enum C {
|
||||
}
|
||||
|
||||
public byte getMeta() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case AQUA -> (byte) 11;
|
||||
case BLACK -> (byte) 0;
|
||||
case BLUE, DARK_AQUA -> (byte) 9;
|
||||
@@ -721,7 +728,7 @@ public enum C {
|
||||
}
|
||||
|
||||
public byte getItemMeta() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case AQUA, DARK_AQUA -> (byte) 9;
|
||||
case BLACK -> (byte) 15;
|
||||
case BLUE -> (byte) 3;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -77,13 +77,13 @@ public class MemoryMonitor {
|
||||
|
||||
private void sample() {
|
||||
long used = getVMUse();
|
||||
if (usedMemory == -1) {
|
||||
if(usedMemory == -1) {
|
||||
usedMemory = used;
|
||||
garbageMemory = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (used < usedMemory) {
|
||||
if(used < usedMemory) {
|
||||
usedMemory = used;
|
||||
} else {
|
||||
garbageMemory = used - usedMemory;
|
||||
@@ -91,7 +91,7 @@ public class MemoryMonitor {
|
||||
|
||||
long g = garbageMemory - garbageLast;
|
||||
|
||||
if (g >= 0) {
|
||||
if(g >= 0) {
|
||||
garbageBin += g;
|
||||
garbageLast = garbageMemory;
|
||||
} else {
|
||||
@@ -99,8 +99,8 @@ public class MemoryMonitor {
|
||||
garbageLast = 0;
|
||||
}
|
||||
|
||||
if (cl.flip()) {
|
||||
if (garbageMemory > 0) {
|
||||
if(cl.flip()) {
|
||||
if(garbageMemory > 0) {
|
||||
pressure = garbageBin;
|
||||
garbageBin = 0;
|
||||
} else {
|
||||
@@ -117,7 +117,7 @@ public class MemoryMonitor {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (looper != null) {
|
||||
if(looper != null) {
|
||||
looper.interrupt();
|
||||
looper = null;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,10 @@ public interface Hunk<T> {
|
||||
* Create a hunk view from a source hunk. This view reads and writes through to
|
||||
* the source hunk. Its is not a copy.
|
||||
*
|
||||
* @param <T> the type
|
||||
* @param src the source hunk
|
||||
* @param <T>
|
||||
* the type
|
||||
* @param src
|
||||
* the source hunk
|
||||
* @return the hunk view
|
||||
*/
|
||||
static <T> Hunk<T> view(Hunk<T> src) {
|
||||
@@ -197,9 +199,12 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Creates a new bounding hunk from the given hunks
|
||||
*
|
||||
* @param <T> the type
|
||||
* @param factory the factory that creates a hunk
|
||||
* @param hunks the hunks
|
||||
* @param <T>
|
||||
* the type
|
||||
* @param factory
|
||||
* the factory that creates a hunk
|
||||
* @param hunks
|
||||
* the hunks
|
||||
* @return the new bounding hunk
|
||||
*/
|
||||
@SafeVarargs
|
||||
@@ -208,7 +213,7 @@ public interface Hunk<T> {
|
||||
int h = 0;
|
||||
int d = 0;
|
||||
|
||||
for (Hunk<T> i : hunks) {
|
||||
for(Hunk<T> i : hunks) {
|
||||
w = Math.max(w, i.getWidth());
|
||||
h = Math.max(h, i.getHeight());
|
||||
d = Math.max(d, i.getDepth());
|
||||
@@ -216,7 +221,7 @@ public interface Hunk<T> {
|
||||
|
||||
Hunk<T> b = factory.apply(w, h, d);
|
||||
|
||||
for (Hunk<T> i : hunks) {
|
||||
for(Hunk<T> i : hunks) {
|
||||
b.insert(i);
|
||||
}
|
||||
|
||||
@@ -224,11 +229,11 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
static <A, B> void computeDual2D(int parallelism, Hunk<A> a, Hunk<B> b, Consumer5<Integer, Integer, Integer, Hunk<A>, Hunk<B>> v) {
|
||||
if (a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) {
|
||||
if(a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) {
|
||||
throw new RuntimeException("Hunk sizes must match!");
|
||||
}
|
||||
|
||||
if (a.get2DDimension(parallelism) == 1) {
|
||||
if(a.get2DDimension(parallelism) == 1) {
|
||||
v.accept(0, 0, 0, a, b);
|
||||
return;
|
||||
}
|
||||
@@ -239,7 +244,7 @@ public interface Hunk<T> {
|
||||
{
|
||||
v.accept(xx, yy, zz, ha, hr);
|
||||
|
||||
synchronized (rq) {
|
||||
synchronized(rq) {
|
||||
rq.add(r);
|
||||
}
|
||||
}), (x, y, z, hax, hbx) ->
|
||||
@@ -253,13 +258,13 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
static <A, B> void getDualSections2D(int sections, Hunk<A> a, Hunk<B> b, Consumer6<Integer, Integer, Integer, Hunk<A>, Hunk<B>, Runnable> v, Consumer5<Integer, Integer, Integer, Hunk<A>, Hunk<B>> inserterAB) {
|
||||
if (a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) {
|
||||
if(a.getWidth() != b.getWidth() || a.getHeight() != b.getHeight() || a.getDepth() != b.getDepth()) {
|
||||
throw new RuntimeException("Hunk sizes must match!");
|
||||
}
|
||||
|
||||
int dim = a.get2DDimension(sections);
|
||||
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
getDualSection(0, 0, 0, a.getWidth(), a.getHeight(), a.getDepth(), a, b, (ha, hr, r) -> v.accept(0, 0, 0, ha, hr, r), inserterAB);
|
||||
return;
|
||||
}
|
||||
@@ -270,10 +275,10 @@ public interface Hunk<T> {
|
||||
int dr = a.getDepth() - (d * dim);
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < a.getWidth(); i += w) {
|
||||
for(i = 0; i < a.getWidth(); i += w) {
|
||||
int ii = i;
|
||||
|
||||
for (j = 0; j < a.getDepth(); j += d) {
|
||||
for(j = 0; j < a.getDepth(); j += d) {
|
||||
int jj = j;
|
||||
getDualSection(i, 0, j, i + w + (i == 0 ? wr : 0), a.getHeight(), j + d + (j == 0 ? dr : 0), a, b, (ha, hr, r) -> v.accept(ii, 0, jj, ha, hr, r), inserterAB);
|
||||
i = i == 0 ? i + wr : i;
|
||||
@@ -291,37 +296,44 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Create a hunk that is optimized for specific uses
|
||||
*
|
||||
* @param w width
|
||||
* @param h height
|
||||
* @param d depth
|
||||
* @param type the class type
|
||||
* @param packed if the hunk is generally more than 50% full (non-null nodes)
|
||||
* @param concurrent if this hunk must be thread safe
|
||||
* @param <T> the type
|
||||
* @param w
|
||||
* width
|
||||
* @param h
|
||||
* height
|
||||
* @param d
|
||||
* depth
|
||||
* @param type
|
||||
* the class type
|
||||
* @param packed
|
||||
* if the hunk is generally more than 50% full (non-null nodes)
|
||||
* @param concurrent
|
||||
* if this hunk must be thread safe
|
||||
* @param <T>
|
||||
* the type
|
||||
* @return the hunk
|
||||
*/
|
||||
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent) {
|
||||
if (type.equals(Double.class)) {
|
||||
if(type.equals(Double.class)) {
|
||||
return concurrent ?
|
||||
packed ? (Hunk<T>) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
packed ? (Hunk<T>) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
}
|
||||
|
||||
if (type.equals(Integer.class)) {
|
||||
if(type.equals(Integer.class)) {
|
||||
return concurrent ?
|
||||
packed ? (Hunk<T>) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
packed ? (Hunk<T>) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
}
|
||||
|
||||
if (type.equals(Long.class)) {
|
||||
if(type.equals(Long.class)) {
|
||||
return concurrent ?
|
||||
packed ? (Hunk<T>) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
packed ? (Hunk<T>) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
}
|
||||
|
||||
return concurrent ?
|
||||
packed ? newAtomicHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
packed ? newAtomicHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
}
|
||||
|
||||
static IrisPosition rotatedBounding(int w, int h, int d, double x, double y, double z) {
|
||||
@@ -359,15 +371,15 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
static void rotate(double x, double y, double z, int[] c) {
|
||||
if (x % 360 != 0) {
|
||||
if(x % 360 != 0) {
|
||||
rotateAroundX(Math.toRadians(x), c);
|
||||
}
|
||||
|
||||
if (y % 360 != 0) {
|
||||
if(y % 360 != 0) {
|
||||
rotateAroundY(Math.toRadians(y), c);
|
||||
}
|
||||
|
||||
if (z % 360 != 0) {
|
||||
if(z % 360 != 0) {
|
||||
rotateAroundZ(Math.toRadians(z), c);
|
||||
}
|
||||
}
|
||||
@@ -469,14 +481,14 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default int filterDimension(int dim) {
|
||||
if (dim <= 1) {
|
||||
if(dim <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dim = dim % 2 != 0 ? dim + 1 : dim;
|
||||
|
||||
if (dim > getMinimumDimension() / 2) {
|
||||
if (dim <= 2) {
|
||||
if(dim > getMinimumDimension() / 2) {
|
||||
if(dim <= 2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -487,7 +499,7 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default int get2DDimension(int sections) {
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -495,7 +507,7 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default int get3DDimension(int sections) {
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -556,8 +568,10 @@ public interface Hunk<T> {
|
||||
* hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));<br>
|
||||
* }<br>
|
||||
*
|
||||
* @param p the predicate
|
||||
* @param c the consumer
|
||||
* @param p
|
||||
* the predicate
|
||||
* @param c
|
||||
* the consumer
|
||||
* @return this
|
||||
*/
|
||||
default Hunk<T> iterateSurfaces2D(Predicate<T> p, Consumer8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Hunk<T>> c) {
|
||||
@@ -618,9 +632,12 @@ public interface Hunk<T> {
|
||||
* hunk.set(hunkX, ?, hunkZ, noise(actualBlockX, ?, actualBlockZ));<br>
|
||||
* }<br>
|
||||
*
|
||||
* @param parallelism the ideal threads to use on this
|
||||
* @param p the predicate
|
||||
* @param c the consumer
|
||||
* @param parallelism
|
||||
* the ideal threads to use on this
|
||||
* @param p
|
||||
* the predicate
|
||||
* @param c
|
||||
* the consumer
|
||||
* @return this
|
||||
*/
|
||||
default Hunk<T> iterateSurfaces2D(int parallelism, Predicate<T> p, Consumer8<Integer, Integer, Integer, Integer, Integer, Integer, Integer, Hunk<T>> c) {
|
||||
@@ -629,20 +646,20 @@ public interface Hunk<T> {
|
||||
int last = -1;
|
||||
int in = getHeight() - 1;
|
||||
boolean hitting = false;
|
||||
for (int i = getHeight() - 1; i >= 0; i--) {
|
||||
for(int i = getHeight() - 1; i >= 0; i--) {
|
||||
boolean solid = p.test(h.get(ax, i, az));
|
||||
|
||||
if (!hitting && solid) {
|
||||
if(!hitting && solid) {
|
||||
in = i;
|
||||
hitting = true;
|
||||
} else if (hitting && !solid) {
|
||||
} else if(hitting && !solid) {
|
||||
hitting = false;
|
||||
c.accept(ax, az, hox, hoz, in, i - 1, last, h);
|
||||
last = i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hitting) {
|
||||
if(hitting) {
|
||||
c.accept(ax, az, hox, hoz, in, 0, last, h);
|
||||
}
|
||||
});
|
||||
@@ -657,7 +674,8 @@ public interface Hunk<T> {
|
||||
* <p>
|
||||
* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz));
|
||||
*
|
||||
* @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
|
||||
* @param c
|
||||
* the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
|
||||
* @return this
|
||||
*/
|
||||
default Hunk<T> iterate2DTop(Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) {
|
||||
@@ -675,15 +693,17 @@ public interface Hunk<T> {
|
||||
* <p>
|
||||
* hunk.set(ax, ?, az, NOISE.get(ax+hx, az+hz));
|
||||
*
|
||||
* @param parallelism the target parallelism value or 0 to disable
|
||||
* @param c the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
|
||||
* @param parallelism
|
||||
* the target parallelism value or 0 to disable
|
||||
* @param c
|
||||
* the consumer hunkX, hunkZ, hunkOffsetX, hunkOffsetZ.
|
||||
* @return this
|
||||
*/
|
||||
default Hunk<T> iterate2DTop(int parallelism, Consumer5<Integer, Integer, Integer, Integer, Hunk<T>> c) {
|
||||
compute2D(parallelism, (x, y, z, h) ->
|
||||
{
|
||||
for (int i = 0; i < h.getWidth(); i++) {
|
||||
for (int k = 0; k < h.getDepth(); k++) {
|
||||
for(int i = 0; i < h.getWidth(); i++) {
|
||||
for(int k = 0; k < h.getDepth(); k++) {
|
||||
c.accept(i, k, x, z, h);
|
||||
}
|
||||
}
|
||||
@@ -699,7 +719,7 @@ public interface Hunk<T> {
|
||||
default Hunk<T> iterate(int parallelism, Predicate<T> p, Consumer3<Integer, Integer, Integer> c) {
|
||||
iterate(parallelism, (x, y, z, t) ->
|
||||
{
|
||||
if (p.test(t)) {
|
||||
if(p.test(t)) {
|
||||
c.accept(x, y, z);
|
||||
}
|
||||
});
|
||||
@@ -714,7 +734,7 @@ public interface Hunk<T> {
|
||||
default Hunk<T> iterate(int parallelism, Predicate<T> p, Consumer4<Integer, Integer, Integer, T> c) {
|
||||
iterate(parallelism, (x, y, z, t) ->
|
||||
{
|
||||
if (p.test(t)) {
|
||||
if(p.test(t)) {
|
||||
c.accept(x, y, z, t);
|
||||
}
|
||||
});
|
||||
@@ -727,9 +747,9 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> iterateSync(Consumer3<Integer, Integer, Integer> c) {
|
||||
for (int i = 0; i < getWidth(); i++) {
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
for (int k = 0; k < getDepth(); k++) {
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
for(int k = 0; k < getDepth(); k++) {
|
||||
c.accept(i, j, k);
|
||||
}
|
||||
}
|
||||
@@ -739,9 +759,9 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
|
||||
for (int i = 0; i < getWidth(); i++) {
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
for (int k = 0; k < getDepth(); k++) {
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
for(int k = 0; k < getDepth(); k++) {
|
||||
c.accept(i, j, k, get(i, j, k));
|
||||
}
|
||||
}
|
||||
@@ -751,9 +771,9 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> updateSync(Function4<Integer, Integer, Integer, T, T> c) {
|
||||
for (int i = 0; i < getWidth(); i++) {
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
for (int k = 0; k < getDepth(); k++) {
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
for(int k = 0; k < getDepth(); k++) {
|
||||
set(i, j, k, c.apply(i, j, k, get(i, j, k)));
|
||||
}
|
||||
}
|
||||
@@ -763,9 +783,9 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
|
||||
for (int i = 0; i < getWidth(); i++) {
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
for (int k = 0; k < getDepth(); k++) {
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
for(int k = 0; k < getDepth(); k++) {
|
||||
c.accept(i, j, k, get(i, j, k));
|
||||
}
|
||||
}
|
||||
@@ -777,9 +797,9 @@ public interface Hunk<T> {
|
||||
default Hunk<T> iterate(int parallelism, Consumer3<Integer, Integer, Integer> c) {
|
||||
compute3D(parallelism, (x, y, z, h) ->
|
||||
{
|
||||
for (int i = 0; i < h.getWidth(); i++) {
|
||||
for (int j = 0; j < h.getHeight(); j++) {
|
||||
for (int k = 0; k < h.getDepth(); k++) {
|
||||
for(int i = 0; i < h.getWidth(); i++) {
|
||||
for(int j = 0; j < h.getHeight(); j++) {
|
||||
for(int k = 0; k < h.getDepth(); k++) {
|
||||
c.accept(i + x, j + y, k + z);
|
||||
}
|
||||
}
|
||||
@@ -796,9 +816,9 @@ public interface Hunk<T> {
|
||||
default Hunk<T> iterate(int parallelism, Consumer4<Integer, Integer, Integer, T> c) {
|
||||
compute3D(parallelism, (x, y, z, h) ->
|
||||
{
|
||||
for (int i = 0; i < h.getWidth(); i++) {
|
||||
for (int j = 0; j < h.getHeight(); j++) {
|
||||
for (int k = 0; k < h.getDepth(); k++) {
|
||||
for(int i = 0; i < h.getWidth(); i++) {
|
||||
for(int j = 0; j < h.getHeight(); j++) {
|
||||
for(int k = 0; k < h.getDepth(); k++) {
|
||||
c.accept(i + x, j + y, k + z, h.get(i, j, k));
|
||||
}
|
||||
}
|
||||
@@ -813,14 +833,14 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> compute2D(int parallelism, Consumer4<Integer, Integer, Integer, Hunk<T>> v) {
|
||||
if (get2DDimension(parallelism) == 1) {
|
||||
if(get2DDimension(parallelism) == 1) {
|
||||
v.accept(0, 0, 0, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
BurstExecutor e = MultiBurst.burst.burst(parallelism);
|
||||
|
||||
if (isAtomic()) {
|
||||
if(isAtomic()) {
|
||||
getSectionsAtomic2D(parallelism, (xx, yy, zz, h) -> e.queue(() ->
|
||||
{
|
||||
v.accept(xx, yy, zz, h);
|
||||
@@ -834,7 +854,7 @@ public interface Hunk<T> {
|
||||
{
|
||||
v.accept(xx, yy, zz, h);
|
||||
|
||||
synchronized (rq) {
|
||||
synchronized(rq) {
|
||||
rq.add(r);
|
||||
}
|
||||
}), this::insert);
|
||||
@@ -847,7 +867,7 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> compute2DYRange(int parallelism, int ymin, int ymax, Consumer4<Integer, Integer, Integer, Hunk<T>> v) {
|
||||
if (get2DDimension(parallelism) == 1) {
|
||||
if(get2DDimension(parallelism) == 1) {
|
||||
v.accept(0, 0, 0, this);
|
||||
return this;
|
||||
}
|
||||
@@ -858,7 +878,7 @@ public interface Hunk<T> {
|
||||
{
|
||||
v.accept(xx, yy, zz, h);
|
||||
|
||||
synchronized (rq) {
|
||||
synchronized(rq) {
|
||||
rq.add(r);
|
||||
}
|
||||
}), this::insert);
|
||||
@@ -872,7 +892,7 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default Hunk<T> compute3D(int parallelism, Consumer4<Integer, Integer, Integer, Hunk<T>> v) {
|
||||
if (get3DDimension(parallelism) == 1) {
|
||||
if(get3DDimension(parallelism) == 1) {
|
||||
v.accept(0, 0, 0, this);
|
||||
return this;
|
||||
}
|
||||
@@ -882,7 +902,7 @@ public interface Hunk<T> {
|
||||
getSections3D(parallelism, (xx, yy, zz, h, r) -> e.queue(() ->
|
||||
{
|
||||
v.accept(xx, yy, zz, h);
|
||||
synchronized (rq) {
|
||||
synchronized(rq) {
|
||||
rq.add(r);
|
||||
}
|
||||
}), this::insert);
|
||||
@@ -898,7 +918,7 @@ public interface Hunk<T> {
|
||||
default Hunk<T> getSectionsAtomic2D(int sections, Consumer4<Integer, Integer, Integer, Hunk<T>> v) {
|
||||
int dim = get2DDimension(sections);
|
||||
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
getAtomicSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh) -> v.accept(0, 0, 0, hh));
|
||||
return this;
|
||||
}
|
||||
@@ -909,10 +929,10 @@ public interface Hunk<T> {
|
||||
int dr = getDepth() - (d * dim);
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < getWidth(); i += w) {
|
||||
for(i = 0; i < getWidth(); i += w) {
|
||||
int ii = i;
|
||||
|
||||
for (j = 0; j < getDepth(); j += d) {
|
||||
for(j = 0; j < getDepth(); j += d) {
|
||||
int jj = j;
|
||||
getAtomicSection(i, 0, j, i + w + (i == 0 ? wr : 0), getHeight(), j + d + (j == 0 ? dr : 0), (h) -> v.accept(ii, 0, jj, h));
|
||||
i = i == 0 ? i + wr : i;
|
||||
@@ -926,7 +946,7 @@ public interface Hunk<T> {
|
||||
default Hunk<T> getSections2D(int sections, Consumer5<Integer, Integer, Integer, Hunk<T>, Runnable> v, Consumer4<Integer, Integer, Integer, Hunk<T>> inserter) {
|
||||
int dim = get2DDimension(sections);
|
||||
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
getSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh, r) -> v.accept(0, 0, 0, hh, r), inserter);
|
||||
return this;
|
||||
}
|
||||
@@ -937,10 +957,10 @@ public interface Hunk<T> {
|
||||
int dr = getDepth() - (d * dim);
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < getWidth(); i += w) {
|
||||
for(i = 0; i < getWidth(); i += w) {
|
||||
int ii = i;
|
||||
|
||||
for (j = 0; j < getDepth(); j += d) {
|
||||
for(j = 0; j < getDepth(); j += d) {
|
||||
int jj = j;
|
||||
getSection(i, 0, j, i + w + (i == 0 ? wr : 0), getHeight(), j + d + (j == 0 ? dr : 0), (h, r) -> v.accept(ii, 0, jj, h, r), inserter);
|
||||
i = i == 0 ? i + wr : i;
|
||||
@@ -954,7 +974,7 @@ public interface Hunk<T> {
|
||||
default Hunk<T> getSections2DYLimit(int sections, int ymin, int ymax, Consumer5<Integer, Integer, Integer, Hunk<T>, Runnable> v, Consumer4<Integer, Integer, Integer, Hunk<T>> inserter) {
|
||||
int dim = get2DDimension(sections);
|
||||
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
getSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh, r) -> v.accept(0, 0, 0, hh, r), inserter);
|
||||
return this;
|
||||
}
|
||||
@@ -965,10 +985,10 @@ public interface Hunk<T> {
|
||||
int dr = getDepth() - (d * dim);
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < getWidth(); i += w) {
|
||||
for(i = 0; i < getWidth(); i += w) {
|
||||
int ii = i;
|
||||
|
||||
for (j = 0; j < getDepth(); j += d) {
|
||||
for(j = 0; j < getDepth(); j += d) {
|
||||
int jj = j;
|
||||
getSection(i, ymin, j, i + w + (i == 0 ? wr : 0), ymax, j + d + (j == 0 ? dr : 0), (h, r) -> v.accept(ii, ymin, jj, h, r), inserter);
|
||||
i = i == 0 ? i + wr : i;
|
||||
@@ -986,7 +1006,7 @@ public interface Hunk<T> {
|
||||
default Hunk<T> getSections3D(int sections, Consumer5<Integer, Integer, Integer, Hunk<T>, Runnable> v, Consumer4<Integer, Integer, Integer, Hunk<T>> inserter) {
|
||||
int dim = get3DDimension(sections);
|
||||
|
||||
if (sections <= 1) {
|
||||
if(sections <= 1) {
|
||||
getSection(0, 0, 0, getWidth(), getHeight(), getDepth(), (hh, r) -> v.accept(0, 0, 0, hh, r), inserter);
|
||||
return this;
|
||||
}
|
||||
@@ -999,13 +1019,13 @@ public interface Hunk<T> {
|
||||
int dr = getDepth() - (d * dim);
|
||||
int i, j, k;
|
||||
|
||||
for (i = 0; i < getWidth(); i += w) {
|
||||
for(i = 0; i < getWidth(); i += w) {
|
||||
int ii = i;
|
||||
|
||||
for (j = 0; j < getHeight(); j += d) {
|
||||
for(j = 0; j < getHeight(); j += d) {
|
||||
int jj = j;
|
||||
|
||||
for (k = 0; k < getDepth(); k += d) {
|
||||
for(k = 0; k < getDepth(); k += d) {
|
||||
int kk = k;
|
||||
getSection(ii, jj, kk, i + w + (i == 0 ? wr : 0), j + h + (j == 0 ? hr : 0), k + d + (k == 0 ? dr : 0), (hh, r) -> v.accept(ii, jj, kk, hh, r), inserter);
|
||||
i = i == 0 ? i + wr : i;
|
||||
@@ -1037,20 +1057,26 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Create a new hunk from a section of this hunk.
|
||||
*
|
||||
* @param x1 The min x (inclusive)
|
||||
* @param y1 The min y (inclusive)
|
||||
* @param z1 The min z (inclusive)
|
||||
* @param x2 The max x (exclusive)
|
||||
* @param y2 The max y (exclusive)
|
||||
* @param z2 The max z (exclusive)
|
||||
* @param x1
|
||||
* The min x (inclusive)
|
||||
* @param y1
|
||||
* The min y (inclusive)
|
||||
* @param z1
|
||||
* The min z (inclusive)
|
||||
* @param x2
|
||||
* The max x (exclusive)
|
||||
* @param y2
|
||||
* The max y (exclusive)
|
||||
* @param z2
|
||||
* The max z (exclusive)
|
||||
* @return the new hunk (x2-x1, y2-y1, z2-z1)
|
||||
*/
|
||||
default ArrayHunk<T> crop(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
ArrayHunk<T> h = new ArrayHunk<T>(x2 - x1, y2 - y1, z2 - z1);
|
||||
|
||||
for (int i = x1; i < x2; i++) {
|
||||
for (int j = y1; j < y2; j++) {
|
||||
for (int k = z1; k < z2; k++) {
|
||||
for(int i = x1; i < x2; i++) {
|
||||
for(int j = y1; j < y2; j++) {
|
||||
for(int k = z1; k < z2; k++) {
|
||||
h.setRaw(i - x1, j - y1, k - z1, getRaw(i, j, k));
|
||||
}
|
||||
}
|
||||
@@ -1063,12 +1089,18 @@ public interface Hunk<T> {
|
||||
* Create a new view of this same hunk from a section of this hunk.
|
||||
* Modifications are routed to this hunk!
|
||||
*
|
||||
* @param x1 The min x (inclusive)
|
||||
* @param y1 The min y (inclusive)
|
||||
* @param z1 The min z (inclusive)
|
||||
* @param x2 The max x (exclusive)
|
||||
* @param y2 The max y (exclusive)
|
||||
* @param z2 The max z (exclusive)
|
||||
* @param x1
|
||||
* The min x (inclusive)
|
||||
* @param y1
|
||||
* The min y (inclusive)
|
||||
* @param z1
|
||||
* The min z (inclusive)
|
||||
* @param x2
|
||||
* The max x (exclusive)
|
||||
* @param y2
|
||||
* The max y (exclusive)
|
||||
* @param z2
|
||||
* The max z (exclusive)
|
||||
* @return the cropped view of this hunk (x2-x1, y2-y1, z2-z1)
|
||||
*/
|
||||
default Hunk<T> croppedView(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
@@ -1093,18 +1125,25 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Set a region
|
||||
*
|
||||
* @param x1 inclusive 1st x
|
||||
* @param y1 inclusive 1st y
|
||||
* @param z1 inclusive 1st z
|
||||
* @param x2 inclusive 2nd x
|
||||
* @param y2 inclusive 2nd y
|
||||
* @param z2 inclusive 2nd z
|
||||
* @param t the value to set
|
||||
* @param x1
|
||||
* inclusive 1st x
|
||||
* @param y1
|
||||
* inclusive 1st y
|
||||
* @param z1
|
||||
* inclusive 1st z
|
||||
* @param x2
|
||||
* inclusive 2nd x
|
||||
* @param y2
|
||||
* inclusive 2nd y
|
||||
* @param z2
|
||||
* inclusive 2nd z
|
||||
* @param t
|
||||
* the value to set
|
||||
*/
|
||||
default void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) {
|
||||
for (int i = x1; i <= x2; i++) {
|
||||
for (int j = y1; j <= y2; j++) {
|
||||
for (int k = z1; k <= z2; k++) {
|
||||
for(int i = x1; i <= x2; i++) {
|
||||
for(int j = y1; j <= y2; j++) {
|
||||
for(int k = z1; k <= z2; k++) {
|
||||
setRaw(i, j, k, t);
|
||||
}
|
||||
}
|
||||
@@ -1114,9 +1153,12 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Get the value to the closest valid position
|
||||
*
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param x
|
||||
* the x
|
||||
* @param y
|
||||
* the y
|
||||
* @param z
|
||||
* the z
|
||||
* @return the value closest to the border of the hunk
|
||||
*/
|
||||
default T getClosest(int x, int y, int z) {
|
||||
@@ -1146,11 +1188,12 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Get a 1 node thick hunk representing the face of this hunk
|
||||
*
|
||||
* @param f the face
|
||||
* @param f
|
||||
* the face
|
||||
* @return the hunk view of this hunk
|
||||
*/
|
||||
default Hunk<T> viewFace(HunkFace f) {
|
||||
switch (f) {
|
||||
switch(f) {
|
||||
case BOTTOM:
|
||||
return croppedView(0, 0, 0, getWidth() - 1, 0, getDepth() - 1);
|
||||
case EAST:
|
||||
@@ -1173,11 +1216,12 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Crop (copy) a 1 node thick hunk representing the face of this hunk
|
||||
*
|
||||
* @param f the face
|
||||
* @param f
|
||||
* the face
|
||||
* @return the hunk copy (face) of this hunk
|
||||
*/
|
||||
default Hunk<T> cropFace(HunkFace f) {
|
||||
switch (f) {
|
||||
switch(f) {
|
||||
case BOTTOM:
|
||||
return crop(0, 0, 0, getWidth() - 1, 0, getDepth() - 1);
|
||||
case EAST:
|
||||
@@ -1200,17 +1244,21 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Set a value at the given position
|
||||
*
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param t the value
|
||||
* @param x
|
||||
* the x
|
||||
* @param y
|
||||
* the y
|
||||
* @param z
|
||||
* the z
|
||||
* @param t
|
||||
* the value
|
||||
*/
|
||||
default void set(int x, int y, int z, T t) {
|
||||
setRaw(x, y, z, t);
|
||||
}
|
||||
|
||||
default void setIfExists(int x, int y, int z, T t) {
|
||||
if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) {
|
||||
if(x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1218,7 +1266,7 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
default T getIfExists(int x, int y, int z, T t) {
|
||||
if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) {
|
||||
if(x < 0 || x >= getWidth() || y < 0 || y >= getHeight() || z < 0 || z >= getDepth()) {
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -1232,19 +1280,26 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Set a value at the given position without checking coordinate bounds
|
||||
*
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param t the value
|
||||
* @param x
|
||||
* the x
|
||||
* @param y
|
||||
* the y
|
||||
* @param z
|
||||
* the z
|
||||
* @param t
|
||||
* the value
|
||||
*/
|
||||
void setRaw(int x, int y, int z, T t);
|
||||
|
||||
/**
|
||||
* Get a value at the given position without checking coordinate bounds
|
||||
*
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param x
|
||||
* the x
|
||||
* @param y
|
||||
* the y
|
||||
* @param z
|
||||
* the z
|
||||
* @return the value or null
|
||||
*/
|
||||
T getRaw(int x, int y, int z);
|
||||
@@ -1252,9 +1307,12 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Get a value at the given position
|
||||
*
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
* @param x
|
||||
* the x
|
||||
* @param y
|
||||
* the y
|
||||
* @param z
|
||||
* the z
|
||||
* @return the value or null
|
||||
*/
|
||||
default T get(int x, int y, int z) {
|
||||
@@ -1264,7 +1322,7 @@ public interface Hunk<T> {
|
||||
default T getOr(int x, int y, int z, T t) {
|
||||
T v = getRaw(x, y, z);
|
||||
|
||||
if (v == null) {
|
||||
if(v == null) {
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -1274,10 +1332,14 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Insert a hunk into this one with an offset the inserted hunk
|
||||
*
|
||||
* @param offX the offset from zero for x
|
||||
* @param offY the offset from zero for y
|
||||
* @param offZ the offset from zero for z
|
||||
* @param hunk the hunk to insert
|
||||
* @param offX
|
||||
* the offset from zero for x
|
||||
* @param offY
|
||||
* the offset from zero for y
|
||||
* @param offZ
|
||||
* the offset from zero for z
|
||||
* @param hunk
|
||||
* the hunk to insert
|
||||
*/
|
||||
default void insert(int offX, int offY, int offZ, Hunk<T> hunk) {
|
||||
insert(offX, offY, offZ, hunk, false);
|
||||
@@ -1290,7 +1352,8 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Insert a hunk into this one
|
||||
*
|
||||
* @param hunk the hunk to insert
|
||||
* @param hunk
|
||||
* the hunk to insert
|
||||
*/
|
||||
default void insert(Hunk<T> hunk) {
|
||||
insert(0, 0, 0, hunk, false);
|
||||
@@ -1310,8 +1373,10 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Insert a hunk into this one
|
||||
*
|
||||
* @param hunk the hunk to insert
|
||||
* @param inverted invert the inserted hunk or not
|
||||
* @param hunk
|
||||
* the hunk to insert
|
||||
* @param inverted
|
||||
* invert the inserted hunk or not
|
||||
*/
|
||||
default void insert(Hunk<T> hunk, boolean inverted) {
|
||||
insert(0, 0, 0, hunk, inverted);
|
||||
@@ -1321,16 +1386,21 @@ public interface Hunk<T> {
|
||||
* Insert a hunk into this one with an offset and possibly inverting the y of
|
||||
* the inserted hunk
|
||||
*
|
||||
* @param offX the offset from zero for x
|
||||
* @param offY the offset from zero for y
|
||||
* @param offZ the offset from zero for z
|
||||
* @param hunk the hunk to insert
|
||||
* @param invertY should the inserted hunk be inverted
|
||||
* @param offX
|
||||
* the offset from zero for x
|
||||
* @param offY
|
||||
* the offset from zero for y
|
||||
* @param offZ
|
||||
* the offset from zero for z
|
||||
* @param hunk
|
||||
* the hunk to insert
|
||||
* @param invertY
|
||||
* should the inserted hunk be inverted
|
||||
*/
|
||||
default void insert(int offX, int offY, int offZ, Hunk<T> hunk, boolean invertY) {
|
||||
for (int i = offX; i < offX + hunk.getWidth(); i++) {
|
||||
for (int j = offY; j < offY + hunk.getHeight(); j++) {
|
||||
for (int k = offZ; k < offZ + hunk.getDepth(); k++) {
|
||||
for(int i = offX; i < offX + hunk.getWidth(); i++) {
|
||||
for(int j = offY; j < offY + hunk.getHeight(); j++) {
|
||||
for(int k = offZ; k < offZ + hunk.getDepth(); k++) {
|
||||
setRaw(i, j, k, hunk.getRaw(i - offX, j - offY, k - offZ));
|
||||
}
|
||||
}
|
||||
@@ -1338,20 +1408,26 @@ public interface Hunk<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a hunk into this one with an offset and possibly inverting the y of. Will never insert a node if its already used
|
||||
* Insert a hunk into this one with an offset and possibly inverting the y of. Will never insert a node if its
|
||||
* already used
|
||||
* the inserted hunk
|
||||
*
|
||||
* @param offX the offset from zero for x
|
||||
* @param offY the offset from zero for y
|
||||
* @param offZ the offset from zero for z
|
||||
* @param hunk the hunk to insert
|
||||
* @param invertY should the inserted hunk be inverted
|
||||
* @param offX
|
||||
* the offset from zero for x
|
||||
* @param offY
|
||||
* the offset from zero for y
|
||||
* @param offZ
|
||||
* the offset from zero for z
|
||||
* @param hunk
|
||||
* the hunk to insert
|
||||
* @param invertY
|
||||
* should the inserted hunk be inverted
|
||||
*/
|
||||
default void insertSoftly(int offX, int offY, int offZ, Hunk<T> hunk, boolean invertY, Predicate<T> shouldOverwrite) {
|
||||
for (int i = offX; i < offX + hunk.getWidth(); i++) {
|
||||
for (int j = offY; j < offY + hunk.getHeight(); j++) {
|
||||
for (int k = offZ; k < offZ + hunk.getDepth(); k++) {
|
||||
if (shouldOverwrite.test(getRaw(i, j, k))) {
|
||||
for(int i = offX; i < offX + hunk.getWidth(); i++) {
|
||||
for(int j = offY; j < offY + hunk.getHeight(); j++) {
|
||||
for(int k = offZ; k < offZ + hunk.getDepth(); k++) {
|
||||
if(shouldOverwrite.test(getRaw(i, j, k))) {
|
||||
setRaw(i, j, k, hunk.getRaw(i - offX, j - offY, k - offZ));
|
||||
}
|
||||
}
|
||||
@@ -1362,7 +1438,8 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Acts like fill, however if used by a mapped hunk, will simply clear it
|
||||
*
|
||||
* @param b the data to use for fill
|
||||
* @param b
|
||||
* the data to use for fill
|
||||
*/
|
||||
default void empty(T b) {
|
||||
fill(b);
|
||||
@@ -1371,21 +1448,24 @@ public interface Hunk<T> {
|
||||
/**
|
||||
* Take a hunk and scale it up using interpolation
|
||||
*
|
||||
* @param scale the scale
|
||||
* @param d the interpolation method
|
||||
* @param interpolated the interpolated value converter
|
||||
* @param scale
|
||||
* the scale
|
||||
* @param d
|
||||
* the interpolation method
|
||||
* @param interpolated
|
||||
* the interpolated value converter
|
||||
* @return the new hunk
|
||||
*/
|
||||
default Hunk<T> interpolate3D(double scale, InterpolationMethod3D d, Interpolated<T> interpolated) {
|
||||
Hunk<T> t = Hunk.newArrayHunk((int) (getWidth() * scale), (int) (getHeight() * scale), (int) (getDepth() * scale));
|
||||
NoiseProvider3 n3 = (x, y, z) -> interpolated.toDouble(
|
||||
t.get((int) (x / scale),
|
||||
(int) (y / scale),
|
||||
(int) (z / scale)));
|
||||
t.get((int) (x / scale),
|
||||
(int) (y / scale),
|
||||
(int) (z / scale)));
|
||||
|
||||
for (int i = 0; i < t.getWidth(); i++) {
|
||||
for (int j = 0; j < t.getHeight(); j++) {
|
||||
for (int k = 0; k < t.getDepth(); k++) {
|
||||
for(int i = 0; i < t.getWidth(); i++) {
|
||||
for(int j = 0; j < t.getHeight(); j++) {
|
||||
for(int k = 0; k < t.getDepth(); k++) {
|
||||
t.set(i, j, k, interpolated.fromDouble(IrisInterpolation.getNoise3D(d, i, j, k, scale, n3)));
|
||||
}
|
||||
}
|
||||
@@ -1398,20 +1478,23 @@ public interface Hunk<T> {
|
||||
* Take a hunk and scale it up using interpolation
|
||||
* 2D, (using only x and z) assumes the height is 1
|
||||
*
|
||||
* @param scale the scale
|
||||
* @param d the interpolation method
|
||||
* @param interpolated the interpolated value converter
|
||||
* @param scale
|
||||
* the scale
|
||||
* @param d
|
||||
* the interpolation method
|
||||
* @param interpolated
|
||||
* the interpolated value converter
|
||||
* @return the new hunk
|
||||
*/
|
||||
default Hunk<T> interpolate2D(double scale, InterpolationMethod d, Interpolated<T> interpolated) {
|
||||
Hunk<T> t = Hunk.newArrayHunk((int) (getWidth() * scale), 1, (int) (getDepth() * scale));
|
||||
NoiseProvider n2 = (x, z) -> interpolated.toDouble(
|
||||
t.get((int) (x / scale),
|
||||
0,
|
||||
(int) (z / scale)));
|
||||
t.get((int) (x / scale),
|
||||
0,
|
||||
(int) (z / scale)));
|
||||
|
||||
for (int i = 0; i < t.getWidth(); i++) {
|
||||
for (int j = 0; j < t.getDepth(); j++) {
|
||||
for(int i = 0; i < t.getWidth(); i++) {
|
||||
for(int j = 0; j < t.getDepth(); j++) {
|
||||
t.set(i, 0, j, interpolated.fromDouble(IrisInterpolation.getNoise(d, i, j, scale, n2)));
|
||||
}
|
||||
}
|
||||
@@ -1451,9 +1534,9 @@ public interface Hunk<T> {
|
||||
Hunk<T> r = builder.get(maxX - minX, maxY - minY, maxZ - minZ);
|
||||
int[] cr = {(maxX - minX) / 2, (maxY - minY) / 2, (maxZ - minZ) / 2};
|
||||
|
||||
for (i = 0; i < w; i++) {
|
||||
for (j = 0; j < h; j++) {
|
||||
for (k = 0; k < d; k++) {
|
||||
for(i = 0; i < w; i++) {
|
||||
for(j = 0; j < h; j++) {
|
||||
for(k = 0; k < d; k++) {
|
||||
b[0] = i - c[0];
|
||||
b[1] = j - c[1];
|
||||
b[2] = k - c[2];
|
||||
@@ -1461,7 +1544,7 @@ public interface Hunk<T> {
|
||||
|
||||
try {
|
||||
r.set(b[0] + cr[0], b[1] + cr[1], b[2] + cr[2], get(i, j, k));
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package com.volmit.iris.util.hunk.bits;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
@@ -30,27 +29,27 @@ import java.util.concurrent.atomic.AtomicLongArray;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
public class DataBits {
|
||||
private static final int[] MAGIC = new int[]{
|
||||
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
||||
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
||||
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
||||
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
||||
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
||||
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
||||
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
||||
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
||||
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
||||
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
||||
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
||||
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
||||
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
||||
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
||||
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
||||
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
||||
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
||||
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
||||
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
||||
0, 5};
|
||||
private static final int[] MAGIC = new int[] {
|
||||
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
||||
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
||||
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
||||
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
||||
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
||||
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
||||
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
||||
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
||||
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
||||
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
||||
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
||||
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
||||
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
||||
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
||||
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
||||
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
||||
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
||||
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
||||
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
||||
0, 5};
|
||||
|
||||
private final AtomicLongArray data;
|
||||
private final int bits;
|
||||
@@ -81,8 +80,8 @@ public class DataBits {
|
||||
this.divideShift = MAGIC[var3 + 2];
|
||||
int var4 = (length + valuesPerLong - 1) / valuesPerLong;
|
||||
|
||||
if (data != null) {
|
||||
if (data.length() != var4) {
|
||||
if(data != null) {
|
||||
if(data.length() != var4) {
|
||||
throw new RuntimeException("NO! Trying to load " + data.length() + " into actual size of " + var4 + " because length: " + length + " (bits: " + bits + ")");
|
||||
}
|
||||
this.data = data;
|
||||
@@ -102,7 +101,7 @@ public class DataBits {
|
||||
private static AtomicLongArray longs(DataInputStream din, int longSize) throws IOException {
|
||||
AtomicLongArray a = new AtomicLongArray(longSize);
|
||||
|
||||
for (int i = 0; i < a.length(); i++) {
|
||||
for(int i = 0; i < a.length(); i++) {
|
||||
a.set(i, Varint.readUnsignedVarLong(din));
|
||||
}
|
||||
|
||||
@@ -110,11 +109,11 @@ public class DataBits {
|
||||
}
|
||||
|
||||
public DataBits setBits(int newBits) {
|
||||
if (bits != newBits) {
|
||||
if(bits != newBits) {
|
||||
DataBits newData = new DataBits(newBits, size);
|
||||
AtomicInteger c = new AtomicInteger(0);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
for(int i = 0; i < size; i++) {
|
||||
newData.set(i, get(i));
|
||||
}
|
||||
|
||||
@@ -175,12 +174,12 @@ public class DataBits {
|
||||
|
||||
public void getAll(IntConsumer var0) {
|
||||
int var1 = 0;
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
for(int i = 0; i < data.length(); i++) {
|
||||
long var5 = data.get(i);
|
||||
for (int var7 = 0; var7 < valuesPerLong; var7++) {
|
||||
for(int var7 = 0; var7 < valuesPerLong; var7++) {
|
||||
var0.accept((int) (var5 & mask));
|
||||
var5 >>= bits;
|
||||
if (++var1 >= size) {
|
||||
if(++var1 >= size) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +187,7 @@ public class DataBits {
|
||||
}
|
||||
|
||||
public void write(DataOutputStream dos) throws IOException {
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
for(int i = 0; i < data.length(); i++) {
|
||||
Varint.writeUnsignedVarLong(data.get(i), dos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package com.volmit.iris.util.hunk.bits;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -56,8 +55,7 @@ public class DataContainer<T> {
|
||||
this.bits = new AtomicInteger(palette.get().bits());
|
||||
}
|
||||
|
||||
public static String readBitString(DataInputStream din) throws IOException
|
||||
{
|
||||
public static String readBitString(DataInputStream din) throws IOException {
|
||||
DataContainer<Character> c = new DataContainer<>(din, new Writable<Character>() {
|
||||
@Override
|
||||
public Character readNodeData(DataInputStream din) throws IOException {
|
||||
@@ -72,8 +70,7 @@ public class DataContainer<T> {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(int i = c.size()-1; i >= 0; i--)
|
||||
{
|
||||
for(int i = c.size() - 1; i >= 0; i--) {
|
||||
sb.setCharAt(i, c.get(i));
|
||||
}
|
||||
|
||||
@@ -93,27 +90,24 @@ public class DataContainer<T> {
|
||||
}
|
||||
}, s.length());
|
||||
|
||||
for(int i = 0; i < s.length(); i++)
|
||||
{
|
||||
for(int i = 0; i < s.length(); i++) {
|
||||
c.set(i, s.charAt(i));
|
||||
}
|
||||
|
||||
c.writeDos(dos);
|
||||
}
|
||||
|
||||
public DataBits getData()
|
||||
{
|
||||
public DataBits getData() {
|
||||
return data.get();
|
||||
}
|
||||
|
||||
public Palette<T> getPalette()
|
||||
{
|
||||
public Palette<T> getPalette() {
|
||||
return palette.get();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "DataContainer <" + length + " x " + bits + " bits> -> Palette<" + palette.get().getClass().getSimpleName().replaceAll("\\QPalette\\E", "") + ">: " + palette.get().size() +
|
||||
" " + data.get().toString() + " PalBit: " + palette.get().bits();
|
||||
" " + data.get().toString() + " PalBit: " + palette.get().bits();
|
||||
}
|
||||
|
||||
public byte[] write() throws IOException {
|
||||
@@ -136,13 +130,13 @@ public class DataContainer<T> {
|
||||
|
||||
private Palette<T> newPalette(DataInputStream din) throws IOException {
|
||||
int paletteSize = Varint.readUnsignedVarInt(din);
|
||||
Palette<T> d = newPalette(bits(paletteSize+1));
|
||||
Palette<T> d = newPalette(bits(paletteSize + 1));
|
||||
d.from(paletteSize, writer, din);
|
||||
return d;
|
||||
}
|
||||
|
||||
private Palette<T> newPalette(int bits) {
|
||||
if (bits <= LINEAR_BITS_LIMIT) {
|
||||
if(bits <= LINEAR_BITS_LIMIT) {
|
||||
return new LinearPalette<>(LINEAR_INITIAL_LENGTH);
|
||||
}
|
||||
|
||||
@@ -150,17 +144,16 @@ public class DataContainer<T> {
|
||||
}
|
||||
|
||||
public void ensurePaletted(T t) {
|
||||
if (palette.get().id(t) == -1) {
|
||||
if(palette.get().id(t) == -1) {
|
||||
expandOne();
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int position, T t) {
|
||||
synchronized (this)
|
||||
{
|
||||
synchronized(this) {
|
||||
int id = palette.get().id(t);
|
||||
|
||||
if (id == -1) {
|
||||
if(id == -1) {
|
||||
expandOne();
|
||||
id = palette.get().add(t);
|
||||
}
|
||||
@@ -170,17 +163,16 @@ public class DataContainer<T> {
|
||||
}
|
||||
|
||||
private void expandOne() {
|
||||
if (palette.get().size() + 1 >= BIT[bits.get()]) {
|
||||
if(palette.get().size() + 1 >= BIT[bits.get()]) {
|
||||
setBits(bits.get() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public T get(int position) {
|
||||
synchronized (this)
|
||||
{
|
||||
synchronized(this) {
|
||||
int id = data.get().get(position) + 1;
|
||||
|
||||
if (id <= 0) {
|
||||
if(id <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -189,8 +181,8 @@ public class DataContainer<T> {
|
||||
}
|
||||
|
||||
public void setBits(int bits) {
|
||||
if (this.bits.get() != bits) {
|
||||
if (this.bits.get() <= LINEAR_BITS_LIMIT != bits <= LINEAR_BITS_LIMIT) {
|
||||
if(this.bits.get() != bits) {
|
||||
if(this.bits.get() <= LINEAR_BITS_LIMIT != bits <= LINEAR_BITS_LIMIT) {
|
||||
palette.set(newPalette(bits).from(palette.get()));
|
||||
}
|
||||
|
||||
@@ -202,7 +194,7 @@ public class DataContainer<T> {
|
||||
private static int[] computeBitLimits() {
|
||||
int[] m = new int[16];
|
||||
|
||||
for (int i = 0; i < m.length; i++) {
|
||||
for(int i = 0; i < m.length; i++) {
|
||||
m[i] = (int) Math.pow(2, i);
|
||||
}
|
||||
|
||||
@@ -210,12 +202,12 @@ public class DataContainer<T> {
|
||||
}
|
||||
|
||||
protected static int bits(int size) {
|
||||
if (DataContainer.BIT[INITIAL_BITS] >= size) {
|
||||
if(DataContainer.BIT[INITIAL_BITS] >= size) {
|
||||
return INITIAL_BITS;
|
||||
}
|
||||
|
||||
for (int i = 0; i < DataContainer.BIT.length; i++) {
|
||||
if (DataContainer.BIT[i] >= size) {
|
||||
for(int i = 0; i < DataContainer.BIT.length; i++) {
|
||||
if(DataContainer.BIT[i] >= size) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HashPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public T get(int id) {
|
||||
if (id < 0 || id >= size.get()) {
|
||||
if(id < 0 || id >= size.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class HashPalette<T> implements Palette<T> {
|
||||
int index = size.getAndIncrement();
|
||||
palette.put(t, index);
|
||||
|
||||
if (t != null) {
|
||||
if(t != null) {
|
||||
lookup.put(index, t);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ public class HashPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public int id(T t) {
|
||||
if(t == null)
|
||||
{
|
||||
if(t == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,9 +74,8 @@ public class HashPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public void iterate(Consumer2<T, Integer> c) {
|
||||
for (T i : palette.keySet()) {
|
||||
if(i == null)
|
||||
{
|
||||
for(T i : palette.keySet()) {
|
||||
if(i == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package com.volmit.iris.util.hunk.bits;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.function.Consumer2;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -38,7 +36,7 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public T get(int id) {
|
||||
if (id < 0 || id >= size.get()) {
|
||||
if(id < 0 || id >= size.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -54,10 +52,10 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
}
|
||||
|
||||
private void grow(int newLength) {
|
||||
if (newLength > palette.get().length()) {
|
||||
if(newLength > palette.get().length()) {
|
||||
AtomicReferenceArray<T> a = new AtomicReferenceArray<>(newLength + size.get());
|
||||
|
||||
for (int i = 0; i < palette.get().length(); i++) {
|
||||
for(int i = 0; i < palette.get().length(); i++) {
|
||||
a.set(i, palette.get().get(i));
|
||||
}
|
||||
|
||||
@@ -67,13 +65,12 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public int id(T t) {
|
||||
if(t == null)
|
||||
{
|
||||
if(t == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i < size() + 1; i++) {
|
||||
if (t.equals(palette.get().get(i))) {
|
||||
for(int i = 1; i < size() + 1; i++) {
|
||||
if(t.equals(palette.get().get(i))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -83,12 +80,12 @@ public class LinearPalette<T> implements Palette<T> {
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size.get()-1;
|
||||
return size.get() - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void iterate(Consumer2<T, Integer> c) {
|
||||
for (int i = 1; i < size()+1; i++) {
|
||||
for(int i = 1; i < size() + 1; i++) {
|
||||
c.accept(palette.get().get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public interface Palette<T> {
|
||||
int size();
|
||||
|
||||
default int bits() {
|
||||
return DataContainer.bits(size()+1);
|
||||
return DataContainer.bits(size() + 1);
|
||||
}
|
||||
|
||||
void iterate(Consumer2<T, Integer> c);
|
||||
@@ -44,14 +44,14 @@ public interface Palette<T> {
|
||||
iterate((a, b) -> {
|
||||
try {
|
||||
c.accept(a, b);
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
default Palette<T> from(int size, Writable<T> writable, DataInputStream in) throws IOException {
|
||||
for (int i = 0; i < size; i++) {
|
||||
for(int i = 0; i < size; i++) {
|
||||
add(writable.readNodeData(in));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,31 +22,23 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.slices.BlockMatter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
public class TecTest {
|
||||
public static Set<BlockData> randomBlocks(int max)
|
||||
{
|
||||
public static Set<BlockData> randomBlocks(int max) {
|
||||
KSet<BlockData> d = new KSet<>();
|
||||
|
||||
while(d.size() < max)
|
||||
{
|
||||
while(d.size() < max) {
|
||||
Material m = Material.values()[RNG.r.i(Material.values().length - 1)];
|
||||
if(m.isBlock())
|
||||
{
|
||||
if(m.isBlock()) {
|
||||
d.add(m.createBlockData());
|
||||
}
|
||||
}
|
||||
@@ -54,23 +46,19 @@ public class TecTest {
|
||||
return d;
|
||||
}
|
||||
|
||||
public static void go()
|
||||
{
|
||||
public static void go() {
|
||||
|
||||
}
|
||||
|
||||
public static boolean test(int size, int pal)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static boolean test(int size, int pal) {
|
||||
try {
|
||||
Iris.info("Test? " + size + " " + pal);
|
||||
KList<BlockData> blocks = new KList<>(randomBlocks(pal));
|
||||
Iris.info("Fill " + pal + " -> " + size + " Entries");
|
||||
Writable<BlockData> writer = new BlockMatter();
|
||||
DataContainer<BlockData> dc = new DataContainer<>(writer, size);
|
||||
|
||||
for(int i = 0; i < dc.size(); i++)
|
||||
{
|
||||
for(int i = 0; i < dc.size(); i++) {
|
||||
dc.set(i, blocks.getRandom());
|
||||
}
|
||||
|
||||
@@ -84,13 +72,9 @@ public class TecTest {
|
||||
if(Arrays.equals(dat, dat2)) {
|
||||
Iris.info("MATCH");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < dc.size(); i++)
|
||||
{
|
||||
if(!dx.get(i).equals(dc.get(i)))
|
||||
{
|
||||
} else {
|
||||
for(int i = 0; i < dc.size(); i++) {
|
||||
if(!dx.get(i).equals(dc.get(i))) {
|
||||
Iris.info("FAIL Expected " + dc.get(i).getAsString(true) + " but got " + dx.get(i).getAsString(true));
|
||||
return false;
|
||||
}
|
||||
@@ -99,10 +83,7 @@ public class TecTest {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, T t) {
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
data.remove(index(x, y, z));
|
||||
return;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
|
||||
int idx, z;
|
||||
|
||||
for (Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
for(Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
idx = g.getKey();
|
||||
z = idx / (getWidth() * getHeight());
|
||||
idx -= (z * getWidth() * getHeight());
|
||||
@@ -83,7 +83,7 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
|
||||
int idx, z;
|
||||
|
||||
for (Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
for(Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
idx = g.getKey();
|
||||
z = idx / (getWidth() * getHeight());
|
||||
idx -= (z * getWidth() * getHeight());
|
||||
|
||||
@@ -48,15 +48,15 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
return data.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, T t) {
|
||||
synchronized (data) {
|
||||
if (t == null) {
|
||||
synchronized(data) {
|
||||
if(t == null) {
|
||||
data.remove(index(x, y, z));
|
||||
return;
|
||||
}
|
||||
@@ -71,10 +71,10 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
int idx, z;
|
||||
|
||||
for (Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
for(Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
idx = g.getKey();
|
||||
z = idx / (getWidth() * getHeight());
|
||||
idx -= (z * getWidth() * getHeight());
|
||||
@@ -87,10 +87,10 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
int idx, z;
|
||||
|
||||
for (Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
for(Map.Entry<Integer, T> g : data.entrySet()) {
|
||||
idx = g.getKey();
|
||||
z = idx / (getWidth() * getHeight());
|
||||
idx -= (z * getWidth() * getHeight());
|
||||
@@ -103,14 +103,14 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public void empty(T b) {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
data.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getRaw(int x, int y, int z) {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
return data.get(index(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
|
||||
@Data
|
||||
@@ -54,11 +53,11 @@ public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
|
||||
for (int i = 0; i < getWidth(); i++) {
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
for (int k = 0; k < getDepth(); k++) {
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
for(int k = 0; k < getDepth(); k++) {
|
||||
T t = getRaw(i, j, k);
|
||||
if (t != null) {
|
||||
if(t != null) {
|
||||
c.accept(i, j, k, t);
|
||||
}
|
||||
}
|
||||
@@ -69,11 +68,11 @@ public class PaletteHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
|
||||
for (int i = 0; i < getWidth(); i++) {
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
for (int k = 0; k < getDepth(); k++) {
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
for(int k = 0; k < getDepth(); k++) {
|
||||
T t = getRaw(i, j, k);
|
||||
if (t != null) {
|
||||
if(t != null) {
|
||||
c.accept(i, j, k, t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class PaletteOrHunk<T> extends StorageHunk<T> implements Hunk<T>
|
||||
}
|
||||
|
||||
public void setPalette(DataContainer<T> c) {
|
||||
if (isPalette()) {
|
||||
if(isPalette()) {
|
||||
((PaletteHunk<T>) hunk).setPalette(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public abstract class StorageHunk<T> implements Hunk<T> {
|
||||
private final int depth;
|
||||
|
||||
public StorageHunk(int width, int height, int depth) {
|
||||
if (width <= 0 || height <= 0 || depth <= 0) {
|
||||
if(width <= 0 || height <= 0 || depth <= 0) {
|
||||
throw new RuntimeException("Unsupported size " + width + " " + height + " " + depth);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,14 +38,14 @@ public class SynchronizedArrayHunk<T> extends StorageHunk<T> implements Hunk<T>
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, T t) {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
data[index(x, y, z)] = t;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getRaw(int x, int y, int z) {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
return data[index(x, y, z)];
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class SynchronizedArrayHunk<T> extends StorageHunk<T> implements Hunk<T>
|
||||
|
||||
@Override
|
||||
public void fill(T t) {
|
||||
synchronized (data) {
|
||||
synchronized(data) {
|
||||
Arrays.fill(data, t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +55,19 @@ public class BiomeGridHunkView implements Hunk<Biome> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, Biome t) {
|
||||
chunk.setBiome(x, y+minHeight, z, t);
|
||||
chunk.setBiome(x, y + minHeight, z, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getRaw(int x, int y, int z) {
|
||||
return chunk.getBiome(x, y+minHeight, z);
|
||||
return chunk.getBiome(x, y + minHeight, z);
|
||||
}
|
||||
|
||||
public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) {
|
||||
if (chunk instanceof LinkedTerrainChunk) {
|
||||
INMS.get().forceBiomeInto(x, y+minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
|
||||
if(chunk instanceof LinkedTerrainChunk) {
|
||||
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
|
||||
return;
|
||||
}
|
||||
INMS.get().forceBiomeInto(x, y+minHeight, z, somethingVeryDirty, chunk);
|
||||
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ChunkBiomeHunkView implements Hunk<Biome> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, Biome t) {
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public class ChunkBiomeHunkView implements Hunk<Biome> {
|
||||
@Override
|
||||
public Biome getRaw(int x, int y, int z) {
|
||||
return Iris.service(EditSVC.class)
|
||||
.getBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16));
|
||||
.getBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,24 +47,24 @@ public class ChunkDataHunkView implements Hunk<BlockData> {
|
||||
|
||||
@Override
|
||||
public void set(int x1, int y1, int z1, int x2, int y2, int z2, BlockData t) {
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
chunk.setRegion(x1, y1+chunk.getMinHeight(), z1, x2, y2+chunk.getMinHeight(), z2, t);
|
||||
chunk.setRegion(x1, y1 + chunk.getMinHeight(), z1, x2, y2 + chunk.getMinHeight(), z2, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, BlockData t) {
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
chunk.setBlock(x, y+chunk.getMinHeight(), z, t);
|
||||
chunk.setBlock(x, y + chunk.getMinHeight(), z, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getRaw(int x, int y, int z) {
|
||||
return chunk.getBlockData(x, y+chunk.getMinHeight(), z);
|
||||
return chunk.getBlockData(x, y + chunk.getMinHeight(), z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ChunkHunkView implements Hunk<BlockData> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, BlockData t) {
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FunctionalHunkView<R, T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, T t) {
|
||||
if (backConverter == null) {
|
||||
if(backConverter == null) {
|
||||
throw new UnsupportedOperationException("You cannot writeNodeData to this hunk (Read Only)");
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class FunctionalHunkView<R, T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public T getRaw(int x, int y, int z) {
|
||||
if (converter == null) {
|
||||
if(converter == null) {
|
||||
throw new UnsupportedOperationException("You cannot read this hunk (Write Only)");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ public class RotatedXHunkView<T> implements Hunk<T> {
|
||||
int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f));
|
||||
int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f));
|
||||
src.setIfExists(x,
|
||||
(int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc,
|
||||
(int) Math.round(sin * y - yc + cos * (z - zc)) - zc,
|
||||
t);
|
||||
(int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc,
|
||||
(int) Math.round(sin * y - yc + cos * (z - zc)) - zc,
|
||||
t);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,8 +46,8 @@ public class RotatedXHunkView<T> implements Hunk<T> {
|
||||
int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f));
|
||||
int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f));
|
||||
return src.getIfExists(x,
|
||||
(int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc,
|
||||
(int) Math.round(sin * y - yc + cos * (z - zc)) - zc
|
||||
(int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc,
|
||||
(int) Math.round(sin * y - yc + cos * (z - zc)) - zc
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ public class RotatedYHunkView<T> implements Hunk<T> {
|
||||
int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f));
|
||||
int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f));
|
||||
src.setIfExists((int)
|
||||
Math.round(cos * (x - xc) + sin * (z - zc)) - xc,
|
||||
y,
|
||||
(int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc, t);
|
||||
Math.round(cos * (x - xc) + sin * (z - zc)) - xc,
|
||||
y,
|
||||
(int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,9 +46,9 @@ public class RotatedYHunkView<T> implements Hunk<T> {
|
||||
int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f));
|
||||
int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f));
|
||||
return src.getIfExists(
|
||||
(int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc,
|
||||
y,
|
||||
(int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc
|
||||
(int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc,
|
||||
y,
|
||||
(int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ public class RotatedZHunkView<T> implements Hunk<T> {
|
||||
int xc = (int) Math.round(cos * (getWidth() / 2f) - sin * (getHeight() / 2f));
|
||||
int yc = (int) Math.round(sin * (getWidth() / 2f) + cos * (getHeight() / 2f));
|
||||
return src.getIfExists((int) Math.round(cos * (x - xc) - sin * (y - yc)) - xc,
|
||||
(int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc
|
||||
, z);
|
||||
(int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc
|
||||
, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class SynchronizedHunkView<T> implements Hunk<T> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, T t) {
|
||||
synchronized (src) {
|
||||
synchronized(src) {
|
||||
src.setRaw(x, y, z, t);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user