aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2022-02-06 21:52:14 +0100
committerTec <daniel112092@gmail.com>2022-02-06 21:54:10 +0100
commita95469c70c6b4b16b49937ce563bba589962f17b (patch)
tree7df21e6ea20b0d903c8f7d546cb22c9452359187 /src/main/java/com
parentfe3e8abfbb46a4fd75906e3d41e0dfb4435b8403 (diff)
downloadGT5-Unofficial-a95469c70c6b4b16b49937ce563bba589962f17b.tar.gz
GT5-Unofficial-a95469c70c6b4b16b49937ce563bba589962f17b.tar.bz2
GT5-Unofficial-a95469c70c6b4b16b49937ce563bba589962f17b.zip
Some super scripting
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java10
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java3
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java3
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java12
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java4
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java3
-rw-r--r--src/main/java/com/github/technus/tectech/util/TT_Utility.java310
7 files changed, 193 insertions, 152 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java
index e14a034b81..03c57a754e 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/EMAtomDefinition.java
@@ -14,6 +14,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMNeutrinoDefinition;
+import com.github.technus.tectech.util.TT_Utility;
import com.github.technus.tectech.util.XSTR;
import java.util.*;
@@ -370,7 +371,14 @@ public class EMAtomDefinition extends EMComplexTemplate {
@Override
public String getSymbol() {
- return getShortSymbol() + " N:" + getNeutralCount() + " I:" + (getNeutralCount() + getElement()) + " C:" + getCharge();
+ String ionName = "";
+ int ionization = getCharge() / 3;
+ if(ionization>0){
+ ionName = ionization == 1 ? TT_Utility.toSuperscript("+") : TT_Utility.toSuperscript(ionization + "+");
+ }else if(ionization<0) {
+ ionName = ionization == -1 ? TT_Utility.toSuperscript("-") : TT_Utility.toSuperscript(-ionization + "-");
+ }
+ return TT_Utility.toSuperscript(Long.toString(getNeutralCount() + (long)getElement())) +getShortSymbol()+ ionName;
}
@Override
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java
index cf59c1fffd..8b1e1d556b 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMGaugeBosonDefinition.java
@@ -4,6 +4,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
+import com.github.technus.tectech.util.TT_Utility;
import static com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay.NO_DECAY;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*;
@@ -27,7 +28,7 @@ public class EMGaugeBosonDefinition extends EMBosonDefinition {
public static final EMDecay deadEndHalf = new EMDecay(boson_Y__1);
protected EMGaugeBosonDefinition(String name, String symbol, double mass, int charge, int color, int ID, String bind) {
- super(name, symbol, 0, mass, charge, color, ID, bind);
+ super(name, TT_Utility.toSuperscript(symbol), 0, mass, charge, color, ID, bind);
}
public static void run(EMDefinitionsRegistry registry) {
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java
index 324d790de6..0926b34425 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMLeptonDefinition.java
@@ -4,6 +4,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType;
import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack;
+import com.github.technus.tectech.util.TT_Utility;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.boson_Y__;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.deadEnd;
@@ -29,7 +30,7 @@ public class EMLeptonDefinition extends EMFermionDefinition {
public static final EMDefinitionStack lepton_e_2 = new EMDefinitionStack(lepton_e_, 2);
protected EMLeptonDefinition(String name, String symbol, int type, double mass, int charge, int ID,String bind) {
- super(name, symbol, type, mass, charge, -1, ID,bind);
+ super(name, TT_Utility.toSuperscript(symbol), type, mass, charge, -1, ID,bind);
//this.itemThing=null;
//this.fluidThing=null;
}
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java
index 9bb05d2cbf..fee5774e15 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMNeutrinoDefinition.java
@@ -14,12 +14,12 @@ import static net.minecraft.util.StatCollector.translateToLocal;
*/
public class EMNeutrinoDefinition extends EMLeptonDefinition {
public static final EMNeutrinoDefinition
- lepton_Ve = new EMNeutrinoDefinition("tt.keyword.ElectronNeutrino", "\u03bd\u03b2", 1, 2e0D, 21,"Ve-"),
- lepton_Vm = new EMNeutrinoDefinition("tt.keyword.MuonNeutrino", "\u03bd\u03bc", 2, 0.15e6D, 23,"Vm-"),
- lepton_Vt = new EMNeutrinoDefinition("tt.keyword.TauonNeutrino", "\u03bd\u03c4", 3, 15e6D, 25,"Vt-"),
- lepton_Ve_ = new EMNeutrinoDefinition("tt.keyword.PositronNeutrino", "~\u03bd\u03b2", -1, 2e0D, 22,"Ve+"),
- lepton_Vm_ = new EMNeutrinoDefinition("tt.keyword.AntimuonNeutrino", "~\u03bd\u03bc", -2, 0.15e6D, 24,"Vm+"),
- lepton_Vt_ = new EMNeutrinoDefinition("tt.keyword.AntitauonNeutrino", "~\u03bd\u03c4", -3, 15e6D, 26,"Vt+");
+ lepton_Ve = new EMNeutrinoDefinition("tt.keyword.ElectronNeutrino", "\u03bd\u03b2", 1, 2e0D, 21,"Ve"),
+ lepton_Vm = new EMNeutrinoDefinition("tt.keyword.MuonNeutrino", "\u03bd\u03bc", 2, 0.15e6D, 23,"Vm"),
+ lepton_Vt = new EMNeutrinoDefinition("tt.keyword.TauonNeutrino", "\u03bd\u03c4", 3, 15e6D, 25,"Vt"),
+ lepton_Ve_ = new EMNeutrinoDefinition("tt.keyword.PositronNeutrino", "~\u03bd\u03b2", -1, 2e0D, 22,"~Ve"),
+ lepton_Vm_ = new EMNeutrinoDefinition("tt.keyword.AntimuonNeutrino", "~\u03bd\u03bc", -2, 0.15e6D, 24,"~Vm"),
+ lepton_Vt_ = new EMNeutrinoDefinition("tt.keyword.AntitauonNeutrino", "~\u03bd\u03c4", -3, 15e6D, 26,"~Vt");
public static final EMDefinitionStack lepton_Ve1 = new EMDefinitionStack(lepton_Ve, 1);
public static final EMDefinitionStack lepton_Ve2 = new EMDefinitionStack(lepton_Ve, 2);
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java
index 785d426a0b..c2b77f7704 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMPrimitiveDefinition.java
@@ -16,8 +16,8 @@ public class EMPrimitiveDefinition extends EMPrimitiveTemplate {
null__ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveNULLPOINTER" , "." , 0 , 0D , -3 , Integer.MIN_VALUE+1 , "." ),
space = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveSpace" , "_" , 0 , 0D , -4 , Integer.MIN_VALUE + 2 , "_" ),
space_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitivePresence" , "~_" , 0 , 0D , -4 , Integer.MIN_VALUE + 3 , "~_" ),
- mass = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveMass" , "#" , 0 , 1 , -4 , Integer.MIN_VALUE + 4 , "#" ),
- mass_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveDarkMass" , "~#" , 0 , 1 , -4 , Integer.MIN_VALUE + 5 , "~#" ),
+ mass = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveMass" , "*" , 0 , 1 , -4 , Integer.MIN_VALUE + 4 , "*" ),
+ mass_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveDarkMass" , "~*" , 0 , 1 , -4 , Integer.MIN_VALUE + 5 , "~*" ),
energy = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveEnergy" , "E" , 4 , 0D , -4 , Integer.MIN_VALUE + 6 , "E" ),
energy_ = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveDarkEnergy" , "~E" , -4 , 0 , -4 , Integer.MIN_VALUE + 7 , "~E" ),
magic = new EMPrimitiveDefinition ( "tt.keyword.PrimitiveMagic" , "Ma" , 5 , 1e5D , 0 , Integer.MIN_VALUE + 8 , "Ma" ),
diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java
index 760ce48068..c90e89108b 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/primitive/EMScalarBosonDefinition.java
@@ -3,6 +3,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.definitions.primiti
import com.github.technus.tectech.mechanics.elementalMatter.core.decay.EMDecay;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMDefinitionsRegistry;
import com.github.technus.tectech.mechanics.elementalMatter.core.definitions.registry.EMType;
+import com.github.technus.tectech.util.TT_Utility;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMGaugeBosonDefinition.*;
import static com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.EMLeptonDefinition.*;
@@ -17,7 +18,7 @@ public class EMScalarBosonDefinition extends EMBosonDefinition {
boson_H__ = new EMScalarBosonDefinition("tt.keyword.Higgs", "H0", 125.09e9D, -2, 32,"H0");
private EMScalarBosonDefinition(String name, String symbol, double mass, int color, int ID,String bind) {
- super(name, symbol, 0, mass, 0, color, ID,bind);
+ super(name,TT_Utility.toSuperscript(symbol), 0, mass, 0, color, ID,bind);
}
public static void run(EMDefinitionsRegistry registry) {
diff --git a/src/main/java/com/github/technus/tectech/util/TT_Utility.java b/src/main/java/com/github/technus/tectech/util/TT_Utility.java
index a9732e294a..2b67f72ff0 100644
--- a/src/main/java/com/github/technus/tectech/util/TT_Utility.java
+++ b/src/main/java/com/github/technus/tectech/util/TT_Utility.java
@@ -41,23 +41,24 @@ import java.util.function.Function;
public final class TT_Utility {
private TT_Utility() {
}
- private static final StringBuilder STRING_BUILDER =new StringBuilder();
- private static final Map<Locale, Formatter> FORMATTER_MAP =new HashMap<>();
- private static Formatter getFormatter(){
+ private static final StringBuilder STRING_BUILDER = new StringBuilder();
+ private static final Map<Locale, Formatter> FORMATTER_MAP = new HashMap<>();
+
+ private static Formatter getFormatter() {
STRING_BUILDER.setLength(0);
- return FORMATTER_MAP.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), locale -> new Formatter(STRING_BUILDER,locale));
+ return FORMATTER_MAP.computeIfAbsent(Locale.getDefault(Locale.Category.FORMAT), locale -> new Formatter(STRING_BUILDER, locale));
}
- public static String formatNumberShortExp(double value){
+ public static String formatNumberShortExp(double value) {
return getFormatter().format("%.3E", value).toString();
}
- public static String formatNumberExp(double value){
+ public static String formatNumberExp(double value) {
return getFormatter().format("%+.5E", value).toString();
}
- public static String formatNumberIntHex(int value){
+ public static String formatNumberIntHex(int value) {
return getFormatter().format("%08X", value).toString();
}
@@ -73,33 +74,63 @@ public final class TT_Utility {
return sortedEntries;
}
- public static int bitStringToInt(String bits){
- if(bits==null){
+ public static int bitStringToInt(String bits) {
+ if (bits == null) {
return 0;
}
- if(bits.length() > 32){
+ if (bits.length() > 32) {
throw new NumberFormatException("Too long!");
}
- return Integer.parseInt(bits,2);
+ return Integer.parseInt(bits, 2);
}
- public static int hexStringToInt(String hex){
- if(hex==null){
+ public static int hexStringToInt(String hex) {
+ if (hex == null) {
return 0;
}
- if(hex.length()>8){
+ if (hex.length() > 8) {
throw new NumberFormatException("Too long!");
}
- return Integer.parseInt(hex,16);
+ return Integer.parseInt(hex, 16);
}
- public static double stringToDouble(String str){
- if(str==null){
+ public static double stringToDouble(String str) {
+ if (str == null) {
return 0;
}
return Double.parseDouble(str);
}
+ private static final String SUPER_SCRIPT = "\u207D\u207E*\u207A,\u207B./\u2070\u00B9\u00B2\u00B3\u2074\u2075\u2076\u2077\u2078\u2079:;<\u207C";
+ private static final String SUB_SCRIPT = "\u208D\u208E*\u208A,\u208B./\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089:;<\u208C";
+
+ public static String toSubscript(String s) {
+ STRING_BUILDER.setLength(0);
+ for (int i = 0; i <s.length(); i++) {
+ char c=s.charAt(i);
+ if(c>='('&&c<='='){
+ STRING_BUILDER.append(SUB_SCRIPT.charAt(c-'('));
+ }else {
+ STRING_BUILDER.append(c);
+ }
+ }
+ return STRING_BUILDER.toString();
+ }
+
+ public static String toSuperscript(String s) {
+ STRING_BUILDER.setLength(0);
+ for (int i = 0; i <s.length(); i++) {
+ char c=s.charAt(i);
+ if(c>='('&&c<='='){
+ STRING_BUILDER.append(SUPER_SCRIPT.charAt(c-'('));
+ }else {
+ STRING_BUILDER.append(c);
+ }
+ }
+ return STRING_BUILDER.toString();
+ }
+
+
public static double getValue(String in1) {
String str = in1.toLowerCase();
double val;
@@ -299,7 +330,7 @@ public final class TT_Utility {
public static String[] splitButDifferent(String string, String delimiter) {
String[] strings = new String[StringUtils.countMatches(string, delimiter) + 1];
- int lastEnd = 0;
+ int lastEnd = 0;
for (int i = 0; i < strings.length - 1; i++) {
int nextEnd = string.indexOf(delimiter, lastEnd);
strings[i] = string.substring(lastEnd, nextEnd);
@@ -317,8 +348,8 @@ public final class TT_Utility {
return strings;
}
- public static String getSomeString(NBTTagCompound nbt,int index) {
- return nbt.getString(Integer.toString(index%nbt.getInteger("i")));
+ public static String getSomeString(NBTTagCompound nbt, int index) {
+ return nbt.getString(Integer.toString(index % nbt.getInteger("i")));
}
public static NBTTagCompound packStrings(String... info) {
@@ -331,15 +362,15 @@ public final class TT_Utility {
}
@SuppressWarnings("unchecked")
- public static <T> T[] unpackNBT(Class<T> tClass, Function<NBTTagCompound,T> converter, NBTTagCompound nbt) {
- T[] objects = (T[])Array.newInstance(tClass,nbt.getInteger("i"));
+ public static <T> T[] unpackNBT(Class<T> tClass, Function<NBTTagCompound, T> converter, NBTTagCompound nbt) {
+ T[] objects = (T[]) Array.newInstance(tClass, nbt.getInteger("i"));
for (int i = 0; i < objects.length; i++) {
objects[i] = converter.apply(nbt.getCompoundTag(Integer.toString(i)));
}
return objects;
}
- public static <T> NBTTagCompound packNBT(Function<T,NBTTagCompound> converter, T... info) {
+ public static <T> NBTTagCompound packNBT(Function<T, NBTTagCompound> converter, T... info) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("i", info.length);
for (int i = 0; i < info.length; i++) {
@@ -354,8 +385,8 @@ public final class TT_Utility {
public static class ItemStack_NoNBT implements Comparable<ItemStack_NoNBT> {
public final Item mItem;
- public final int mStackSize;
- public final int mMetaData;
+ public final int mStackSize;
+ public final int mMetaData;
public ItemStack_NoNBT(Item aItem, long aStackSize, long aMetaData) {
this.mItem = aItem;
@@ -407,240 +438,239 @@ public final class TT_Utility {
}
}
- public static void setTier(int tier,Object me){
- try{
- Field field=GT_MetaTileEntity_TieredMachineBlock.class.getField("mTier");
+ public static void setTier(int tier, Object me) {
+ try {
+ Field field = GT_MetaTileEntity_TieredMachineBlock.class.getField("mTier");
field.setAccessible(true);
- field.set(me,(byte)tier);
- }catch (Exception e){
+ field.set(me, (byte) tier);
+ } catch (Exception e) {
//e.printStackTrace();
}
}
- public static StringBuilder receiveString(StringBuilder previousValue, int startIndex, int index, int value){
- int sizeReq=index-startIndex;
- if(value==0){
- previousValue.setLength(Math.min(previousValue.length(),sizeReq));
- }else {
- previousValue.setLength(Math.max(previousValue.length(),sizeReq));
- previousValue.setCharAt(sizeReq,(char)value);
+ public static StringBuilder receiveString(StringBuilder previousValue, int startIndex, int index, int value) {
+ int sizeReq = index - startIndex;
+ if (value == 0) {
+ previousValue.setLength(Math.min(previousValue.length(), sizeReq));
+ } else {
+ previousValue.setLength(Math.max(previousValue.length(), sizeReq));
+ previousValue.setCharAt(sizeReq, (char) value);
}
return previousValue;
}
@Deprecated
- public static double receiveDouble(double previousValue, int startIndex, int index, int value){
- return Double.longBitsToDouble(receiveLong(Double.doubleToLongBits(previousValue),startIndex,index,value));
+ public static double receiveDouble(double previousValue, int startIndex, int index, int value) {
+ return Double.longBitsToDouble(receiveLong(Double.doubleToLongBits(previousValue), startIndex, index, value));
}
- public static long receiveLong(long previousValue, int startIndex, int index, int value){
- value &=0xFFFF;
- switch (index-startIndex){
+ public static long receiveLong(long previousValue, int startIndex, int index, int value) {
+ value &= 0xFFFF;
+ switch (index - startIndex) {
case 0:
- previousValue&= 0xFFFF_FFFF_FFFF_0000L;
- previousValue|=value;
+ previousValue &= 0xFFFF_FFFF_FFFF_0000L;
+ previousValue |= value;
break;
case 1:
- previousValue&=0xFFFF_FFFF_0000_FFFFL;
- previousValue|=(long)value<<16;
+ previousValue &= 0xFFFF_FFFF_0000_FFFFL;
+ previousValue |= (long) value << 16;
break;
case 2:
- previousValue&=0xFFFF_0000_FFFF_FFFFL;
- previousValue|=(long)value<<32;
+ previousValue &= 0xFFFF_0000_FFFF_FFFFL;
+ previousValue |= (long) value << 32;
break;
case 3:
- previousValue&=0x0000_FFFF_FFFF_FFFFL;
- previousValue|=(long)value<<48;
+ previousValue &= 0x0000_FFFF_FFFF_FFFFL;
+ previousValue |= (long) value << 48;
break;
}
return previousValue;
}
- public static void sendString(StringBuilder string,Container container, ICrafting crafter,int startIndex){
+ public static void sendString(StringBuilder string, Container container, ICrafting crafter, int startIndex) {
for (int i = 0; i < string.length(); i++) {
- crafter.sendProgressBarUpdate(container,startIndex++,string.charAt(i));
+ crafter.sendProgressBarUpdate(container, startIndex++, string.charAt(i));
}
- crafter.sendProgressBarUpdate(container,startIndex,0);
+ crafter.sendProgressBarUpdate(container, startIndex, 0);
}
- public static void sendDouble(double value,Container container, ICrafting crafter,int startIndex){
- sendLong(Double.doubleToLongBits(value),container,crafter,startIndex);
+ public static void sendDouble(double value, Container container, ICrafting crafter, int startIndex) {
+ sendLong(Double.doubleToLongBits(value), container, crafter, startIndex);
}
- public static void sendLong(long value,Container container, ICrafting crafter,int startIndex){
- crafter.sendProgressBarUpdate(container, startIndex++, (int)(value & 0xFFFFL));
- crafter.sendProgressBarUpdate(container, startIndex++, (int)((value & 0xFFFF0000L)>>>16));
- crafter.sendProgressBarUpdate(container, startIndex++, (int)((value & 0xFFFF00000000L)>>>32));
- crafter.sendProgressBarUpdate(container, startIndex, (int)((value & 0xFFFF000000000000L)>>>48));
+ public static void sendLong(long value, Container container, ICrafting crafter, int startIndex) {
+ crafter.sendProgressBarUpdate(container, startIndex++, (int) (value & 0xFFFFL));
+ crafter.sendProgressBarUpdate(container, startIndex++, (int) ((value & 0xFFFF0000L) >>> 16));
+ crafter.sendProgressBarUpdate(container, startIndex++, (int) ((value & 0xFFFF00000000L) >>> 32));
+ crafter.sendProgressBarUpdate(container, startIndex, (int) ((value & 0xFFFF000000000000L) >>> 48));
}
@Deprecated
- public static float receiveFloat(float previousValue, int startIndex, int index, int value){
- return Float.intBitsToFloat(receiveInteger(Float.floatToIntBits(previousValue),startIndex,index,value));
+ public static float receiveFloat(float previousValue, int startIndex, int index, int value) {
+ return Float.intBitsToFloat(receiveInteger(Float.floatToIntBits(previousValue), startIndex, index, value));
}
- public static int receiveInteger(int previousValue, int startIndex, int index, int value){
- value &=0xFFFF;
- switch (index-startIndex){
+ public static int receiveInteger(int previousValue, int startIndex, int index, int value) {
+ value &= 0xFFFF;
+ switch (index - startIndex) {
case 0:
- previousValue&= 0xFFFF_0000;
- previousValue|=value;
+ previousValue &= 0xFFFF_0000;
+ previousValue |= value;
break;
case 1:
- previousValue&=0x0000_FFFF;
- previousValue|=value<<16;
+ previousValue &= 0x0000_FFFF;
+ previousValue |= value << 16;
break;
}
return previousValue;
}
- public static void sendFloat(float value,Container container, ICrafting crafter,int startIndex){
- sendInteger(Float.floatToIntBits(value),container,crafter,startIndex);
+ public static void sendFloat(float value, Container container, ICrafting crafter, int startIndex) {
+ sendInteger(Float.floatToIntBits(value), container, crafter, startIndex);
}
- public static void sendInteger(int value,Container container, ICrafting crafter,int startIndex){
- crafter.sendProgressBarUpdate(container, startIndex++, (int)(value & 0xFFFFL));
- crafter.sendProgressBarUpdate(container, startIndex, (value & 0xFFFF0000)>>>16);
+ public static void sendInteger(int value, Container container, ICrafting crafter, int startIndex) {
+ crafter.sendProgressBarUpdate(container, startIndex++, (int) (value & 0xFFFFL));
+ crafter.sendProgressBarUpdate(container, startIndex, (value & 0xFFFF0000) >>> 16);
}
- public static String doubleToString(double value){
- if(value==(long)value){
- return Long.toString((long)value);
+ public static String doubleToString(double value) {
+ if (value == (long) value) {
+ return Long.toString((long) value);
}
return Double.toString(value);
}
- public static boolean checkChunkExist(World world, ChunkCoordIntPair chunk){
- int x=chunk.getCenterXPos();
- int z=chunk.getCenterZPosition();
+ public static boolean checkChunkExist(World world, ChunkCoordIntPair chunk) {
+ int x = chunk.getCenterXPos();
+ int z = chunk.getCenterZPosition();
return world.checkChunksExist(x, 0, z, x, 0, z);
}
- public static NBTTagCompound getPlayerData(UUID uuid1,UUID uuid2,String extension) {
+ public static NBTTagCompound getPlayerData(UUID uuid1, UUID uuid2, String extension) {
try {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
- if (uuid1 != null && uuid2!=null) {
+ if (uuid1 != null && uuid2 != null) {
IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler();
- SaveHandler sh = (SaveHandler)playerNBTManagerObj;
- File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"});
- String id1=uuid1.toString();
- NBTTagCompound tagCompound=read(new File(dir, id1 + "."+extension));
- if(tagCompound!=null){
+ SaveHandler sh = (SaveHandler) playerNBTManagerObj;
+ File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"});
+ String id1 = uuid1.toString();
+ NBTTagCompound tagCompound = read(new File(dir, id1 + "." + extension));
+ if (tagCompound != null) {
return tagCompound;
}
- tagCompound=readBackup(new File(dir, id1 + "."+extension+"_bak"));
- if(tagCompound!=null){
+ tagCompound = readBackup(new File(dir, id1 + "." + extension + "_bak"));
+ if (tagCompound != null) {
return tagCompound;
}
- String id2=uuid2.toString();
- tagCompound=read(new File(dir, id2 + "."+extension));
- if(tagCompound!=null){
+ String id2 = uuid2.toString();
+ tagCompound = read(new File(dir, id2 + "." + extension));
+ if (tagCompound != null) {
return tagCompound;
}
- tagCompound=readBackup(new File(dir, id2 + "."+extension+"_bak"));
- if(tagCompound!=null){
+ tagCompound = readBackup(new File(dir, id2 + "." + extension + "_bak"));
+ if (tagCompound != null) {
return tagCompound;
}
}
}
- } catch (Exception ignored) {}
+ } catch (Exception ignored) {
+ }
return new NBTTagCompound();
}
- public static void savePlayerFile(EntityPlayer player,String extension, NBTTagCompound data) {
+ public static void savePlayerFile(EntityPlayer player, String extension, NBTTagCompound data) {
try {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
if (player != null) {
IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler();
- SaveHandler sh = (SaveHandler)playerNBTManagerObj;
- File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"});
- String id1=player.getUniqueID().toString();
- write(new File(dir, id1 + "."+extension),data);
- write(new File(dir, id1 + "."+extension+"_bak"),data);
- String id2=UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(StandardCharsets.UTF_8)).toString();
- write(new File(dir, id2 + "."+extension),data);
- write(new File(dir, id2 + "."+extension+"_bak"),data);
+ SaveHandler sh = (SaveHandler) playerNBTManagerObj;
+ File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, new String[]{"playersDirectory", "field_75771_c"});
+ String id1 = player.getUniqueID().toString();
+ write(new File(dir, id1 + "." + extension), data);
+ write(new File(dir, id1 + "." + extension + "_bak"), data);
+ String id2 = UUID.nameUUIDFromBytes(player.getCommandSenderName().getBytes(StandardCharsets.UTF_8)).toString();
+ write(new File(dir, id2 + "." + extension), data);
+ write(new File(dir, id2 + "." + extension + "_bak"), data);
}
}
- } catch (Exception ignored) {}
+ } catch (Exception ignored) {
+ }
}
- private static NBTTagCompound read(File file){
+ private static NBTTagCompound read(File file) {
if (file != null && file.exists()) {
- try(FileInputStream fileInputStream= new FileInputStream(file)) {
+ try (FileInputStream fileInputStream = new FileInputStream(file)) {
return CompressedStreamTools.readCompressed(fileInputStream);
} catch (Exception var9) {
- TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath());
+ TecTech.LOGGER.error("Cannot read NBT File: " + file.getAbsolutePath());
}
}
return null;
}
- private static NBTTagCompound readBackup(File file){
+ private static NBTTagCompound readBackup(File file) {
if (file != null && file.exists()) {
- try(FileInputStream fileInputStream= new FileInputStream(file)) {
+ try (FileInputStream fileInputStream = new FileInputStream(file)) {
return CompressedStreamTools.readCompressed(fileInputStream);
} catch (Exception var9) {
- TecTech.LOGGER.error("Cannot read NBT File: "+file.getAbsolutePath());
+ TecTech.LOGGER.error("Cannot read NBT File: " + file.getAbsolutePath());
return new NBTTagCompound();
}
}
return null;
}
- private static void write(File file,NBTTagCompound tagCompound){
+ private static void write(File file, NBTTagCompound tagCompound) {
if (file != null) {
- if(tagCompound==null){
- if(file.exists()) file.delete();
- }else {
- try(FileOutputStream fileOutputStream= new FileOutputStream(file)) {
- CompressedStreamTools.writeCompressed(tagCompound,fileOutputStream);
+ if (tagCompound == null) {
+ if (file.exists()) file.delete();
+ } else {
+ try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
+ CompressedStreamTools.writeCompressed(tagCompound, fileOutputStream);
} catch (Exception var9) {
- TecTech.LOGGER.error("Cannot write NBT File: "+file.getAbsolutePath());
+ TecTech.LOGGER.error("Cannot write NBT File: " + file.getAbsolutePath());
}
}
}
}
- public static AxisAlignedBB fromChunkCoordIntPair(ChunkCoordIntPair chunkCoordIntPair){
- int x=chunkCoordIntPair.chunkXPos<<4;
- int z=chunkCoordIntPair.chunkZPos<<4;
- return AxisAlignedBB.getBoundingBox(x,-128,z,x+16,512,z+16);
+ public static AxisAlignedBB fromChunkCoordIntPair(ChunkCoordIntPair chunkCoordIntPair) {
+ int x = chunkCoordIntPair.chunkXPos << 4;
+ int z = chunkCoordIntPair.chunkZPos << 4;
+ return AxisAlignedBB.getBoundingBox(x, -128, z, x + 16, 512, z + 16);
}
- public static AxisAlignedBB fromChunk(Chunk chunk){
- int x=chunk.xPosition<<4;
- int z=chunk.zPosition<<4;
- return AxisAlignedBB.getBoundingBox(x,-128,z,x+16,512,z+16);
+ public static AxisAlignedBB fromChunk(Chunk chunk) {
+ int x = chunk.xPosition << 4;
+ int z = chunk.zPosition << 4;
+ return AxisAlignedBB.getBoundingBox(x, -128, z, x + 16, 512, z + 16);
}
- public static String getConcated(String[] strings,String separator){
+ public static String getConcated(String[] strings, String separator) {
StringBuilder stringBuilder = new StringBuilder();
for (String string : strings) {
stringBuilder.append(string).append(separator);
}
int length = stringBuilder.length();
- if(length >=separator.length()){
- stringBuilder.setLength(length -separator.length());
+ if (length >= separator.length()) {
+ stringBuilder.setLength(length - separator.length());
}
return stringBuilder.toString();
}
- public static double getMagnitude3D(double[] in)
- {
- return Math.sqrt(in[0]*in[0]+in[1]*in[1]+in[2]*in[2]);
+ public static double getMagnitude3D(double[] in) {
+ return Math.sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]);
}
- public static void normalize3D(double[] in, double[] out)
- {
- double mag=getMagnitude3D(in);
- out[0]=in[0]/mag;
- out[1]=in[1]/mag;
- out[2]=in[2]/mag;
+ public static void normalize3D(double[] in, double[] out) {
+ double mag = getMagnitude3D(in);
+ out[0] = in[0] / mag;
+ out[1] = in[1] / mag;
+ out[2] = in[2] / mag;
}
- public static void crossProduct3D(double[] inA, double[] inB, double[] out)
- {
+ public static void crossProduct3D(double[] inA, double[] inB, double[] out) {
out[0] = inA[1] * inB[2] - inA[2] * inB[1];
out[1] = inA[2] * inB[0] - inA[0] * inB[2];
out[2] = inA[0] * inB[1] - inA[1] * inB[0];