{
+
/** Applies this function to the given argument and its index within a stream. */
R apply(T from, long index);
}
@@ -20,22 +23,27 @@ public class Streams {
* Returns a stream consisting of the results of applying the given function to the elements of
* {@code stream} and their indices in the stream. For example,
*
- * {@code
+ *
+ * {@code
* mapWithIndex(
* Stream.of("a", "b", "c"),
* (str, index) -> str + ":" + index)
- * }
+ * }
+ *
*
- * would return {@code Stream.of("a:0", "b:1", "c:2")}.
+ *
+ * would return {@code Stream.of("a:0", "b:1", "c:2")}.
*
- *
The resulting stream is
+ * The resulting stream is efficiently splittable
* if and only if {@code stream} was efficiently splittable and its underlying spliterator
* reported {@link Spliterator#SUBSIZED}. This is generally the case if the underlying stream
* comes from a data structure supporting efficient indexed random access, typically an array or
* list.
*
- *
The order of the resulting stream is defined if and only if the order of the original stream
+ *
+ * The order of the resulting stream is defined if and only if the order of the original stream
* was defined.
*/
public static Stream mapWithIndex(Stream stream, FunctionWithIndex super T, ? extends R> function) {
@@ -47,23 +55,25 @@ public class Streams {
if (!fromSpliterator.hasCharacteristics(Spliterator.SUBSIZED)) {
Iterator fromIterator = Spliterators.iterator(fromSpliterator);
return StreamSupport.stream(
- new Spliterators.AbstractSpliterator(
- fromSpliterator.estimateSize(),
- fromSpliterator.characteristics() & (Spliterator.ORDERED | Spliterator.SIZED)) {
- long index = 0;
+ new Spliterators.AbstractSpliterator(
+ fromSpliterator.estimateSize(),
+ fromSpliterator.characteristics() & (Spliterator.ORDERED | Spliterator.SIZED)) {
- @Override
- public boolean tryAdvance(Consumer super R> action) {
- if (fromIterator.hasNext()) {
- action.accept(function.apply(fromIterator.next(), index++));
- return true;
- }
- return false;
+ long index = 0;
+
+ @Override
+ public boolean tryAdvance(Consumer super R> action) {
+ if (fromIterator.hasNext()) {
+ action.accept(function.apply(fromIterator.next(), index++));
+ return true;
}
- },
- isParallel);
+ return false;
+ }
+ },
+ isParallel);
}
class Splitr extends MapWithIndexSpliterator, R, Splitr> implements Consumer {
+
T holder;
Splitr(Spliterator splitr, long index) {
@@ -96,9 +106,9 @@ public class Streams {
return StreamSupport.stream(new Splitr(fromSpliterator, 0), isParallel);
}
- private abstract static class MapWithIndexSpliterator<
- F extends Spliterator>, R, S extends MapWithIndexSpliterator>
- implements Spliterator {
+ private abstract static class MapWithIndexSpliterator, R, S extends MapWithIndexSpliterator>
+ implements Spliterator {
+
final F fromSpliterator;
long index;
diff --git a/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java b/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java
index 62566e2..1139b3d 100644
--- a/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java
+++ b/src/main/java/me/towdium/jecalculation/polyfill/mc/client/renderer/GlStateManager.java
@@ -1,15 +1,16 @@
package me.towdium.jecalculation.polyfill.mc.client.renderer;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
+
import javax.annotation.Nullable;
+
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
+
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@@ -19,9 +20,13 @@ import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GLContext;
import org.lwjgl.util.vector.Quaternion;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
@SuppressWarnings("ALL")
@SideOnly(Side.CLIENT)
public class GlStateManager {
+
private static final FloatBuffer BUF_FLOAT_16 = BufferUtils.createFloatBuffer(16);
private static final FloatBuffer BUF_FLOAT_4 = BufferUtils.createFloatBuffer(4);
private static final GlStateManager.AlphaState alphaState = new GlStateManager.AlphaState();
@@ -155,19 +160,15 @@ public class GlStateManager {
}
}
- public static void tryBlendFuncSeparate(
- GlStateManager.SourceFactor srcFactor,
- GlStateManager.DestFactor dstFactor,
- GlStateManager.SourceFactor srcFactorAlpha,
- GlStateManager.DestFactor dstFactorAlpha) {
+ public static void tryBlendFuncSeparate(GlStateManager.SourceFactor srcFactor, GlStateManager.DestFactor dstFactor,
+ GlStateManager.SourceFactor srcFactorAlpha, GlStateManager.DestFactor dstFactorAlpha) {
tryBlendFuncSeparate(srcFactor.factor, dstFactor.factor, srcFactorAlpha.factor, dstFactorAlpha.factor);
}
public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) {
- if (srcFactor != blendState.srcFactor
- || dstFactor != blendState.dstFactor
- || srcFactorAlpha != blendState.srcFactorAlpha
- || dstFactorAlpha != blendState.dstFactorAlpha) {
+ if (srcFactor != blendState.srcFactor || dstFactor != blendState.dstFactor
+ || srcFactorAlpha != blendState.srcFactorAlpha
+ || dstFactorAlpha != blendState.dstFactorAlpha) {
blendState.srcFactor = srcFactor;
blendState.dstFactor = dstFactor;
blendState.srcFactorAlpha = srcFactorAlpha;
@@ -408,34 +409,18 @@ public class GlStateManager {
}
}
- public static void glTexImage2D(
- int target,
- int level,
- int internalFormat,
- int width,
- int height,
- int border,
- int format,
- int type,
- @Nullable IntBuffer pixels) {
+ public static void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border,
+ int format, int type, @Nullable IntBuffer pixels) {
GL11.glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
}
- public static void glTexSubImage2D(
- int target,
- int level,
- int xOffset,
- int yOffset,
- int width,
- int height,
- int format,
- int type,
- IntBuffer pixels) {
+ public static void glTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height,
+ int format, int type, IntBuffer pixels) {
GL11.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, pixels);
}
- public static void glCopyTexSubImage2D(
- int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) {
+ public static void glCopyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width,
+ int height) {
GL11.glCopyTexSubImage2D(target, level, xOffset, yOffset, x, y, width, height);
}
@@ -471,10 +456,9 @@ public class GlStateManager {
}
public static void colorMask(boolean red, boolean green, boolean blue, boolean alpha) {
- if (red != colorMaskState.red
- || green != colorMaskState.green
- || blue != colorMaskState.blue
- || alpha != colorMaskState.alpha) {
+ if (red != colorMaskState.red || green != colorMaskState.green
+ || blue != colorMaskState.blue
+ || alpha != colorMaskState.alpha) {
colorMaskState.red = red;
colorMaskState.green = green;
colorMaskState.blue = blue;
@@ -491,10 +475,9 @@ public class GlStateManager {
}
public static void clearColor(float red, float green, float blue, float alpha) {
- if (red != clearState.color.red
- || green != clearState.color.green
- || blue != clearState.color.blue
- || alpha != clearState.color.alpha) {
+ if (red != clearState.color.red || green != clearState.color.green
+ || blue != clearState.color.blue
+ || alpha != clearState.color.alpha) {
clearState.color.red = red;
clearState.color.green = green;
clearState.color.blue = blue;
@@ -591,10 +574,9 @@ public class GlStateManager {
}
public static void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) {
- if (colorRed != colorState.red
- || colorGreen != colorState.green
- || colorBlue != colorState.blue
- || colorAlpha != colorState.alpha) {
+ if (colorRed != colorState.red || colorGreen != colorState.green
+ || colorBlue != colorState.blue
+ || colorAlpha != colorState.alpha) {
colorState.red = colorRed;
colorState.green = colorGreen;
colorState.blue = colorBlue;
@@ -756,6 +738,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class AlphaState {
+
public GlStateManager.BooleanState alphaTest;
public int func;
public float ref;
@@ -769,6 +752,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class BlendState {
+
public GlStateManager.BooleanState blend;
public int srcFactor;
public int dstFactor;
@@ -786,6 +770,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class BooleanState {
+
private final int capability;
private boolean currentState;
@@ -816,6 +801,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class ClearState {
+
public double depth;
public GlStateManager.Color color;
@@ -827,6 +813,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class Color {
+
public float red;
public float green;
public float blue;
@@ -850,6 +837,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class ColorLogicState {
+
public GlStateManager.BooleanState colorLogicOp;
public int opcode;
@@ -861,6 +849,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class ColorMask {
+
public boolean red;
public boolean green;
public boolean blue;
@@ -876,6 +865,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class ColorMaterialState {
+
public GlStateManager.BooleanState colorMaterial;
public int face;
public int mode;
@@ -889,6 +879,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
public static enum CullFace {
+
FRONT(1028),
BACK(1029),
FRONT_AND_BACK(1032);
@@ -902,6 +893,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class CullState {
+
public GlStateManager.BooleanState cullFace;
public int mode;
@@ -913,6 +905,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class DepthState {
+
public GlStateManager.BooleanState depthTest;
public boolean maskEnabled;
public int depthFunc;
@@ -926,6 +919,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
public static enum DestFactor {
+
CONSTANT_ALPHA(32771),
CONSTANT_COLOR(32769),
DST_ALPHA(772),
@@ -950,6 +944,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
public static enum FogMode {
+
LINEAR(9729),
EXP(2048),
EXP2(2049);
@@ -963,6 +958,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class FogState {
+
public GlStateManager.BooleanState fog;
public int mode;
public float density;
@@ -979,6 +975,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
public static enum LogicOp {
+
AND(5377),
AND_INVERTED(5380),
AND_REVERSE(5378),
@@ -1005,6 +1002,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class PolygonOffsetState {
+
public GlStateManager.BooleanState polygonOffsetFill;
public GlStateManager.BooleanState polygonOffsetLine;
public float factor;
@@ -1018,7 +1016,9 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
public static enum Profile {
+
DEFAULT {
+
public void apply() {
GlStateManager.disableAlpha();
GlStateManager.alphaFunc(519, 0.0F);
@@ -1032,14 +1032,22 @@ public class GlStateManager {
if (i == 0) {
GL11.glLight(
- GL11.GL_LIGHT0 + i, GL11.GL_DIFFUSE, reflectSetColorBuffer(1.0F, 1.0F, 1.0F, 1.0F));
+ GL11.GL_LIGHT0 + i,
+ GL11.GL_DIFFUSE,
+ reflectSetColorBuffer(1.0F, 1.0F, 1.0F, 1.0F));
GL11.glLight(
- GL11.GL_LIGHT0 + i, GL11.GL_SPECULAR, reflectSetColorBuffer(1.0F, 1.0F, 1.0F, 1.0F));
+ GL11.GL_LIGHT0 + i,
+ GL11.GL_SPECULAR,
+ reflectSetColorBuffer(1.0F, 1.0F, 1.0F, 1.0F));
} else {
GL11.glLight(
- GL11.GL_LIGHT0 + i, GL11.GL_DIFFUSE, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
+ GL11.GL_LIGHT0 + i,
+ GL11.GL_DIFFUSE,
+ reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glLight(
- GL11.GL_LIGHT0 + i, GL11.GL_SPECULAR, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
+ GL11.GL_LIGHT0 + i,
+ GL11.GL_SPECULAR,
+ reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
}
}
@@ -1051,10 +1059,10 @@ public class GlStateManager {
GlStateManager.disableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.tryBlendFuncSeparate(
- GlStateManager.SourceFactor.ONE,
- GlStateManager.DestFactor.ZERO,
- GlStateManager.SourceFactor.ONE,
- GlStateManager.DestFactor.ZERO);
+ GlStateManager.SourceFactor.ONE,
+ GlStateManager.DestFactor.ZERO,
+ GlStateManager.SourceFactor.ONE,
+ GlStateManager.DestFactor.ZERO);
GL14.glBlendEquation(GL14.GL_FUNC_ADD);
GlStateManager.disableFog();
GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
@@ -1097,7 +1105,9 @@ public class GlStateManager {
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
GL11.glTexEnv(
- GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F));
+ GL11.GL_TEXTURE_ENV,
+ GL11.GL_TEXTURE_ENV_COLOR,
+ reflectSetColorBuffer(0.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_COMBINE_RGB, GL11.GL_MODULATE);
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL13.GL_COMBINE_ALPHA, GL11.GL_MODULATE);
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL15.GL_SRC0_RGB, GL11.GL_TEXTURE);
@@ -1128,6 +1138,7 @@ public class GlStateManager {
public void clean() {}
},
PLAYER_SKIN {
+
public void apply() {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
@@ -1138,12 +1149,13 @@ public class GlStateManager {
}
},
TRANSPARENT_MODEL {
+
public void apply() {
GlStateManager.color(1.0F, 1.0F, 1.0F, 0.15F);
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
- GlStateManager.blendFunc(
- GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
+ GlStateManager
+ .blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.alphaFunc(516, 0.003921569F);
}
@@ -1163,6 +1175,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
public static enum SourceFactor {
+
CONSTANT_ALPHA(32771),
CONSTANT_COLOR(32769),
DST_ALPHA(772),
@@ -1188,6 +1201,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class StencilFunc {
+
public int func;
public int mask;
@@ -1199,6 +1213,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class StencilState {
+
public GlStateManager.StencilFunc func;
public int mask;
public int fail;
@@ -1224,6 +1239,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class TexGenCoord {
+
public GlStateManager.BooleanState textureGen;
public int coord;
public int param = -1;
@@ -1236,6 +1252,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class TexGenState {
+
public GlStateManager.TexGenCoord s;
public GlStateManager.TexGenCoord t;
public GlStateManager.TexGenCoord r;
@@ -1251,6 +1268,7 @@ public class GlStateManager {
@SideOnly(Side.CLIENT)
static class TextureState {
+
public GlStateManager.BooleanState texture2DState;
public int textureName;
@@ -1259,12 +1277,12 @@ public class GlStateManager {
}
}
- private static FloatBuffer reflectSetColorBuffer(
- float p_74521_0_, float p_74521_1_, float p_74521_2_, float p_74521_3_) {
+ private static FloatBuffer reflectSetColorBuffer(float p_74521_0_, float p_74521_1_, float p_74521_2_,
+ float p_74521_3_) {
FloatBuffer res = null;
try {
- Method m = RenderHelper.class.getDeclaredMethod(
- "setColorBuffer", float.class, float.class, float.class, float.class);
+ Method m = RenderHelper.class
+ .getDeclaredMethod("setColorBuffer", float.class, float.class, float.class, float.class);
m.setAccessible(true);
res = (FloatBuffer) m.invoke(null, p_74521_0_, p_74521_1_, p_74521_2_, p_74521_3_);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
diff --git a/src/main/java/me/towdium/jecalculation/polyfill/mc/util/NonNullList.java b/src/main/java/me/towdium/jecalculation/polyfill/mc/util/NonNullList.java
index 4f24590..8a868c8 100644
--- a/src/main/java/me/towdium/jecalculation/polyfill/mc/util/NonNullList.java
+++ b/src/main/java/me/towdium/jecalculation/polyfill/mc/util/NonNullList.java
@@ -4,11 +4,14 @@ import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+
import org.apache.commons.lang3.Validate;
public class NonNullList extends AbstractList {
+
private final List delegate;
private final E defaultElement;
diff --git a/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/MathHelper.java b/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/MathHelper.java
index 80c3bf9..6653f96 100644
--- a/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/MathHelper.java
+++ b/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/MathHelper.java
@@ -1,11 +1,13 @@
package me.towdium.jecalculation.polyfill.mc.util.math;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import java.util.UUID;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
public class MathHelper {
+
public static final float SQRT_2 = sqrt(2.0F);
private static final float[] SIN_TABLE = new float[65536];
private static final Random RANDOM = new Random();
@@ -430,8 +432,12 @@ public class MathHelper {
f6 = f2;
break;
default:
- throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + hue
- + ", " + saturation + ", " + value);
+ throw new RuntimeException(
+ "Something went wrong when converting from HSV to RGB. Input was " + hue
+ + ", "
+ + saturation
+ + ", "
+ + value);
}
int j = clamp((int) (f4 * 255.0F), 0, 255);
@@ -454,10 +460,8 @@ public class MathHelper {
SIN_TABLE[i] = (float) Math.sin((double) i * Math.PI * 2.0D / 65536.0D);
}
- 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
- };
+ 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 };
FRAC_BIAS = Double.longBitsToDouble(4805340802404319232L);
ASINE_TAB = new double[257];
COS_TAB = new double[257];
diff --git a/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/Vec3i.java b/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/Vec3i.java
index 2597834..1b75fc5 100644
--- a/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/Vec3i.java
+++ b/src/main/java/me/towdium/jecalculation/polyfill/mc/util/math/Vec3i.java
@@ -1,10 +1,12 @@
package me.towdium.jecalculation.polyfill.mc.util.math;
-import com.google.common.base.Objects;
import javax.annotation.concurrent.Immutable;
+import com.google.common.base.Objects;
+
@Immutable
public class Vec3i implements Comparable {
+
public static final Vec3i NULL_VECTOR = new Vec3i(0, 0, 0);
private final int x;
private final int y;
@@ -44,9 +46,8 @@ public class Vec3i implements Comparable {
public int compareTo(Vec3i p_compareTo_1_) {
if (this.getY() == p_compareTo_1_.getY()) {
- return this.getZ() == p_compareTo_1_.getZ()
- ? this.getX() - p_compareTo_1_.getX()
- : this.getZ() - p_compareTo_1_.getZ();
+ return this.getZ() == p_compareTo_1_.getZ() ? this.getX() - p_compareTo_1_.getX()
+ : this.getZ() - p_compareTo_1_.getZ();
} else {
return this.getY() - p_compareTo_1_.getY();
}
@@ -66,9 +67,9 @@ public class Vec3i implements Comparable {
public Vec3i crossProduct(Vec3i vec) {
return new Vec3i(
- this.getY() * vec.getZ() - this.getZ() * vec.getY(),
- this.getZ() * vec.getX() - this.getX() * vec.getZ(),
- this.getX() * vec.getY() - this.getY() * vec.getX());
+ this.getY() * vec.getZ() - this.getZ() * vec.getY(),
+ this.getZ() * vec.getX() - this.getX() * vec.getZ(),
+ this.getX() * vec.getY() - this.getY() * vec.getX());
}
public double getDistance(int xIn, int yIn, int zIn) {
@@ -98,9 +99,9 @@ public class Vec3i implements Comparable {
public String toString() {
return Objects.toStringHelper(this)
- .add("x", this.getX())
- .add("y", this.getY())
- .add("z", this.getZ())
- .toString();
+ .add("x", this.getX())
+ .add("y", this.getY())
+ .add("z", this.getZ())
+ .toString();
}
}
diff --git a/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java b/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java
index 17857c3..1faf617 100644
--- a/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java
+++ b/src/main/java/me/towdium/jecalculation/utils/ClientUtils.java
@@ -5,6 +5,7 @@ import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
public class ClientUtils {
+
public static Minecraft mc() {
return Minecraft.getMinecraft();
}
@@ -12,7 +13,7 @@ public class ClientUtils {
public static void playClickSound(float pitchIn) {
try {
mc().getSoundHandler()
- .playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), pitchIn));
+ .playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), pitchIn));
} catch (Exception e) {
// why may crash ??
e.printStackTrace();
diff --git a/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java b/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java
index 3bfbb16..9b8945b 100644
--- a/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java
+++ b/src/main/java/me/towdium/jecalculation/utils/ItemStackHelper.java
@@ -4,6 +4,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemStackHelper {
+
public static final Item EMPTY_ITEM = null;
public static final ItemStack EMPTY_ITEM_STACK = new ItemStack((Item) null);
diff --git a/src/main/java/me/towdium/jecalculation/utils/NBTJson.java b/src/main/java/me/towdium/jecalculation/utils/NBTJson.java
index 6b5d955..82b5d94 100644
--- a/src/main/java/me/towdium/jecalculation/utils/NBTJson.java
+++ b/src/main/java/me/towdium/jecalculation/utils/NBTJson.java
@@ -1,6 +1,5 @@
package me.towdium.jecalculation.utils;
-import com.google.gson.*;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -8,9 +7,13 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
+
import net.minecraft.nbt.*;
+import com.google.gson.*;
+
public class NBTJson {
+
private static final Pattern numberPattern = Pattern.compile("^([-+]?[\\d]+\\.?[0-9]*)([bBsSlLfFdD]?)$");
private static final JsonParser parser = new JsonParser();
private static final Gson gson = new GsonBuilder().create();
@@ -71,8 +74,10 @@ public class NBTJson {
if (m.find()) {
// Number
final String numberString = m.group(1);
- if (m.groupCount() == 2 && m.group(2).length() > 0) {
- final char numberType = m.group(2).charAt(0);
+ if (m.groupCount() == 2 && m.group(2)
+ .length() > 0) {
+ final char numberType = m.group(2)
+ .charAt(0);
switch (numberType) {
case 'b':
case 'B':
@@ -107,19 +112,24 @@ public class NBTJson {
nbtList.add(toNbt(element));
}
- if (nbtList.stream().allMatch(n -> n instanceof NBTTagInt)) {
- return new NBTTagIntArray(nbtList.stream()
+ if (nbtList.stream()
+ .allMatch(n -> n instanceof NBTTagInt)) {
+ return new NBTTagIntArray(
+ nbtList.stream()
.mapToInt(i -> ((NBTTagInt) i).func_150287_d())
.toArray());
- } else if (nbtList.stream().allMatch(n -> n instanceof NBTTagByte)) {
- return new NBTTagByteArray(
- toByteArray(nbtList.stream().mapToInt(i -> ((NBTTagInt) i).func_150287_d())));
- } else {
- NBTTagList nbtTagList = new NBTTagList();
- nbtList.forEach(nbtTagList::appendTag);
+ } else if (nbtList.stream()
+ .allMatch(n -> n instanceof NBTTagByte)) {
+ return new NBTTagByteArray(
+ toByteArray(
+ nbtList.stream()
+ .mapToInt(i -> ((NBTTagInt) i).func_150287_d())));
+ } else {
+ NBTTagList nbtTagList = new NBTTagList();
+ nbtList.forEach(nbtTagList::appendTag);
- return nbtTagList;
- }
+ return nbtTagList;
+ }
} else if (jsonElement instanceof JsonObject) {
// NBTTagCompound
final JsonObject jsonObject = (JsonObject) jsonElement;
@@ -134,10 +144,11 @@ public class NBTJson {
}
public static byte[] toByteArray(IntStream stream) {
- return stream.collect(
- ByteArrayOutputStream::new,
- (baos, i) -> baos.write((byte) i),
- (baos1, baos2) -> baos1.write(baos2.toByteArray(), 0, baos2.size()))
- .toByteArray();
+ return stream
+ .collect(
+ ByteArrayOutputStream::new,
+ (baos, i) -> baos.write((byte) i),
+ (baos1, baos2) -> baos1.write(baos2.toByteArray(), 0, baos2.size()))
+ .toByteArray();
}
}
diff --git a/src/main/java/me/towdium/jecalculation/utils/ReflectionHelper.java b/src/main/java/me/towdium/jecalculation/utils/ReflectionHelper.java
index 78cf7b9..205c71d 100644
--- a/src/main/java/me/towdium/jecalculation/utils/ReflectionHelper.java
+++ b/src/main/java/me/towdium/jecalculation/utils/ReflectionHelper.java
@@ -4,16 +4,18 @@ import java.lang.reflect.Field;
/**
* Author: Towdium
- * Date: 2016/6/25.
+ * Date: 2016/6/25.
*/
public class ReflectionHelper {
+
@SuppressWarnings("unchecked")
public static T getField(C o, String... names) {
Field field = null;
boolean flag = false;
for (String name : names) {
try {
- field = o.getClass().getDeclaredField(name);
+ field = o.getClass()
+ .getDeclaredField(name);
} catch (NoSuchFieldException e) {
continue;
}
@@ -21,8 +23,9 @@ public class ReflectionHelper {
break;
}
if (!flag) {
- StringBuilder buffer =
- new StringBuilder("Field not found in class " + o.getClass().getCanonicalName() + ":");
+ StringBuilder buffer = new StringBuilder(
+ "Field not found in class " + o.getClass()
+ .getCanonicalName() + ":");
for (String s : names) {
buffer.append(" ");
buffer.append(s);
@@ -42,7 +45,8 @@ public class ReflectionHelper {
public static T get(C o, String name) {
T res;
try {
- Field field = o.getClass().getDeclaredField(name);
+ Field field = o.getClass()
+ .getDeclaredField(name);
field.setAccessible(true);
res = (T) field.get(o);
} catch (NoSuchFieldException | IllegalAccessException e) {
@@ -54,7 +58,8 @@ public class ReflectionHelper {
public static void set(C o, String name, T value) {
try {
- Field field = o.getClass().getDeclaredField(name);
+ Field field = o.getClass()
+ .getDeclaredField(name);
field.setAccessible(true);
field.set(o, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
diff --git a/src/main/java/me/towdium/jecalculation/utils/Utilities.java b/src/main/java/me/towdium/jecalculation/utils/Utilities.java
index 923d008..15cabbc 100644
--- a/src/main/java/me/towdium/jecalculation/utils/Utilities.java
+++ b/src/main/java/me/towdium/jecalculation/utils/Utilities.java
@@ -2,14 +2,6 @@ package me.towdium.jecalculation.utils;
import static net.minecraft.client.resources.I18n.format;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
-import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.ModContainer;
-import cpw.mods.fml.common.registry.GameData;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -23,12 +15,10 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
+
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
-import me.towdium.jecalculation.JustEnoughCalculation;
-import me.towdium.jecalculation.Tags;
-import me.towdium.jecalculation.polyfill.NBTHelper;
-import me.towdium.jecalculation.utils.wrappers.Pair;
+
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.Item;
@@ -37,26 +27,37 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.text.WordUtils;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
+
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.ModContainer;
+import cpw.mods.fml.common.registry.GameData;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import me.towdium.jecalculation.JustEnoughCalculation;
+import me.towdium.jecalculation.Tags;
+import me.towdium.jecalculation.polyfill.NBTHelper;
+import me.towdium.jecalculation.utils.wrappers.Pair;
+
/**
* Author: Towdium
- * Date: 2016/6/25.
+ * Date: 2016/6/25.
*/
-@SuppressWarnings({"unused", "UnusedReturnValue"})
+@SuppressWarnings({ "unused", "UnusedReturnValue" })
@ParametersAreNonnullByDefault
public class Utilities {
+
// FLOAT FORMATTING
- public static char[] suffix = new char[] {'K', 'M', 'B', 'G', 'T', 'P'};
- public static DecimalFormat[] format = new DecimalFormat[] {
- new DecimalFormat("#."),
- new DecimalFormat("#.#"),
- new DecimalFormat("#.##"),
- new DecimalFormat("#.###"),
- new DecimalFormat("#.####")
- };
+ public static char[] suffix = new char[] { 'K', 'M', 'B', 'G', 'T', 'P' };
+ public static DecimalFormat[] format = new DecimalFormat[] { new DecimalFormat("#."), new DecimalFormat("#.#"),
+ new DecimalFormat("#.##"), new DecimalFormat("#.###"), new DecimalFormat("#.####") };
public static String cutNumber(float f, int size) {
BiFunction form = (fl, len) -> format[len - 1 - (int) Math.log10(fl)].format(fl);
@@ -67,7 +68,8 @@ public class Utilities {
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public static Stream stream(Optional o) {
- return o.map(Stream::of).orElse(Stream.empty());
+ return o.map(Stream::of)
+ .orElse(Stream.empty());
}
public static Supplier fake(Runnable r) {
@@ -88,13 +90,16 @@ public class Utilities {
public static String getModName(Item item) {
String name = getName(item);
String id = name.substring(0, name.indexOf(":"));
- return id.equals("minecraft")
- ? "Minecraft"
- : Loader.instance().getIndexedModList().get(id).getName();
+ return id.equals("minecraft") ? "Minecraft"
+ : Loader.instance()
+ .getIndexedModList()
+ .get(id)
+ .getName();
}
public static String getName(Item item) {
- return GameData.getItemRegistry().getNameForObject(item);
+ return GameData.getItemRegistry()
+ .getNameForObject(item);
}
public static String getName(ItemStack itemStack) {
@@ -122,7 +127,8 @@ public class Utilities {
String iconName = icon.getIconName();
String modId = iconName.split(":")[0];
- Map indexedModList = Loader.instance().getIndexedModList();
+ Map indexedModList = Loader.instance()
+ .getIndexedModList();
ModContainer modContainer = indexedModList.get(modId);
if (modContainer == null) {
String capitalizedModId = WordUtils.capitalize(modId);
@@ -157,6 +163,7 @@ public class Utilities {
}
public enum ChatMessage {
+
MAX_LOOP,
RECIPE_TRANSFER_ERROR;
@@ -173,6 +180,7 @@ public class Utilities {
}
public static class Relation {
+
public HashMap, V> data = new HashMap<>();
public void put(K a, K b, V v) {
@@ -190,6 +198,7 @@ public class Utilities {
}
public static class Timer {
+
long time = System.currentTimeMillis();
boolean running = false;
@@ -208,6 +217,7 @@ public class Utilities {
@SuppressWarnings("UnusedReturnValue")
public static class Circulator {
+
int total, current;
public Circulator(int total) {
@@ -250,6 +260,7 @@ public class Utilities {
}
public static class ReversedIterator implements Iterator {
+
ListIterator i;
public ReversedIterator(List l) {
@@ -278,6 +289,7 @@ public class Utilities {
@SideOnly(Side.CLIENT)
public static class I18n {
+
public static boolean contains(String s1, String s2) {
return s1.contains(s2);
}
@@ -297,18 +309,18 @@ public class Utilities {
}
public static List wrap(String s, int width) {
- return new TextWrapper()
- .wrap(
- s,
- ClientUtils.mc()
- .getLanguageManager()
- .getCurrentLanguage()
- .getLanguageCode(),
- i -> TextWrapper.renderer.getCharWidth(i),
- width);
+ return new TextWrapper().wrap(
+ s,
+ ClientUtils.mc()
+ .getLanguageManager()
+ .getCurrentLanguage()
+ .getLanguageCode(),
+ i -> TextWrapper.renderer.getCharWidth(i),
+ width);
}
static class TextWrapper {
+
static FontRenderer renderer = ClientUtils.mc().fontRenderer;
String str;
@@ -367,6 +379,7 @@ public class Utilities {
}
public static class Recent {
+
LinkedList data = new LinkedList<>();
BiPredicate tester;
int limit;
@@ -402,6 +415,7 @@ public class Utilities {
}
public static class Json {
+
@Nullable
public static NBTTagCompound read(File f) {
try {
@@ -458,6 +472,8 @@ public class Utilities {
}
public static String[] mergeStringArrays(String[]... arrays) {
- return Stream.of(arrays).flatMap(Stream::of).toArray(String[]::new);
+ return Stream.of(arrays)
+ .flatMap(Stream::of)
+ .toArray(String[]::new);
}
}
diff --git a/src/main/java/me/towdium/jecalculation/utils/Version.java b/src/main/java/me/towdium/jecalculation/utils/Version.java
index d3342cc..d7315b8 100644
--- a/src/main/java/me/towdium/jecalculation/utils/Version.java
+++ b/src/main/java/me/towdium/jecalculation/utils/Version.java
@@ -1,11 +1,13 @@
package me.towdium.jecalculation.utils;
import javax.annotation.ParametersAreNonnullByDefault;
+
import me.towdium.jecalculation.polyfill.MethodsReturnNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class Version implements Comparable {
+
private int major = 0, minor = 0, patch = 0;
private String preRelease = "";
private final boolean success;
diff --git a/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java b/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java
index 4fad0b6..3fb67ef 100644
--- a/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java
+++ b/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java
@@ -2,9 +2,10 @@ package me.towdium.jecalculation.utils.wrappers;
/**
* Author: Towdium
- * Date: 2016/7/1.
+ * Date: 2016/7/1.
*/
public class Pair