aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/nbt
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-11-12 00:46:13 +1000
committerAlkalus <draknyte1@hotmail.com>2017-11-12 00:46:13 +1000
commit0e508a2821b8f51910c448a2385f1737a874d894 (patch)
tree5d258fbc9c0a4bb35b33098c01f158256d1b3b1c /src/Java/gtPlusPlus/core/util/nbt
parentbfc8a3974fc3d6c147d52a91d9c21b501cdce45f (diff)
downloadGT5-Unofficial-0e508a2821b8f51910c448a2385f1737a874d894.tar.gz
GT5-Unofficial-0e508a2821b8f51910c448a2385f1737a874d894.tar.bz2
GT5-Unofficial-0e508a2821b8f51910c448a2385f1737a874d894.zip
% Formatting.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/nbt')
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java118
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java18
2 files changed, 63 insertions, 73 deletions
diff --git a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java
index 72f65c7924..81981bbac5 100644
--- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java
+++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java
@@ -11,10 +11,10 @@ import net.minecraft.nbt.NBTTagCompound;
public class ModularArmourUtils {
- public static ItemStack addComponent(ItemStack tArmour, ItemStack[] tComponents){
- if (tArmour != null){
+ public static ItemStack addComponent(ItemStack tArmour, ItemStack[] tComponents) {
+ if (tArmour != null) {
ItemStack rArmour = NBTUtils.writeItemsToGtCraftingComponents(tArmour, tComponents, true);
- if (rArmour != null){
+ if (rArmour != null) {
}
}
@@ -22,96 +22,91 @@ public class ModularArmourUtils {
}
public static enum Modifiers {
- BOOST_HP("skill.hpboost"),
- BOOST_DEF("skill.defenceboost"),
- BOOST_SPEED("skill.speedboost"),
- BOOST_MINING("skill.miningboost"),
- BOOST_DAMAGE("skill.damageboost"),
- BOOST_HOLY("skill.holyboost");
+ BOOST_HP("skill.hpboost"), BOOST_DEF("skill.defenceboost"), BOOST_SPEED("skill.speedboost"), BOOST_MINING(
+ "skill.miningboost"), BOOST_DAMAGE("skill.damageboost"), BOOST_HOLY("skill.holyboost");
private String MODIFIER_NAME;
- private Modifiers (final String mModifier){
+
+ private Modifiers(final String mModifier) {
this.MODIFIER_NAME = mModifier;
}
+
public String getModifier() {
return this.MODIFIER_NAME;
- }
- public boolean isValidLevel(int i){
- if (i >= 0 && i <= 100){
+ }
+
+ public boolean isValidLevel(int i) {
+ if (i >= 0 && i <= 100) {
return true;
}
return false;
}
}
-
+
public static enum BT {
- TYPE_AMULET(BaubleType.AMULET, 0),
- TYPE_RING(BaubleType.RING, 1),
- TYPE_BELT(BaubleType.BELT, 2);
+ TYPE_AMULET(BaubleType.AMULET, 0), TYPE_RING(BaubleType.RING, 1), TYPE_BELT(BaubleType.BELT, 2);
private final BaubleType mType;
private final int mID;
private final String mBaubleType;
- private BT (final BaubleType tType, int tID){
+
+ private BT(final BaubleType tType, int tID) {
this.mType = tType;
this.mID = tID;
this.mBaubleType = tType.name().toLowerCase();
}
- public BaubleType getType(){
+
+ public BaubleType getType() {
return this.mType;
}
-
- public BT getThis(){
+
+ public BT getThis() {
return this;
}
-
- public BaubleType getBaubleByID(int tID){
- if (tID == 0){
+
+ public BaubleType getBaubleByID(int tID) {
+ if (tID == 0) {
return BaubleType.AMULET;
- }
- else if (tID == 1){
+ } else if (tID == 1) {
return BaubleType.RING;
- }
- else if (tID == 2){
+ } else if (tID == 2) {
return BaubleType.BELT;
- }
- else {
+ } else {
return BaubleType.RING;
}
}
-
- public int getID(){
+
+ public int getID() {
return this.mID;
}
-
- public String getTypeAsString(){
+
+ public String getTypeAsString() {
return this.mBaubleType;
}
}
-
+
public static void setModifierLevel(ItemStack aStack, Pair<Modifiers, Integer> mPair) {
setModifierLevel(aStack, mPair.getKey(), mPair.getValue().intValue());
}
-
+
public static void setModifierLevel(ItemStack aStack, Modifiers aMod, Integer aInt) {
setModifierLevel(aStack, aMod, aInt.intValue());
}
-
+
public static void setModifierLevel(ItemStack aStack, Modifiers aMod, int aInt) {
-
+
int mCurrentLevel = getModifierLevel(aStack, aMod);
- int mNewTotalLevel = mCurrentLevel+aInt;
-
+ int mNewTotalLevel = mCurrentLevel + aInt;
+
NBTTagCompound tNBT = NBTUtils.getNBT(aStack);
- if (aMod.isValidLevel(mNewTotalLevel)){
+ if (aMod.isValidLevel(mNewTotalLevel)) {
tNBT.setInteger(aMod.getModifier(), mNewTotalLevel);
- GT_Utility.ItemNBT.setNBT(aStack, tNBT);
- }
- else {
- if (getModifierLevel(aStack, aMod) > 100){
- setModifierLevel(aStack, aMod, 100);
+ GT_Utility.ItemNBT.setNBT(aStack, tNBT);
+ } else {
+ if (getModifierLevel(aStack, aMod) > 100) {
+ setModifierLevel(aStack, aMod, 100);
}
}
}
-
+
public static int getModifierLevel(ItemStack aStack, Pair<Modifiers, Integer> newPair) {
return getModifierLevel(aStack, newPair.getKey());
}
@@ -120,13 +115,13 @@ public class ModularArmourUtils {
NBTTagCompound tNBT = NBTUtils.getNBT(aStack);
return tNBT.getInteger(aMod.getModifier());
}
-
+
public static void setBaubleType(ItemStack aStack, BT aMod) {
Utils.LOG_INFO("Changing bauble type.");
NBTTagCompound tNBT = NBTUtils.getNBT(aStack);
- if (aMod != null){
+ if (aMod != null) {
tNBT.setInteger("mBaubleType", aMod.getID());
- GT_Utility.ItemNBT.setNBT(aStack, tNBT);
+ GT_Utility.ItemNBT.setNBT(aStack, tNBT);
}
}
@@ -134,28 +129,25 @@ public class ModularArmourUtils {
NBTTagCompound tNBT = NBTUtils.getNBT(aStack);
return tNBT.getInteger("mBaubleType");
}
-
+
public static BaubleType getBaubleType(ItemStack aStack) {
NBTTagCompound tNBT = NBTUtils.getNBT(aStack);
return getBaubleByID(tNBT.getInteger("mBaubleType"));
}
-
- public static BaubleType getBaubleByID(int tID){
- if (tID == 0){
+
+ public static BaubleType getBaubleByID(int tID) {
+ if (tID == 0) {
return BaubleType.AMULET;
- }
- else if (tID == 1){
+ } else if (tID == 1) {
return BaubleType.RING;
- }
- else if (tID == 2){
+ } else if (tID == 2) {
return BaubleType.BELT;
- }
- else {
+ } else {
return BaubleType.RING;
}
}
-
- public static ItemStack setDefaultStats(ItemStack aStack){
+
+ public static ItemStack setDefaultStats(ItemStack aStack) {
ItemStack tempStack = aStack;
setModifierLevel(tempStack, Modifiers.BOOST_DAMAGE, 0);
setModifierLevel(tempStack, Modifiers.BOOST_DEF, 0);
@@ -165,5 +157,5 @@ public class ModularArmourUtils {
setModifierLevel(tempStack, Modifiers.BOOST_SPEED, 0);
return tempStack;
}
-
+
}
diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java
index d2e8ba867f..b023c64c77 100644
--- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java
+++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java
@@ -162,7 +162,7 @@ public class NBTUtils {
NBTTagCompound tNBT = getNBT(aStack);
return tNBT.getInteger(aTag);
}
-
+
public static void setLong(ItemStack aStack, String aTag, long aInt) {
NBTTagCompound tNBT = getNBT(aStack);
tNBT.setLong(aTag, aInt);
@@ -173,7 +173,7 @@ public class NBTUtils {
NBTTagCompound tNBT = getNBT(aStack);
return tNBT.getLong(aTag);
}
-
+
public static void setFloat(ItemStack aStack, String aTag, float aInt) {
NBTTagCompound tNBT = getNBT(aStack);
tNBT.setFloat(aTag, aInt);
@@ -210,8 +210,9 @@ public class NBTUtils {
Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap");
if (mInternalMap != null) {
- //mInternalMap.forEach((k, v) -> Utils.LOG_INFO("Key: " + k + ": Value: " + v));
- for(Map.Entry<?,?> e:mInternalMap.entrySet()){
+ // mInternalMap.forEach((k, v) -> Utils.LOG_INFO("Key: "
+ // + k + ": Value: " + v));
+ for (Map.Entry<?, ?> e : mInternalMap.entrySet()) {
Utils.LOG_INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue().toString());
}
} else {
@@ -230,18 +231,15 @@ public class NBTUtils {
}
}
-
-
- //Botania soulbind handling
+ // Botania soulbind handling
public static boolean setBotanicaSoulboundOwner(ItemStack aStack, String aName) {
final String TAG_SOULBIND = "soulbind";
NBTTagCompound tNBT = getNBT(aStack);
tNBT.setString(TAG_SOULBIND, aName);
GT_Utility.ItemNBT.setNBT(aStack, tNBT);
- if (NBTUtils.doesStringExist(aStack, TAG_SOULBIND)){
+ if (NBTUtils.doesStringExist(aStack, TAG_SOULBIND)) {
return true;
- }
- else {
+ } else {
return false;
}
}