aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-10-24 15:24:33 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-10-24 15:24:33 +1000
commitffa66d97ddb837817948a1048de41674ba450cfd (patch)
tree0a8557d99cd05037e39d4c8f76a7ed88624042ce /src/Java/gtPlusPlus/core
parentfbd2678b8dbd4d0a6260df550ca0648bb55b07fc (diff)
downloadGT5-Unofficial-ffa66d97ddb837817948a1048de41674ba450cfd.tar.gz
GT5-Unofficial-ffa66d97ddb837817948a1048de41674ba450cfd.tar.bz2
GT5-Unofficial-ffa66d97ddb837817948a1048de41674ba450cfd.zip
$ Fixed the getItemStackInPlayersHand method, now it has variable server/client versions, all with various constructors. (World/String/UUID) - Closes #31
% Moved a heap of Code to separate Utils classes.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java4
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java6
-rw-r--r--src/Java/gtPlusPlus/core/commands/CommandMath.java3
-rw-r--r--src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java3
-rw-r--r--src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java5
-rw-r--r--src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java4
-rw-r--r--src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java3
-rw-r--r--src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java3
-rw-r--r--src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java3
-rw-r--r--src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java4
-rw-r--r--src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java5
-rw-r--r--src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java5
-rw-r--r--src/Java/gtPlusPlus/core/util/Utils.java90
-rw-r--r--src/Java/gtPlusPlus/core/util/entity/EntityUtils.java68
-rw-r--r--src/Java/gtPlusPlus/core/util/item/UtilsItems.java29
-rw-r--r--src/Java/gtPlusPlus/core/util/player/PlayerUtils.java128
16 files changed, 226 insertions, 137 deletions
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java
index 9ac81bffe4..22536aa19b 100644
--- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java
@@ -5,7 +5,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.item.UtilsItems;
+import gtPlusPlus.core.util.player.PlayerUtils;
import ic2.core.item.tool.ItemToolWrench;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -70,7 +70,7 @@ public class Machine_Workbench extends BlockContainer
{
if (world.isRemote) return true;
- ItemStack heldItem = UtilsItems.getItemStackInPlayersHand();
+ ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand();
boolean holdingWrench = false;
if (heldItem != null){
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java
index ce09ddab59..2f061ea298 100644
--- a/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WorkbenchAdvanced.java
@@ -5,7 +5,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.item.UtilsItems;
+import gtPlusPlus.core.util.player.PlayerUtils;
import ic2.core.item.tool.ItemToolWrench;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -68,9 +68,9 @@ public class Machine_WorkbenchAdvanced extends BlockContainer
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz)
{
- if (world.isRemote) return true;
- ItemStack heldItem = UtilsItems.getItemStackInPlayersHand();
+ ItemStack heldItem = PlayerUtils.getItemStackInPlayersHand(player);
+ if (world.isRemote) return true;
boolean holdingWrench = false;
if (heldItem != null){
diff --git a/src/Java/gtPlusPlus/core/commands/CommandMath.java b/src/Java/gtPlusPlus/core/commands/CommandMath.java
index 2a726dd8b1..01091d84e3 100644
--- a/src/Java/gtPlusPlus/core/commands/CommandMath.java
+++ b/src/Java/gtPlusPlus/core/commands/CommandMath.java
@@ -1,6 +1,7 @@
package gtPlusPlus.core.commands;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.player.PlayerUtils;
import java.util.ArrayList;
import java.util.List;
@@ -101,7 +102,7 @@ public class CommandMath implements ICommand
}
}
catch(NullPointerException e) {
- Utils.messagePlayer(P, "You do not have a spawn, so...");
+ PlayerUtils.messagePlayer(P, "You do not have a spawn, so...");
}
if (Y == null || Y.equals(null)) {
Y = W.getSpawnPoint();
diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java
index 1db26846c7..e529d47699 100644
--- a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java
@@ -3,6 +3,7 @@ package gtPlusPlus.core.handler.events;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.player.PlayerCache;
+import gtPlusPlus.core.util.player.PlayerUtils;
import java.util.UUID;
@@ -37,7 +38,7 @@ public class LoginEventHandler {
Utils.LOG_INFO("You're not using the latest recommended version of GT++, consider updating.");
Utils.LOG_INFO("Latest version is: "+CORE.MASTER_VERSION);
Utils.LOG_INFO("You currently have: "+CORE.VERSION);
- Utils.messagePlayer(localPlayerRef, "You're not using the latest recommended version of GT++, consider updating.");
+ PlayerUtils.messagePlayer(localPlayerRef, "You're not using the latest recommended version of GT++, consider updating.");
}
else {
Utils.LOG_INFO("You're using the latest recommended version of GT++.");
diff --git a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
index a7c689a79a..49b844f057 100644
--- a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
@@ -5,6 +5,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.BaseMetaTileEntity;
import gregtech.api.metatileentity.BaseTileEntity;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.player.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase;
import java.util.UUID;
@@ -42,12 +43,12 @@ public class PickaxeBlockBreakEventHandler {
Utils.LOG_INFO("UUID info. Accessor: "+accessorUUID + " | Owner: "+ownerUUID);
if (accessorUUID == ownerUUID){
- Utils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed.");
+ PlayerUtils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed.");
event.setCanceled(false);
}
else {
event.setCanceled(true);
- Utils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed.");
+ PlayerUtils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed.");
}
//
}
diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java
index 02f8f63175..7ee08cabee 100644
--- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java
+++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java
@@ -4,7 +4,7 @@ import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.Material;
-import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.entity.EntityUtils;
import gtPlusPlus.core.util.item.UtilsItems;
import java.util.List;
@@ -107,7 +107,7 @@ public class BaseItemComponent extends Item{
@Override
public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) {
- Utils.applyRadiationDamageToEntity(componentMaterial.vRadioationLevel, world, entityHolding);
+ EntityUtils.applyRadiationDamageToEntity(componentMaterial.vRadioationLevel, world, entityHolding);
}
diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java
index 7638da6f0a..f199f87f68 100644
--- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java
+++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java
@@ -7,6 +7,7 @@ import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.entity.EntityUtils;
import gtPlusPlus.core.util.item.UtilsItems;
import gtPlusPlus.core.util.math.MathUtils;
@@ -93,7 +94,7 @@ public class BaseItemDust extends Item{
protected final int sRadiation;
@Override
public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) {
- Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
+ EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
}
@Override
diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java
index 78067e48c7..77e0b7324b 100644
--- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java
+++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java
@@ -4,6 +4,7 @@ import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc;
import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.entity.EntityUtils;
import gtPlusPlus.core.util.item.UtilsItems;
import gtPlusPlus.core.util.math.MathUtils;
@@ -82,7 +83,7 @@ public class BaseItemDustUnique extends Item{
protected final int sRadiation;
@Override
public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) {
- Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
+ EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
}
@Override
diff --git a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java
index e193636043..d58522756f 100644
--- a/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java
+++ b/src/Java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java
@@ -5,6 +5,7 @@ import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.entity.EntityUtils;
import gtPlusPlus.core.util.item.UtilsItems;
import gtPlusPlus.core.util.math.MathUtils;
@@ -113,6 +114,6 @@ public class BaseItemIngot extends Item{
protected final int sRadiation;
@Override
public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) {
- Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
+ EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
}
}
diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java
index ed21b3642a..cd89b027d0 100644
--- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java
+++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java
@@ -3,7 +3,7 @@ package gtPlusPlus.core.item.base.itemblock;
import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.core.block.base.BlockBaseModular;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.entity.EntityUtils;
import gtPlusPlus.core.util.item.UtilsItems;
import java.util.List;
@@ -47,7 +47,7 @@ public class ItemBlockGtBlock extends ItemBlock{
@Override
public void onUpdate(ItemStack iStack, World world, Entity entityHolding, int p_77663_4_, boolean p_77663_5_) {
- Utils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
+ EntityUtils.applyRadiationDamageToEntity(sRadiation, world, entityHolding);
}
}
diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
index 4323a39307..efecb03d9f 100644
--- a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
+++ b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
@@ -6,6 +6,7 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.UtilsItems;
import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.player.PlayerUtils;
import java.util.List;
@@ -86,11 +87,11 @@ public class ItemBlueprint extends Item implements IItemBlueprint{
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) {
//Let the player know what blueprint is held
if (itemStack.hasTagCompound()) {
- Utils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+getNBT(itemStack, "mID")+"|"+getNBT(itemStack, "mBlueprint")+"|"+getNBT(itemStack, "mName")+"|"+UtilsItems.getArrayStackNames(readItemsFromNBT(itemStack)));
+ PlayerUtils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+getNBT(itemStack, "mID")+"|"+getNBT(itemStack, "mBlueprint")+"|"+getNBT(itemStack, "mName")+"|"+UtilsItems.getArrayStackNames(readItemsFromNBT(itemStack)));
}
else {
createNBT(itemStack);
- Utils.messagePlayer(par3Entity, "This is a placeholder. "+getNBT(itemStack, "mID"));
+ PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. "+getNBT(itemStack, "mID"));
}
diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java
index 5e05221ed7..aa67e0f10c 100644
--- a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java
+++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java
@@ -5,6 +5,7 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.UtilsItems;
import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.player.PlayerUtils;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
import ic2.api.item.IElectricItemManager;
@@ -220,8 +221,8 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
Utils.LOG_INFO("rx:"+rx);
arg1.heal(rx*2);
discharge(arg0, (1638400/4)*rx, 6, true, true, false);
- Utils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp.");
- Utils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+secondsLeft(arg0)+".");
+ PlayerUtils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp.");
+ PlayerUtils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+secondsLeft(arg0)+".");
}
}
}
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java
index cdfa556de9..93621200ab 100644
--- a/src/Java/gtPlusPlus/core/util/Utils.java
+++ b/src/Java/gtPlusPlus/core/util/Utils.java
@@ -8,10 +8,8 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.fluid.FluidUtils;
import gtPlusPlus.core.util.item.UtilsItems;
import gtPlusPlus.core.util.math.MathUtils;
-import ic2.core.IC2Potion;
import ic2.core.Ic2Items;
import ic2.core.init.InternalName;
-import ic2.core.item.armor.ItemArmorHazmat;
import ic2.core.item.resources.ItemCell;
import java.awt.Color;
@@ -24,21 +22,12 @@ import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.UUID;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLiving;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.EnumCreatureType;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
-import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
@@ -49,7 +38,6 @@ import org.apache.commons.lang3.EnumUtils;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
-import cpw.mods.fml.common.registry.EntityRegistry;
public class Utils {
@@ -169,11 +157,6 @@ public class Utils {
return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage()));
}
- //TODO
- public static void registerEntityToBiomeSpawns(Class<EntityLiving> classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){
- EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc.
- }
-
//Non-Dev Comments
public static void LOG_INFO(String s){
//if (CORE.DEBUG){
@@ -206,10 +189,6 @@ public class Utils {
g.drawRect (MinA, MinB, MaxA, MaxB);
}
- public static void messagePlayer(EntityPlayer P, String S){
- gregtech.api.util.GT_Utility.sendChatToPlayer(P, S);
- }
-
/**
* Returns if that Liquid is IC2Steam.
*/
@@ -337,53 +316,6 @@ public class Utils {
return targetList;
}
- public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){
- if (parUUID == null)
- {
- return null;
- }
- List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
- for (EntityPlayerMP player : allPlayers)
- {
- if (player.getUniqueID().equals(parUUID))
- {
- return player;
- }
- }
- return null;
- }
-
- @Deprecated
- public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){
- int blockX = MathHelper.floor_double(parEntity.posX);
- int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset);
- int blockZ = MathHelper.floor_double(parEntity.posZ);
- return parEntity.worldObj.getBlock(blockX, blockY, blockZ);
- }
-
- public static Block findBlockUnderEntity(Entity parEntity){
- int blockX = MathHelper.floor_double(parEntity.posX);
- int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1;
- int blockZ = MathHelper.floor_double(parEntity.posZ);
- return parEntity.worldObj.getBlock(blockX, blockY, blockZ);
- }
-
- public static int getFacingDirection(Entity entity){
- int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3;
- return d;
- }
-
- public static boolean isPlayerOP(EntityPlayer player){
- if (player.canCommandSenderUseCommand(2, "")){
- return true;
- }
- return false;
- }
-
- public static void setEntityOnFire(Entity entity, int length){
- entity.setFire(length);
- }
-
public static void spawnCustomParticle(Entity entity){
GTplusplus.proxy.generateMysteriousParticles(entity);
}
@@ -537,28 +469,6 @@ public class Utils {
return true;
}
- public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){
- if (!world.isRemote){
- if (damage > 0 && (entityHolding instanceof EntityLivingBase)) {
- EntityLivingBase entityLiving = (EntityLivingBase) entityHolding;
- if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) {
- int duration;
- if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){
- //Utils.LOG_INFO("t");
- duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration();
- }
- else {
- //Utils.LOG_INFO("f");
- duration = damage*30;
- }
- IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15);
- }
- }
- return true;
- }
- return false;
- }
-
private static short cellID = 15;
public static ItemStack createInternalNameAndFluidCell(String s){
Utils.LOG_WARNING("1");
diff --git a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java
new file mode 100644
index 0000000000..21d31a42ee
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java
@@ -0,0 +1,68 @@
+package gtPlusPlus.core.util.entity;
+
+import ic2.core.IC2Potion;
+import ic2.core.item.armor.ItemArmorHazmat;
+import cpw.mods.fml.common.registry.EntityRegistry;
+import net.minecraft.block.Block;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraft.world.biome.BiomeGenBase;
+
+public class EntityUtils {
+
+ public static void setEntityOnFire(Entity entity, int length){
+ entity.setFire(length);
+ }
+
+ public static int getFacingDirection(Entity entity){
+ int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3;
+ return d;
+ }
+
+ @Deprecated
+ public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){
+ int blockX = MathHelper.floor_double(parEntity.posX);
+ int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset);
+ int blockZ = MathHelper.floor_double(parEntity.posZ);
+ return parEntity.worldObj.getBlock(blockX, blockY, blockZ);
+ }
+
+ public static Block findBlockUnderEntity(Entity parEntity){
+ int blockX = MathHelper.floor_double(parEntity.posX);
+ int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1;
+ int blockZ = MathHelper.floor_double(parEntity.posZ);
+ return parEntity.worldObj.getBlock(blockX, blockY, blockZ);
+ }
+
+ //TODO
+ public static void registerEntityToBiomeSpawns(Class<EntityLiving> classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){
+ EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc.
+ }
+
+ public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){
+ if (!world.isRemote){
+ if (damage > 0 && (entityHolding instanceof EntityLivingBase)) {
+ EntityLivingBase entityLiving = (EntityLivingBase) entityHolding;
+ if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) {
+ int duration;
+ if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){
+ //Utils.LOG_INFO("t");
+ duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration();
+ }
+ else {
+ //Utils.LOG_INFO("f");
+ duration = damage*30;
+ }
+ IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java
index 41dccda796..b067be1c24 100644
--- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java
+++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java
@@ -41,7 +41,6 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
@@ -236,32 +235,8 @@ public class UtilsItems {
return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size);
}*/
-
- public static Item getItemInPlayersHand(){
- Minecraft mc = Minecraft.getMinecraft();
- Item heldItem = null;
-
- try{heldItem = mc.thePlayer.getHeldItem().getItem();
- }catch(NullPointerException e){return null;}
-
- if (heldItem != null){
- return heldItem;
- }
-
- return null;
- }
-
- public static ItemStack getItemStackInPlayersHand(){
- Minecraft mc = Minecraft.getMinecraft();
- ItemStack heldItem = null;
- try{heldItem = mc.thePlayer.getHeldItem();
- }catch(NullPointerException e){return null;}
- if (heldItem != null){
- return heldItem;
- }
- return null;
- }
-
+
+
public static void generateSpawnEgg(String entityModID, String parSpawnName, int colourEgg, int colourOverlay){
Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg");
GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName);
diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
new file mode 100644
index 0000000000..132bfe12ce
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
@@ -0,0 +1,128 @@
+package gtPlusPlus.core.util.player;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class PlayerUtils {
+
+ public static void messagePlayer(EntityPlayer P, String S){
+ gregtech.api.util.GT_Utility.sendChatToPlayer(P, S);
+ }
+
+ public static EntityPlayer getPlayer(String name){
+ List<EntityPlayer> i = new ArrayList<EntityPlayer>();
+ Iterator<EntityPlayer> crunchifyIterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
+ while (crunchifyIterator.hasNext()) {
+ i.add((crunchifyIterator.next()));
+ }
+ try{
+ for (EntityPlayer temp : i) {
+ if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){
+ return temp;
+ }
+ }
+ }
+ catch(NullPointerException e){}
+ return null;
+ }
+
+ public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){
+ if (parUUID == null)
+ {
+ return null;
+ }
+ List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
+ for (EntityPlayerMP player : allPlayers)
+ {
+ if (player.getUniqueID().equals(parUUID))
+ {
+ return player;
+ }
+ }
+ return null;
+ }
+
+ //Not Clientside
+ public static EntityPlayer getPlayerInWorld(World world, String Name){
+ List<EntityPlayer> i = world.playerEntities;
+ Minecraft mc = Minecraft.getMinecraft();
+ try{
+ for (EntityPlayer temp : i) {
+ if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){
+ return temp;
+ }
+ }
+ }
+ catch(NullPointerException e){}
+ return null;
+ }
+
+ public static boolean isPlayerOP(EntityPlayer player){
+ if (player.canCommandSenderUseCommand(2, "")){
+ return true;
+ }
+ return false;
+ }
+
+ //Not Clientside
+ public static ItemStack getItemStackInPlayersHand(World world, String Name){
+ EntityPlayer thePlayer = getPlayer(Name);
+ ItemStack heldItem = null;
+ try{heldItem = thePlayer.getHeldItem();
+ }catch(NullPointerException e){return null;}
+ if (heldItem != null){
+ return heldItem;
+ }
+ return null;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static ItemStack getItemStackInPlayersHand(){
+ Minecraft mc = Minecraft.getMinecraft();
+ ItemStack heldItem = null;
+ try{heldItem = mc.thePlayer.getHeldItem();
+ }catch(NullPointerException e){return null;}
+ if (heldItem != null){
+ return heldItem;
+ }
+ return null;
+ }
+
+ @SideOnly(Side.SERVER)
+ public static ItemStack getItemStackInPlayersHand(EntityPlayer player){
+ ItemStack heldItem = null;
+ try{heldItem = player.getHeldItem();
+ }catch(NullPointerException e){return null;}
+ if (heldItem != null){
+ return heldItem;
+ }
+ return null;
+ }
+
+ public static Item getItemInPlayersHand(){
+ Minecraft mc = Minecraft.getMinecraft();
+ Item heldItem = null;
+
+ try{heldItem = mc.thePlayer.getHeldItem().getItem();
+ }catch(NullPointerException e){return null;}
+
+ if (heldItem != null){
+ return heldItem;
+ }
+
+ return null;
+ }
+
+}