aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/player
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2018-02-22 13:55:56 +1000
committerJordan Byrne <draknyte1@hotmail.com>2018-02-22 13:55:56 +1000
commit24905c16017decae4ee60ce4128b6d26de66baf5 (patch)
tree503cef5b6b77e04b11feea7563cd5f4ef5ef6942 /src/Java/gtPlusPlus/core/util/player
parentc5ddbd07991eea29132efbd7f4131ab9a4a977cf (diff)
downloadGT5-Unofficial-24905c16017decae4ee60ce4128b6d26de66baf5.tar.gz
GT5-Unofficial-24905c16017decae4ee60ce4128b6d26de66baf5.tar.bz2
GT5-Unofficial-24905c16017decae4ee60ce4128b6d26de66baf5.zip
% Minor project cleanup.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/player')
-rw-r--r--src/Java/gtPlusPlus/core/util/player/PlayerUtils.java175
-rw-r--r--src/Java/gtPlusPlus/core/util/player/UtilsMining.java214
2 files changed, 0 insertions, 389 deletions
diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
deleted file mode 100644
index 32488f074d..0000000000
--- a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package gtPlusPlus.core.util.player;
-
-import java.util.*;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gtPlusPlus.core.util.Utils;
-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;
-
-public class PlayerUtils {
-
- public static void messagePlayer(final EntityPlayer P, final String S){
- gregtech.api.util.GT_Utility.sendChatToPlayer(P, S);
- }
-
- public static EntityPlayer getPlayer(final String name){
- try{
- final List<EntityPlayer> i = new ArrayList<>();
- final Iterator<EntityPlayerMP> iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
- while (iterator.hasNext()) {
- i.add((iterator.next()));
- }
- for (final EntityPlayer temp : i) {
- if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){
- return temp;
- }
- }
- }
- catch(final Throwable e){}
- return null;
- }
-
- public static EntityPlayer getPlayerOnServerFromUUID(final UUID parUUID){
- if (parUUID == null)
- {
- return null;
- }
- final List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
- for (final EntityPlayerMP player : allPlayers)
- {
- if (player.getUniqueID().equals(parUUID))
- {
- return player;
- }
- }
- return null;
- }
-
- //Not Clientside
- public static EntityPlayer getPlayerInWorld(final World world, final String Name){
- final List<EntityPlayer> i = world.playerEntities;
- final Minecraft mc = Minecraft.getMinecraft();
- try{
- for (final EntityPlayer temp : i) {
- if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){
- return temp;
- }
- }
- }
- catch(final NullPointerException e){}
- return null;
- }
-
- public static boolean isPlayerOP(final EntityPlayer player){
- if (player.canCommandSenderUseCommand(2, "")){
- return true;
- }
- return false;
- }
-
- //Not Clientside
- public static ItemStack getItemStackInPlayersHand(final World world, final String Name){
- final EntityPlayer thePlayer = getPlayer(Name);
- ItemStack heldItem = null;
- try{heldItem = thePlayer.getHeldItem();
- }catch(final NullPointerException e){return null;}
- if (heldItem != null){
- return heldItem;
- }
- return null;
- }
-
- @SideOnly(Side.CLIENT)
- public static ItemStack getItemStackInPlayersHand(){
- final Minecraft mc = Minecraft.getMinecraft();
- ItemStack heldItem = null;
- try{heldItem = mc.thePlayer.getHeldItem();
- }catch(final NullPointerException e){return null;}
- if (heldItem != null){
- return heldItem;
- }
- return null;
- }
-
- @SideOnly(Side.SERVER)
- public static ItemStack getItemStackInPlayersHand(final EntityPlayer player){
- ItemStack heldItem = null;
- try{heldItem = player.getHeldItem();
- }catch(final NullPointerException e){
- e.printStackTrace();
- return null;
- }
- if (heldItem != null){
- return heldItem;
- }
- return null;
- }
-
- @SideOnly(Side.CLIENT)
- public static Item getItemInPlayersHandClient(){
- final Minecraft mc = Minecraft.getMinecraft();
- Item heldItem = null;
-
- try{heldItem = mc.thePlayer.getHeldItem().getItem();
- }catch(final NullPointerException e){return null;}
-
- if (heldItem != null){
- return heldItem;
- }
-
- return null;
- }
-
- public static Item getItemInPlayersHand(final EntityPlayer player){
- Item heldItem = null;
- try{
- heldItem = player.getHeldItem().getItem();
- }catch(final NullPointerException e){return null;}
-
- if (heldItem != null){
- return heldItem;
- }
- return null;
- }
-
- public final static EntityPlayer getPlayerEntityByName(final String aPlayerName){
- final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName);
- if (player != null){
- return player;
- }
- return null;
- }
-
- public final static UUID getPlayersUUIDByName(final String aPlayerName){
- final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName);
- if (player != null){
- return player.getUniqueID();
- }
- return null;
- }
-
- @SideOnly(Side.CLIENT)
- public static final boolean isPlayerAlkalus(){
- if (Utils.isServer()){
- return false;
- }
- return isPlayerAlkalus(Minecraft.getMinecraft().thePlayer);
- }
-
- public static final boolean isPlayerAlkalus(EntityPlayer player){
- if (player != null){
- if (player.getDisplayName().toLowerCase().equals("draknyte1") || player.getDisplayName().toLowerCase().equals("alkalus")){
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java
deleted file mode 100644
index 4f0402a18e..0000000000
--- a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package gtPlusPlus.core.util.player;
-
-import gtPlusPlus.api.objects.Logger;
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-
-public class UtilsMining {
-
- private static boolean durabilityDamage = false;
- private static ItemStack stack;
-
- public static Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld){
- String correctTool = "";
- if (!currentWorld.isRemote){
- try {
- correctTool = currentBlock.getHarvestTool(0);
- //Utils.LOG_WARNING(correctTool);
- if (correctTool.equals("pickaxe")){
- return true;}
- } catch (final NullPointerException e){
- return false;}
- }
- return false;
- }
-
- private static void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z){
- try {
- final Block block = world.getBlock(X, Y, Z);
- if (canPickaxeBlock(block, world)){
- if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){
- block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0);
- world.setBlockToAir(X, Y, Z);
-
- }
- else {
- Logger.WARNING("Incorrect Tool for mining this block.");
- }
- }
- } catch (final NullPointerException e){
-
- }
- }
-
- /*public static void customMine(World world, String FACING, EntityPlayer aPlayer){
-
- float DURABILITY_LOSS = 0;
- if (!world.isRemote){
- int X = 0;
- int Y = 0;
- int Z = 0;
-
- if (FACING.equals("below") || FACING.equals("above")){
-
- //Set Player Facing
- X = (int) aPlayer.posX;
- Utils.LOG_WARNING("Setting Variable X: "+X);
- if (FACING.equals("above")){
- Z = (int) aPlayer.posY + 1;
- Utils.LOG_WARNING("Setting Variable Y: "+Y);
- }
- else {
- Z = (int) aPlayer.posY - 1;
- Utils.LOG_WARNING("Setting Variable Y: "+Y);}
- Z = (int) aPlayer.posZ;
- Utils.LOG_WARNING("Setting Variable Z: "+Z);
-
- DURABILITY_LOSS = 0;
- for(int i = -2; i < 3; i++) {
- for(int j = -2; j < 3; j++) {
- for(int k = -2; k < 3; k++) {
-// float dur = calculateDurabilityLoss(world, X + i, Y + k, Z + j);
-// DURABILITY_LOSS = (DURABILITY_LOSS + dur);
-// Utils.LOG_WARNING("Added Loss: "+dur);
- removeBlockAndDropAsItem(world, X + i, Y + k, Z + j);
- }
- }
- }
- }
-
- else if (FACING.equals("facingEast") || FACING.equals("facingWest")){
-
- //Set Player Facing
- Z = (int) aPlayer.posZ;
- Y = (int) aPlayer.posY;
- if (FACING.equals("facingEast")){
- X = (int) aPlayer.posX + 1;}
- else {
- X = (int) aPlayer.posX - 1;}
-
-
- DURABILITY_LOSS = 0;
- for(int i = -1; i < 2; i++) {
- for(int j = -1; j < 2; j++) {
- for(int k = -1; k < 2; k++) {
- float dur = calculateDurabilityLoss(world, X+k, Y + i, Z + j);
- DURABILITY_LOSS = (DURABILITY_LOSS + dur);
- Utils.LOG_WARNING("Added Loss: "+dur);
- removeBlockAndDropAsItem(world, X+k, Y + i, Z + j);
- }
- }
- }
- }
-
- else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){
-
- //Set Player Facing
- X = (int) aPlayer.posX;
- Y = (int) aPlayer.posY;
-
- if (FACING.equals("facingNorth")){
- Z = (int) aPlayer.posZ + 1;}
- else {
- Z = (int) aPlayer.posZ - 1;}
-
- DURABILITY_LOSS = 0;
- for(int i = -1; i < 2; i++) {
- for(int j = -1; j < 2; j++) {
- for(int k = -1; k < 2; k++) {
- float dur = calculateDurabilityLoss(world, X + j, Y + i, Z+k);
- DURABILITY_LOSS = (DURABILITY_LOSS + dur);
- Utils.LOG_WARNING("Added Loss: "+dur);
- removeBlockAndDropAsItem(world, X + j, Y + i, Z+k);
- }
- }
- }
- }
-
- //Set Durability damage to the item
- if (durabilityDamage == true){
- Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS);
- if (stack.getItemDamage() < (stack.getMaxDamage()-DURABILITY_LOSS)){
- stack.damageItem((int) DURABILITY_LOSS, aPlayer);
- }
- }
- DURABILITY_LOSS = 0;
- }
- }*/
-
-
- public static boolean getBlockType(final Block block, final World world, final int[] xyz, final int miningLevel){
- final String LIQUID = "liquid";
- final String BLOCK = "block";
- final String ORE = "ore";
- final String AIR = "air";
- String blockClass = "";
-
- if (world.isRemote){
- return false;
- }
-
- if (block == Blocks.end_stone) {
- return true;
- }
- if (block == Blocks.stone) {
- return true;
- }
- if (block == Blocks.sandstone) {
- return true;
- }
- if (block == Blocks.netherrack) {
- return true;
- }
- if (block == Blocks.nether_brick) {
- return true;
- }
- if (block == Blocks.nether_brick_stairs) {
- return true;
- }
- if (block == Blocks.nether_brick_fence) {
- return true;
- }
- if (block == Blocks.glowstone) {
- return true;
- }
-
-
-
- try {
- blockClass = block.getClass().toString().toLowerCase();
- Logger.WARNING(blockClass);
- if (blockClass.toLowerCase().contains(LIQUID)){
- Logger.WARNING(block.toString()+" is a Liquid.");
- return false;
- }
- else if (blockClass.toLowerCase().contains(ORE)){
- Logger.WARNING(block.toString()+" is an Ore.");
- return true;
- }
- else if (block.getHarvestLevel(world.getBlockMetadata(xyz[0], xyz[1], xyz[2])) >= miningLevel){
- Logger.WARNING(block.toString()+" is minable.");
- return true;
- }
- else if (blockClass.toLowerCase().contains(AIR)){
- Logger.WARNING(block.toString()+" is Air.");
- return false;
- }
- else if (blockClass.toLowerCase().contains(BLOCK)){
- Logger.WARNING(block.toString()+" is a block of some kind.");
- return false;
- }
- else {
- Logger.WARNING(block.toString()+" is mystery.");
- return false;
- }
- }
- catch(final NullPointerException e){
- return false;
- }
- }
-
-
-}