summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/util
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 16:03:42 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 16:03:42 -0400
commit9a4d1e95ea7784f0f98ea2913701a3a3c28aefaa (patch)
treeb4307f58fe2197d2215707bb3f44cf8952229c6d /src/main/java/darkknight/jewelrycraft/util
parent4f7ad220df0438b6f3382110577b53f29da46453 (diff)
Formatting pass
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/util')
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/BlockUtils.java111
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/EntitySelector.java4
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/JewelryNBT.java98
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java352
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/PlayerUtils.java18
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/util/Variables.java45
6 files changed, 344 insertions, 284 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java b/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java
index 18dc191..17a6cdc 100755
--- a/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java
+++ b/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java
@@ -10,21 +10,21 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockUtils {
- public static final ForgeDirection DEFAULT_BLOCK_DIRECTION =
- ForgeDirection.WEST;
+ public static final ForgeDirection DEFAULT_BLOCK_DIRECTION = ForgeDirection.WEST;
/**
- * This method is used to get the direction an entity is facing (NORTH,
- * SOUTH, EAST or WEST) based on the entity's rotationYaw.
+ * This method is used to get the direction an entity is facing
+ * (NORTH, SOUTH, EAST or WEST) based on the entity's rotationYaw.
*
* @param entity
- * the living entity
+ * the living entity
* @return a direction
*/
- public static ForgeDirection
- get2dOrientation(EntityLivingBase entity) {
+ public static ForgeDirection get2dOrientation(
+ EntityLivingBase entity) {
int l = MathHelper.floor_double(
- entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3;
+ entity.rotationYaw * 4.0F / 360.0F + 0.5D)
+ & 0x3;
switch (l) {
case 0:
return ForgeDirection.SOUTH;
@@ -43,11 +43,11 @@ public class BlockUtils {
* This gets a float value depending on a direction
*
* @param direction
- * the forge direction
+ * the forge direction
* @return value depending on direction
*/
- public static float
- getRotationFromDirection(ForgeDirection direction) {
+ public static float getRotationFromDirection(
+ ForgeDirection direction) {
switch (direction) {
case NORTH:
return 0F;
@@ -68,15 +68,15 @@ public class BlockUtils {
}
/**
- * This method is used to get the direction an entity is looking at (UP
- * or DOWN) based on the entitiy's rotationPitch
+ * This method is used to get the direction an entity is looking at
+ * (UP or DOWN) based on the entitiy's rotationPitch
*
* @param entity
- * the living entity
+ * the living entity
* @return a forge direction
*/
- public static ForgeDirection
- get3dOrientation(EntityLivingBase entity) {
+ public static ForgeDirection get3dOrientation(
+ EntityLivingBase entity) {
if (entity.rotationPitch > 45.5F)
return ForgeDirection.DOWN;
else if (entity.rotationPitch < -45.5F)
@@ -85,32 +85,38 @@ public class BlockUtils {
}
/**
- * This spawns the item specified and returns the EntityItem it created
+ * This spawns the item specified and returns the EntityItem it
+ * created
*
* @param worldObj
- * the world
+ * the world
* @param x
- * position of the item to drop on the X axis
+ * position of the item to drop on the X axis
* @param y
- * position of the item to drop on the Y axis
+ * position of the item to drop on the Y axis
* @param z
- * position of the item to drop on the Z axis
+ * position of the item to drop on the Z axis
* @param stack
- * the item to spawn
+ * the item to spawn
* @return the EntityItem of the stack
*/
- public static EntityItem dropItemStackInWorld(World worldObj, double x,
- double y, double z, ItemStack stack) {
+ public static EntityItem dropItemStackInWorld(World worldObj,
+ double x, double y, double z, ItemStack stack) {
float f = 0.7F;
- float d0 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F;
- float d1 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F;
- float d2 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F;
- EntityItem entityitem =
- new EntityItem(worldObj, x + d0, y + d1, z + d2, stack);
+ float d0 = worldObj.rand.nextFloat() * f
+ + (1.0F - f) * 0.5F;
+ float d1 = worldObj.rand.nextFloat() * f
+ + (1.0F - f) * 0.5F;
+ float d2 = worldObj.rand.nextFloat() * f
+ + (1.0F - f) * 0.5F;
+ EntityItem entityitem = new EntityItem(worldObj, x + d0,
+ y + d1, z + d2, stack);
entityitem.delayBeforeCanPickup = 10;
if (stack.hasTagCompound())
entityitem.getEntityItem().setTagCompound(
- (NBTTagCompound) stack.getTagCompound().copy());
+ (NBTTagCompound) stack
+ .getTagCompound()
+ .copy());
worldObj.spawnEntityInWorld(entityitem);
return entityitem;
}
@@ -119,24 +125,24 @@ public class BlockUtils {
* It spawns the item with momentum in a certain direction
*
* @param world
- * the world to spawn the item
+ * the world to spawn the item
* @param x
- * the X coordinate to spawn it in
+ * the X coordinate to spawn it in
* @param y
- * the Y coordinate to spawn it in
+ * the Y coordinate to spawn it in
* @param z
- * the Z coordinate to spawn it in
+ * the Z coordinate to spawn it in
* @param direction
- * the direction towards which it should eject
+ * the direction towards which it should eject
* @param stack
- * the item to spawn
+ * the item to spawn
* @return the spawned EntityItem
*/
- public static EntityItem ejectItemInDirection(World world, double x,
- double y, double z, ForgeDirection direction,
- ItemStack stack) {
- EntityItem item =
- BlockUtils.dropItemStackInWorld(world, x, y, z, stack);
+ public static EntityItem ejectItemInDirection(World world,
+ double x, double y, double z,
+ ForgeDirection direction, ItemStack stack) {
+ EntityItem item = BlockUtils.dropItemStackInWorld(world, x,
+ y, z, stack);
item.motionX = direction.offsetX / 5F;
item.motionY = direction.offsetY / 5F;
item.motionZ = direction.offsetZ / 5F;
@@ -147,15 +153,15 @@ public class BlockUtils {
* Drops the content of an inventory with doubles as coordinates
*
* @param inventory
- * the inventory the items are contained in
+ * the inventory the items are contained in
* @param world
- * the world in which to spawn
+ * the world in which to spawn
* @param x
- * the X coordinate to spawn it in
+ * the X coordinate to spawn it in
* @param y
- * the Y coordinate to spawn it in
+ * the Y coordinate to spawn it in
* @param z
- * the Z coordinate to spawn it in
+ * the Z coordinate to spawn it in
*/
public static void dropInventory(IInventory inventory, World world,
double x, double y, double z) {
@@ -164,7 +170,8 @@ public class BlockUtils {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack != null)
- dropItemStackInWorld(world, x, y, z, itemStack);
+ dropItemStackInWorld(world, x, y, z,
+ itemStack);
}
}
@@ -172,15 +179,15 @@ public class BlockUtils {
* Drops the content of an inventory with integer as coordinates
*
* @param inventory
- * the inventory the items are contained in
+ * the inventory the items are contained in
* @param world
- * the world in which to spawn
+ * the world in which to spawn
* @param x
- * the X coordinate to spawn it in
+ * the X coordinate to spawn it in
* @param y
- * the Y coordinate to spawn it in
+ * the Y coordinate to spawn it in
* @param z
- * the Z coordinate to spawn it in
+ * the Z coordinate to spawn it in
*/
public static void dropInventory(IInventory inventory, World world,
int x, int y, int z) {
diff --git a/src/main/java/darkknight/jewelrycraft/util/EntitySelector.java b/src/main/java/darkknight/jewelrycraft/util/EntitySelector.java
index 572e2e9..2398817 100755
--- a/src/main/java/darkknight/jewelrycraft/util/EntitySelector.java
+++ b/src/main/java/darkknight/jewelrycraft/util/EntitySelector.java
@@ -13,7 +13,9 @@ public class EntitySelector {
@Override
public boolean isEntityApplicable(Entity arg0) {
- if (arg0.isCreatureType(EnumCreatureType.monster, false)) {
+ if (arg0.isCreatureType(
+ EnumCreatureType.monster,
+ false)) {
return true;
}
diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java
index 7b74403..320497b 100755
--- a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java
+++ b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java
@@ -25,9 +25,9 @@ public class JewelryNBT {
/**
* @param item
- * The item you want to add the NBT data on
+ * The item you want to add the NBT data on
* @param metal
- * The metal you want to add on the item
+ * The metal you want to add on the item
*/
public static void addMetal(ItemStack item, ItemStack metal) {
NBTTagCompound itemStackData;
@@ -46,9 +46,9 @@ public class JewelryNBT {
/**
* @param item
- * The item you want to add the NBT data on
+ * The item you want to add the NBT data on
* @param gem
- * The gem you want to add on the item
+ * The gem you want to add on the item
*/
public static void addGem(ItemStack item, ItemStack gem) {
if (gem != null) {
@@ -67,9 +67,9 @@ public class JewelryNBT {
/**
* @param item
- * The item you want to add the NBT data on
+ * The item you want to add the NBT data on
* @param modifier
- * The modifier you want to add on the item
+ * The modifier you want to add on the item
*/
public static void addModifiers(ItemStack item,
ArrayList<ItemStack> modifier) {
@@ -84,9 +84,11 @@ public class JewelryNBT {
for (int i = 0; i < modifier.size(); i++) {
NBTTagCompound modifierNBT = new NBTTagCompound();
modifier.get(i).writeToNBT(modifierNBT);
- itemStackData.setTag("modifier" + i, modifierNBT);
+ itemStackData.setTag("modifier" + i,
+ modifierNBT);
}
- itemStackData.setInteger("modifierSize", modifier.size());
+ itemStackData.setInteger("modifierSize",
+ modifier.size());
}
}
@@ -146,8 +148,10 @@ public class JewelryNBT {
* @return
*/
public static boolean isGemX(ItemStack stack, ItemStack gem) {
- if (gem(stack) != null && gem(stack).getItem() == gem.getItem()
- && gem(stack).getItemDamage() == gem.getItemDamage())
+ if (gem(stack) != null
+ && gem(stack).getItem() == gem.getItem()
+ && gem(stack).getItemDamage() == gem
+ .getItemDamage())
return true;
return false;
}
@@ -162,7 +166,8 @@ public class JewelryNBT {
if (modifier(stack) != null) {
ArrayList<ItemStack> list = modifier(stack);
for (int i = 0; i < list.size(); i++)
- if (list.get(i).getItem() == modifier.getItem()
+ if (list.get(i).getItem() == modifier
+ .getItem()
&& list.get(i).getItemDamage() == modifier
.getItemDamage())
return true;
@@ -170,11 +175,13 @@ public class JewelryNBT {
return false;
}
- public static int modifierSize(ItemStack stack, ItemStack modifier) {
+ public static int modifierSize(ItemStack stack,
+ ItemStack modifier) {
if (modifier(stack) != null) {
ArrayList<ItemStack> list = modifier(stack);
for (int i = 0; i < list.size(); i++)
- if (list.get(i).getItem() == modifier.getItem()
+ if (list.get(i).getItem() == modifier
+ .getItem()
&& list.get(i).getItemDamage() == modifier
.getItemDamage())
return list.get(i).stackSize;
@@ -195,8 +202,10 @@ public class JewelryNBT {
*/
public static boolean isIngotX(ItemStack stack, ItemStack ingot) {
if (ingot(stack) != null
- && ingot(stack).getItem() == ingot.getItem()
- && ingot(stack).getItemDamage() == ingot.getItemDamage())
+ && ingot(stack).getItem() == ingot
+ .getItem()
+ && ingot(stack).getItemDamage() == ingot
+ .getItemDamage())
return true;
return false;
}
@@ -204,12 +213,15 @@ public class JewelryNBT {
// TODO Return components based on NBT
public static ItemStack item(ItemStack stack) {
if (stack != null
- && stack != new ItemStack(Item.getItemById(0), 0, 0)
+ && stack != new ItemStack(
+ Item.getItemById(0), 0, 0)
&& stack.hasTagCompound()
- && stack.getTagCompound().hasKey("target")) {
+ && stack.getTagCompound()
+ .hasKey("target")) {
NBTTagCompound itemNBT = (NBTTagCompound) stack
.getTagCompound().getTag("target");
- ItemStack target = new ItemStack(Item.getItemById(0), 0, 0);
+ ItemStack target = new ItemStack(
+ Item.getItemById(0), 0, 0);
target.readFromNBT(itemNBT);
return target;
}
@@ -222,12 +234,14 @@ public class JewelryNBT {
*/
public static ItemStack gem(ItemStack stack) {
if (stack != null
- && stack != new ItemStack(Item.getItemById(0), 0, 0)
+ && stack != new ItemStack(
+ Item.getItemById(0), 0, 0)
&& stack.hasTagCompound()
&& stack.getTagCompound().hasKey("gem")) {
- NBTTagCompound jewelNBT =
- (NBTTagCompound) stack.getTagCompound().getTag("gem");
- ItemStack gem = new ItemStack(Item.getItemById(0), 0, 0);
+ NBTTagCompound jewelNBT = (NBTTagCompound) stack
+ .getTagCompound().getTag("gem");
+ ItemStack gem = new ItemStack(Item.getItemById(0),
+ 0, 0);
gem.readFromNBT(jewelNBT);
return gem;
}
@@ -240,15 +254,18 @@ public class JewelryNBT {
*/
public static ArrayList<ItemStack> modifier(ItemStack stack) {
if (stack != null
- && stack != new ItemStack(Item.getItemById(0), 0, 0)
+ && stack != new ItemStack(
+ Item.getItemById(0), 0, 0)
&& stack.hasTagCompound()) {
- int size = stack.getTagCompound().getInteger("modifierSize");
+ int size = stack.getTagCompound()
+ .getInteger("modifierSize");
ArrayList<ItemStack> list = new ArrayList<>();
for (int i = 0; i < size; i++) {
- ItemStack modifier =
- new ItemStack(Item.getItemById(0), 0, 0);
+ ItemStack modifier = new ItemStack(
+ Item.getItemById(0), 0, 0);
NBTTagCompound modifierNBT = (NBTTagCompound) stack
- .getTagCompound().getTag("modifier" + i);
+ .getTagCompound()
+ .getTag("modifier" + i);
modifier.readFromNBT(modifierNBT);
list.add(modifier);
}
@@ -263,12 +280,15 @@ public class JewelryNBT {
*/
public static ItemStack ingot(ItemStack stack) {
if (stack != null
- && stack != new ItemStack(Item.getItemById(0), 0, 0)
+ && stack != new ItemStack(
+ Item.getItemById(0), 0, 0)
&& stack.hasTagCompound()
- && stack.getTagCompound().hasKey("ingot")) {
+ && stack.getTagCompound()
+ .hasKey("ingot")) {
NBTTagCompound ingotNBT = (NBTTagCompound) stack
.getTagCompound().getTag("ingot");
- ItemStack ingot = new ItemStack(Item.getItemById(0), 0, 0);
+ ItemStack ingot = new ItemStack(
+ Item.getItemById(0), 0, 0);
ingot.readFromNBT(ingotNBT);
return ingot;
}
@@ -281,10 +301,13 @@ public class JewelryNBT {
*/
public static int ingotColor(ItemStack stack) {
if (stack != null
- && stack != new ItemStack(Item.getItemById(0), 0, 0)
+ && stack != new ItemStack(
+ Item.getItemById(0), 0, 0)
&& stack.hasTagCompound()
- && stack.getTagCompound().hasKey("ingotColor"))
- return stack.getTagCompound().getInteger("ingotColor");
+ && stack.getTagCompound()
+ .hasKey("ingotColor"))
+ return stack.getTagCompound()
+ .getInteger("ingotColor");
return 16777215;
}
@@ -295,10 +318,13 @@ public class JewelryNBT {
*/
public static int gemColor(ItemStack stack) {
if (stack != null
- && stack != new ItemStack(Item.getItemById(0), 0, 0)
+ && stack != new ItemStack(
+ Item.getItemById(0), 0, 0)
&& stack.hasTagCompound()
- && stack.getTagCompound().hasKey("gemColor"))
- return stack.getTagCompound().getInteger("gemColor");
+ && stack.getTagCompound()
+ .hasKey("gemColor"))
+ return stack.getTagCompound()
+ .getInteger("gemColor");
return 16777215;
}
diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index c61e82b..bab97d1 100755
--- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -38,39 +38,28 @@ import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class JewelrycraftUtil {
- public static ArrayList<ItemStack> objects =
- new ArrayList<>();
+ public static ArrayList<ItemStack> objects = new ArrayList<>();
- public static ArrayList<ItemStack> gem =
- new ArrayList<>();
+ public static ArrayList<ItemStack> gem = new ArrayList<>();
- public static ArrayList<ItemStack> jewelry =
- new ArrayList<>();
+ public static ArrayList<ItemStack> jewelry = new ArrayList<>();
- public static ArrayList<ItemStack> metal =
- new ArrayList<>();
+ public static ArrayList<ItemStack> metal = new ArrayList<>();
- public static ArrayList<ItemStack> ores =
- new ArrayList<>();
+ public static ArrayList<ItemStack> ores = new ArrayList<>();
- public static HashMap<ItemStack, ItemStack> oreToIngot =
- new HashMap<>();
- public static HashMap<ItemStack, Integer> colors =
- new HashMap<>();
+ public static HashMap<ItemStack, ItemStack> oreToIngot = new HashMap<>();
+ public static HashMap<ItemStack, Integer> colors = new HashMap<>();
- public static ArrayList<String> jamcraftPlayers =
- new ArrayList<>();
+ public static ArrayList<String> jamcraftPlayers = new ArrayList<>();
- private static ArrayList<ItemStack> items =
- new ArrayList<>();
+ private static ArrayList<ItemStack> items = new ArrayList<>();
- public static ArrayList<WorldGenStructure> structures =
- new ArrayList<>();
+ public static ArrayList<WorldGenStructure> structures = new ArrayList<>();
- public static Random rand =
- new Random();
+ public static Random rand = new Random();
- public static EnumCreatureAttribute HEARTS;
+ public static EnumCreatureAttribute HEARTS;
/**
* Adds gems and jewelry to their appropriate lists
@@ -106,10 +95,13 @@ public class JewelrycraftUtil {
try {
if (itemHasSubtypes(item)) {
- ((Item) item).getSubItems((Item) item, null,
+ ((Item) item).getSubItems(
+ (Item) item,
+ null,
items);
} else {
- objects.add(new ItemStack((Item) item));
+ objects.add(new ItemStack(
+ (Item) item));
}
if (!items.isEmpty()) {
@@ -118,8 +110,8 @@ public class JewelrycraftUtil {
items.removeAll(items);
} catch (Exception e) {
- JewelrycraftMod.logger
- .info("Error, tried to add subtypes of item "
+ JewelrycraftMod.logger.info(
+ "Error, tried to add subtypes of item "
+ ((Item) item).getUnlocalizedName()
+ "\nItem is not added in the list.");
}
@@ -128,7 +120,8 @@ public class JewelrycraftUtil {
// Structures
try {
- for (Field f : Generation.class.getDeclaredFields()) {
+ for (Field f : Generation.class
+ .getDeclaredFields()) {
Object obj = f.get(null);
if (obj instanceof WorldGenStructure) {
structures.add((WorldGenStructure) obj);
@@ -140,8 +133,8 @@ public class JewelrycraftUtil {
}
private static boolean itemHasSubtypes(Object item) {
- return ((Item) item).getHasSubtypes()
- && FMLCommonHandler.instance().getSide() == Side.CLIENT;
+ return ((Item) item).getHasSubtypes() && FMLCommonHandler
+ .instance().getSide() == Side.CLIENT;
}
@SideOnly(Side.CLIENT)
@@ -156,23 +149,29 @@ public class JewelrycraftUtil {
try {
if (itemHasSubtypes(item)) {
- ((Item) item).getSubItems((Item) item, null,
+ ((Item) item).getSubItems(
+ (Item) item,
+ null,
items);
} else {
- ItemStack it = new ItemStack((Item) item);
- colors.put(it, color(it, 0));
+ ItemStack it = new ItemStack(
+ (Item) item);
+ colors.put(it, color(it,
+ 0));
}
if (!items.isEmpty()) {
for (ItemStack it : items) {
- colors.put(it, color(it, 0));
+ colors.put(it, color(
+ it,
+ 0));
}
}
items.removeAll(items);
} catch (Exception e) {
- JewelrycraftMod.logger
- .info("Error, tried to add the color of the item "
+ JewelrycraftMod.logger.info(
+ "Error, tried to add the color of the item "
+ ((Item) item).getUnlocalizedName()
+ " but something went wrong.");
}
@@ -185,8 +184,10 @@ public class JewelrycraftUtil {
for (ItemStack stack : colors.keySet()) {
if (item != null && item.getItem() != null
&& stack.getItem() != null
- && item.getItem().equals(stack.getItem())
- && item.getItemDamage() == stack.getItemDamage()) {
+ && item.getItem().equals(
+ stack.getItem())
+ && item.getItemDamage() == stack
+ .getItemDamage()) {
return colors.get(stack);
}
}
@@ -197,8 +198,11 @@ public class JewelrycraftUtil {
@SideOnly(Side.CLIENT)
public static int color(ItemStack stack, int pass) {
if (stack != null) {
- if (Item.getIdFromItem(stack.getItem()) > 0 && stack.getItem()
- .getColorFromItemStack(stack, pass) == 16777215) {
+ if (Item.getIdFromItem(stack.getItem()) > 0
+ && stack.getItem()
+ .getColorFromItemStack(
+ stack,
+ pass) == 16777215) {
return (int) Math.random() * 16777215;
}
@@ -210,9 +214,11 @@ public class JewelrycraftUtil {
// try {
// ingot = getLocation(stack);
// } catch (Exception e) {
- // ingot = new ResourceLocation("textures/items/apple.png");
+ // ingot = new
+ // ResourceLocation("textures/items/apple.png");
// }
- // icon = ImageIO.read(rm.getResource(ingot).getInputStream());
+ // icon =
+ // ImageIO.read(rm.getResource(ingot).getInputStream());
// int height = icon.getHeight();
// int width = icon.getWidth();
// Map m = new HashMap();
@@ -230,7 +236,8 @@ public class JewelrycraftUtil {
// }
// return getMostCommonColour(m);
- return stack.getItem().getColorFromItemStack(stack, pass);
+ return stack.getItem().getColorFromItemStack(stack,
+ pass);
}
return (int) Math.random() * 16777215;
@@ -244,33 +251,40 @@ public class JewelrycraftUtil {
IIcon itemIcon = item.getItem().getIcon(item, 0);
if (isValidBlockFromItem(item)) {
- itemIcon = Block.getBlockFromItem(item.getItem()).getIcon(0,
- item.getItemDamage());
+ itemIcon = Block.getBlockFromItem(item.getItem())
+ .getIcon(0, item.getItemDamage());
}
String iconName = itemIcon.getIconName();
- if (iconName.substring(0, iconName.indexOf(":") + 1) != "") {
- domain = iconName.substring(0, iconName.indexOf(":") + 1)
+ if (iconName.substring(0,
+ iconName.indexOf(":") + 1) != "") {
+ domain = iconName
+ .substring(0, iconName.indexOf(":")
+ + 1)
.replace(":", " ").trim();
} else {
domain = "minecraft";
}
- texture =
- iconName.substring(iconName.lastIndexOf(":") + 1) + ".png";
+ texture = iconName.substring(iconName.lastIndexOf(":") + 1)
+ + ".png";
ResourceLocation textureLocation = null;
- TextureManager texturemanager =
- Minecraft.getMinecraft().getTextureManager();
+ TextureManager texturemanager = Minecraft.getMinecraft()
+ .getTextureManager();
- if (texturemanager.getResourceLocation(item.getItemSpriteNumber())
+ if (texturemanager
+ .getResourceLocation(
+ item.getItemSpriteNumber())
.toString().contains("items")) {
- textureLocation = new ResourceLocation(domain.toLowerCase(),
+ textureLocation = new ResourceLocation(
+ domain.toLowerCase(),
"textures/items/" + texture);
} else {
- textureLocation = new ResourceLocation(domain.toLowerCase(),
+ textureLocation = new ResourceLocation(
+ domain.toLowerCase(),
"textures/blocks/" + texture);
}
@@ -278,24 +292,26 @@ public class JewelrycraftUtil {
}
private static boolean isValidBlockFromItem(ItemStack item) {
- return !(Block
- .getBlockFromItem(item.getItem()) instanceof BlockAir)
+ return !(Block.getBlockFromItem(
+ item.getItem()) instanceof BlockAir)
&& !Block.getBlockFromItem(item.getItem())
- .getIcon(0, item.getItemDamage()).getIconName()
+ .getIcon(0, item.getItemDamage())
+ .getIconName()
.equals("soul_sand");
}
/*
* @SideOnly(Side.CLIENT) public static int getMostCommonColour(Map
* map) { List list = new LinkedList(map.entrySet());
- * Collections.sort(list, new Comparator() { public int compare(Object
- * o1, Object o2) { return ((Comparable) ((Map.Entry) o1).getValue())
- * .compareTo(((Map.Entry) o2).getValue()); } }); Map.Entry me =
- * (Map.Entry) list.get(list.size() - 1); for (int i = 0; i <
- * list.size(); i++) { float alpha = Float
- * .valueOf(list.get(i).toString().split("=")[1]); if (alpha < 180) me
- * = (Map.Entry) list.get(i); } int rgb = (Integer) me.getKey(); return
- * rgb; }
+ * Collections.sort(list, new Comparator() { public int
+ * compare(Object o1, Object o2) { return ((Comparable)
+ * ((Map.Entry) o1).getValue()) .compareTo(((Map.Entry)
+ * o2).getValue()); } }); Map.Entry me = (Map.Entry)
+ * list.get(list.size() - 1); for (int i = 0; i < list.size(); i++)
+ * { float alpha = Float
+ * .valueOf(list.get(i).toString().split("=")[1]); if (alpha < 180)
+ * me = (Map.Entry) list.get(i); } int rgb = (Integer) me.getKey();
+ * return rgb; }
*/
@SideOnly(Side.CLIENT)
@@ -311,13 +327,15 @@ public class JewelrycraftUtil {
public static WeightedRandomCurse[] getCurses(World world,
EntityPlayer player, Random random) {
- WeightedRandomCurse[] curses =
- new WeightedRandomCurse[Curse.availableCurses.size()];
+ WeightedRandomCurse[] curses = new WeightedRandomCurse[Curse.availableCurses
+ .size()];
for (int c = 0; c < Curse.availableCurses.size(); c++) {
curses[c] = new WeightedRandomCurse(
- Curse.availableCurses.get(c), Curse.availableCurses
- .get(c).weight(world, player, random));
+ Curse.availableCurses.get(c),
+ Curse.availableCurses.get(c)
+ .weight(world, player,
+ random));
}
return curses;
@@ -327,25 +345,27 @@ public class JewelrycraftUtil {
* Adds curse points to a player
*
* @param player
- * the player to add the points to
+ * the player to add the points to
* @param points
- * amount of curse points
+ * amount of curse points
*/
- public static void addCursePoints(EntityPlayer player, int points) {
+ public static void addCursePoints(EntityPlayer player,
+ int points) {
NBTTagCompound playerInfo = PlayerUtils
- .getModPlayerPersistTag(player, Variables.MODID);
+ .getModPlayerPersistTag(player,
+ Variables.MODID);
playerInfo.setInteger("cursePoints",
- playerInfo.hasKey("cursePoints")
- ? (playerInfo.getInteger("cursePoints") + points)
- : points);
+ playerInfo.hasKey(
+ "cursePoints") ? (playerInfo.getInteger("cursePoints") + points) : points);
playerInfo.setBoolean("playerCursePointsChanged", true);
}
public static int getCursePoints(EntityPlayer player) {
NBTTagCompound playerInfo = PlayerUtils
- .getModPlayerPersistTag(player, Variables.MODID);
+ .getModPlayerPersistTag(player,
+ Variables.MODID);
return playerInfo.getInteger("cursePoints");
}
@@ -354,38 +374,56 @@ public class JewelrycraftUtil {
* Adds the UUID's of the jamcrafters in a list (+ special people)
*/
public static void jamcrafters() {
- jamcraftPlayers.add("d3214311-7550-4c9c-a372-d9292c10b8a6"); // allout58
- jamcraftPlayers.add("a690119f-c4a2-4bd6-a99d-d63679abb328"); // ChewBaker
- jamcraftPlayers.add("de7c9903-51fa-4a24-88cd-48faf122ca36"); // domi1819
- jamcraftPlayers.add("70aeb298-3a7b-46da-a393-ab10df9359f2"); // founderio
- jamcraftPlayers.add("6fbe603c-14bf-4085-afdd-abe592c26e7c"); // GerbShert
- jamcraftPlayers.add("b0d21306-36bf-4d85-84df-a956d183c45a"); // isomgirls6
- jamcraftPlayers.add("1733a31f-01f9-4f4d-82aa-7de30ca810d3"); // TH3N00B
- jamcraftPlayers.add("4833eacf-1d94-49a7-9f89-4cf88d69dcf9"); // Joban
- jamcraftPlayers.add("718cf671-9084-4e78-b91f-033e80aa11bf"); // KJ4IPS
- jamcraftPlayers.add("bea5e0c4-85c4-454d-a081-e1eaae6895ee"); // Mitchellbrine
- jamcraftPlayers.add("7ecf3e2f-fedf-4f7e-8d24-6731d078db4f"); // MrComputerGhost
- jamcraftPlayers.add("1b11ad3a-f0ca-4695-a019-2d7e5d83a5fd"); // Resinresin
- jamcraftPlayers.add("3ec9ac58-2f1b-4d3f-b4eb-3b875da877ae"); // sci4me
- jamcraftPlayers.add("cf9fa23f-205e-4eed-aba3-9f2848cd6a4d"); // OnyxDarkKnight
- jamcraftPlayers.add("91880caa-b032-48e3-bfe8-c2c7ed31824e"); // theminecoder
- jamcraftPlayers.add("8d0b3804-f71c-4219-897b-8c315448ea7c"); // YSPilot
- jamcraftPlayers.add("bbb87dbe-690f-4205-bdc5-72ffb8ebc29d"); // direwolf20
+ jamcraftPlayers.add(
+ "d3214311-7550-4c9c-a372-d9292c10b8a6"); // allout58
+ jamcraftPlayers.add(
+ "a690119f-c4a2-4bd6-a99d-d63679abb328"); // ChewBaker
+ jamcraftPlayers.add(
+ "de7c9903-51fa-4a24-88cd-48faf122ca36"); // domi1819
+ jamcraftPlayers.add(
+ "70aeb298-3a7b-46da-a393-ab10df9359f2"); // founderio
+ jamcraftPlayers.add(
+ "6fbe603c-14bf-4085-afdd-abe592c26e7c"); // GerbShert
+ jamcraftPlayers.add(
+ "b0d21306-36bf-4d85-84df-a956d183c45a"); // isomgirls6
+ jamcraftPlayers.add(
+ "1733a31f-01f9-4f4d-82aa-7de30ca810d3"); // TH3N00B
+ jamcraftPlayers.add(
+ "4833eacf-1d94-49a7-9f89-4cf88d69dcf9"); // Joban
+ jamcraftPlayers.add(
+ "718cf671-9084-4e78-b91f-033e80aa11bf"); // KJ4IPS
+ jamcraftPlayers.add(
+ "bea5e0c4-85c4-454d-a081-e1eaae6895ee"); // Mitchellbrine
+ jamcraftPlayers.add(
+ "7ecf3e2f-fedf-4f7e-8d24-6731d078db4f"); // MrComputerGhost
+ jamcraftPlayers.add(
+ "1b11ad3a-f0ca-4695-a019-2d7e5d83a5fd"); // Resinresin
+ jamcraftPlayers.add(
+ "3ec9ac58-2f1b-4d3f-b4eb-3b875da877ae"); // sci4me
+ jamcraftPlayers.add(
+ "cf9fa23f-205e-4eed-aba3-9f2848cd6a4d"); // OnyxDarkKnight
+ jamcraftPlayers.add(
+ "91880caa-b032-48e3-bfe8-c2c7ed31824e"); // theminecoder
+ jamcraftPlayers.add(
+ "8d0b3804-f71c-4219-897b-8c315448ea7c"); // YSPilot
+ jamcraftPlayers.add(
+ "bbb87dbe-690f-4205-bdc5-72ffb8ebc29d"); // direwolf20
}
/**
* Adds a random amount of modifiers to a list
*
* @param randValue
- * maximum number of modifiers
+ * maximum number of modifiers
* @return a list containing the random modifiers
*/
- public static ArrayList<ItemStack> addRandomModifiers(int randValue) {
+ public static ArrayList<ItemStack> addRandomModifiers(
+ int randValue) {
ArrayList<ItemStack> list = new ArrayList<>();
for (int i = 0; i < 2 + randValue; i++) {
- ItemStack item =
- objects.get(new Random().nextInt(objects.size()));
+ ItemStack item = objects.get(new Random()
+ .nextInt(objects.size()));
item.stackSize = 1 + new Random().nextInt(2);
@@ -400,64 +438,55 @@ public class JewelrycraftUtil {
*/
public static void addMetals() {
/*
- int index = 0;
-
- while (index < OreDictionary.getOreNames().length) {
- Iterator<ItemStack> i = OreDictionary
- .getOres(OreDictionary.getOreNames()[index])
- .iterator();
-
- while (i.hasNext()) {
- ItemStack nextStack = i.next();
-
- String stackName = nextStack.getItem().getUnlocalizedName()
- .toLowerCase();
-
- if ((stackName.contains("ingot")
- || stackName.contains("alloy"))
- && !metal.contains(nextStack)) {
- metal.add(nextStack);
- }
-
- if (nextStack.getItem().getUnlocalizedName().toLowerCase()
- .contains("ore") && !ores.contains(nextStack)) {
- ItemStack ingot = FurnaceRecipes.smelting()
- .getSmeltingResult(nextStack);
-
- if (ingot != null && (ingot.getItem()
- .getUnlocalizedName().toLowerCase()
- .contains("ingot")
- || ingot.getItem().getUnlocalizedName()
- .toLowerCase().contains("alloy"))) {
- ores.add(nextStack);
-
- oreToIngot.put(nextStack, ingot);
-
- JewelrycraftMod.logger.info(nextStack + " Adding "
- + nextStack.getDisplayName()
- + " with damage value "
- + nextStack.getItemDamage() + " and with "
- + nextStack.stackSize + " in stack");
-
- JewelrycraftMod.logger.info(ingot
- + " Adding ingot " + ingot.getDisplayName()
- + " with damage value "
- + ingot.getItemDamage() + " and with "
- + ingot.stackSize + " in stack");
- }
- }
- }
-
- index++;
- }
- */
+ * int index = 0;
+ *
+ * while (index < OreDictionary.getOreNames().length) {
+ * Iterator<ItemStack> i = OreDictionary
+ * .getOres(OreDictionary.getOreNames()[index])
+ * .iterator();
+ *
+ * while (i.hasNext()) { ItemStack nextStack = i.next();
+ *
+ * String stackName =
+ * nextStack.getItem().getUnlocalizedName() .toLowerCase();
+ *
+ * if ((stackName.contains("ingot") ||
+ * stackName.contains("alloy")) &&
+ * !metal.contains(nextStack)) { metal.add(nextStack); }
+ *
+ * if
+ * (nextStack.getItem().getUnlocalizedName().toLowerCase()
+ * .contains("ore") && !ores.contains(nextStack)) {
+ * ItemStack ingot = FurnaceRecipes.smelting()
+ * .getSmeltingResult(nextStack);
+ *
+ * if (ingot != null && (ingot.getItem()
+ * .getUnlocalizedName().toLowerCase() .contains("ingot")
+ * || ingot.getItem().getUnlocalizedName()
+ * .toLowerCase().contains("alloy"))) {
+ * ores.add(nextStack);
+ *
+ * oreToIngot.put(nextStack, ingot);
+ *
+ * JewelrycraftMod.logger.info(nextStack + " Adding " +
+ * nextStack.getDisplayName() + " with damage value " +
+ * nextStack.getItemDamage() + " and with " +
+ * nextStack.stackSize + " in stack");
+ *
+ * JewelrycraftMod.logger.info(ingot + " Adding ingot " +
+ * ingot.getDisplayName() + " with damage value " +
+ * ingot.getItemDamage() + " and with " + ingot.stackSize +
+ * " in stack"); } } }
+ *
+ * index++; }
+ */
}
/**
* Checks to see if the specified item is a gem
*
* @param item
- * ItemStack containing the item
+ * ItemStack containing the item
* @return is the item a gem
*/
public static boolean isGem(ItemStack item) {
@@ -468,7 +497,7 @@ public class JewelrycraftUtil {
* Checks to see if the specified item is a metal
*
* @param item
- * ItemStack containing the item
+ * ItemStack containing the item
* @return is the item a metal
*/
public static boolean isMetal(ItemStack item) {
@@ -479,7 +508,7 @@ public class JewelrycraftUtil {
* Checks to see if the specified item is a piece of jewelry
*
* @param item
- * ItemStack containing the item
+ * ItemStack containing the item
* @return is the item a piece of jewelry
*/
public static boolean isJewelry(ItemStack item) {
@@ -491,7 +520,8 @@ public class JewelrycraftUtil {
while (i.hasNext()) {
ItemStack temp = i.next();
if (temp.getItem() == item.getItem()
- && temp.getItemDamage() == item.getItemDamage()) {
+ && temp.getItemDamage() == item
+ .getItemDamage()) {
return true;
}
}
@@ -503,7 +533,7 @@ public class JewelrycraftUtil {
* Checks to see if the specified item is an ore
*
* @param item
- * ItemStack containing the item
+ * ItemStack containing the item
* @return is the item an ore
*/
public static boolean isOre(ItemStack item) {
@@ -514,13 +544,14 @@ public class JewelrycraftUtil {
* Gets the ingot from the ore
*
* @param ore
- * the ore
+ * the ore
* @return the ingot
*/
public static ItemStack getIngotFromOre(ItemStack ore) {
for (ItemStack ors : JewelrycraftUtil.oreToIngot.keySet())
if (ors.getItem().equals(ore.getItem())
- && ors.getItemDamage() == ore.getItemDamage()) {
+ && ors.getItemDamage() == ore
+ .getItemDamage()) {
return oreToIngot.get(ors);
}
@@ -528,16 +559,17 @@ public class JewelrycraftUtil {
}
/**
- * This determines whether the player unlocked an achievement or not.
+ * This determines whether the player unlocked an achievement or
+ * not.
*
* @param player
- * The player to unlock the achievement
+ * The player to unlock the achievement
* @param achievement
- * The achievement to be unlocked
+ * The achievement to be unlocked
* @return True or False depending if the player did unlock the
* achievement or not
*/
- public static boolean AchievemtUnlocked(EntityPlayer player,
+ public static boolean isAchievementUnlocked(EntityPlayer player,
Achievement achievement) {
return ((EntityPlayerMP) player).func_147099_x()
.hasAchievementUnlocked(achievement);
diff --git a/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java b/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java
index c981555..8a3abe3 100755
--- a/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java
+++ b/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java
@@ -12,24 +12,26 @@ public class PlayerUtils {
* Returns the NBTTag of the player
*
* @param player
- * the player
+ * the player
* @param modName
- * the mod name
+ * the mod name
* @return appropriate NBTTag
*/
- public static NBTTagCompound
- getModPlayerPersistTag(EntityPlayer player, String modName) {
- if (player.worldObj.isRemote && ScreenHandler.tagCache != null)
+ public static NBTTagCompound getModPlayerPersistTag(
+ EntityPlayer player, String modName) {
+ if (player.worldObj.isRemote
+ && ScreenHandler.tagCache != null)
return ScreenHandler.tagCache;
NBTTagCompound tag = player.getEntityData();
NBTTagCompound persistTag = null;
if (tag.hasKey(EntityPlayer.PERSISTED_NBT_TAG))
- persistTag =
- tag.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
+ persistTag = tag.getCompoundTag(
+ EntityPlayer.PERSISTED_NBT_TAG);
else {
persistTag = new NBTTagCompound();
- tag.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag);
+ tag.setTag(EntityPlayer.PERSISTED_NBT_TAG,
+ persistTag);
}
NBTTagCompound modTag = null;
if (persistTag.hasKey(modName))
diff --git a/src/main/java/darkknight/jewelrycraft/util/Variables.java b/src/main/java/darkknight/jewelrycraft/util/Variables.java
index 53ec9fd..8b853ef 100755
--- a/src/main/java/darkknight/jewelrycraft/util/Variables.java
+++ b/src/main/java/darkknight/jewelrycraft/util/Variables.java
@@ -3,34 +3,25 @@ package darkknight.jewelrycraft.util;
import net.minecraft.util.ResourceLocation;
public class Variables {
- public static final int CURSE_POINTS_PER_LEVEL = 7000;
+ public static final int CURSE_POINTS_PER_LEVEL = 7000;
- public static final String MODID =
- "jewelrycraft2";
- public static final String MODNAME =
- "Jewelrycraft 2";
- public static final String VERSION =
- "1.1.4";
- public static final String PACKET_CHANNEL =
- "jewelrycraft2";
+ public static final String MODID = "jewelrycraft2";
+ public static final String MODNAME = "Jewelrycraft 2";
+ public static final String VERSION = "1.1.4";
+ public static final String PACKET_CHANNEL = "jewelrycraft2";
- public static final String CONFIG_GUI =
- "darkknight.jewelrycraft.config.ConfigGuiFactory";
- public static final String CLIENT_PROXY =
- "darkknight.jewelrycraft.proxy.ClientProxy";
- public static final String SERVER_PROXY =
- "darkknight.jewelrycraft.proxy.CommonProxy";
+ public static final String CONFIG_GUI = "darkknight.jewelrycraft.config.ConfigGuiFactory";
+ public static final String CLIENT_PROXY = "darkknight.jewelrycraft.proxy.ClientProxy";
+ public static final String SERVER_PROXY = "darkknight.jewelrycraft.proxy.CommonProxy";
- public static final ResourceLocation PEDESTAL_TEXTURE =
- new ResourceLocation(Variables.MODID,
- "textures/tileentities/BricksPedestal.png");
- public static final ResourceLocation SHADOW_HAND_TEXTURE =
- new ResourceLocation(Variables.MODID,
- "textures/tileentities/ShadowHand.png");
- public static final ResourceLocation VILLAGER_TEXTURE =
- new ResourceLocation(Variables.MODID,
- "textures/entities/jeweler.png");
- public static final ResourceLocation MISC_TEXTURE =
- new ResourceLocation(Variables.MODID,
- "textures/gui/hearts.png");
+ public static final ResourceLocation PEDESTAL_TEXTURE = new ResourceLocation(
+ Variables.MODID,
+ "textures/tileentities/BricksPedestal.png");
+ public static final ResourceLocation SHADOW_HAND_TEXTURE = new ResourceLocation(
+ Variables.MODID,
+ "textures/tileentities/ShadowHand.png");
+ public static final ResourceLocation VILLAGER_TEXTURE = new ResourceLocation(
+ Variables.MODID, "textures/entities/jeweler.png");
+ public static final ResourceLocation MISC_TEXTURE = new ResourceLocation(
+ Variables.MODID, "textures/gui/hearts.png");
}