Search in sources :

Example 56 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class CommandJoinSpaceRace method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, sender.getName(), true);
    if (args.length == 0) {
        try {
            if (playerBase != null) {
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                if (stats.getSpaceRaceInviteTeamID() > 0) {
                    SpaceRaceManager.sendSpaceRaceData(server, playerBase, SpaceRaceManager.getSpaceRaceFromID(stats.getSpaceRaceInviteTeamID()));
                    GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_OPEN_JOIN_RACE_GUI, GCCoreUtil.getDimensionID(playerBase.worldObj), new Object[] { stats.getSpaceRaceInviteTeamID() }), playerBase);
                } else {
                    throw new Exception("You haven't been invited to a space race team!");
                }
            } else {
                throw new Exception("Could not find player with name: " + args[0]);
            }
        } catch (final Exception var6) {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    } else {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.joinrace.no_team", this.getCommandUsage(sender)), new Object[0]);
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 57 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class CommandGCAstroMiner method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length > 2) {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
    }
    if (args.length < 1) {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssinvite.wrong_usage", this.getCommandUsage(sender)), new Object[0]);
    }
    int type = 0;
    int newvalue = 0;
    if (args[0].equalsIgnoreCase("show")) {
        type = 1;
    } else if (args[0].equalsIgnoreCase("reset")) {
        type = 2;
    } else if (args[0].length() > 3 && args[0].substring(0, 3).equalsIgnoreCase("set")) {
        String number = args[0].substring(3);
        try {
            newvalue = Integer.parseInt(number);
            if (newvalue > 0) {
                type = 3;
            }
        } catch (NumberFormatException ex) {
        }
    }
    // Proceed if syntax of show|reset|set<number> was correct
    if (type > 0) {
        EntityPlayerMP playerBase = null;
        try {
            if (args.length == 2) {
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[1], true);
            } else {
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
            }
            if (playerBase != null) {
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                switch(type) {
                    case 1:
                        sender.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("command.gcastrominer.count", PlayerUtil.getName(playerBase), "" + stats.getAstroMinerCount())));
                        break;
                    case 2:
                        stats.setAstroMinerCount(0);
                        sender.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("command.gcastrominer.count", PlayerUtil.getName(playerBase), "" + 0)));
                        break;
                    case 3:
                        stats.setAstroMinerCount(newvalue);
                        sender.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("command.gcastrominer.count", PlayerUtil.getName(playerBase), "" + newvalue)));
                        break;
                }
            } else {
                throw new Exception("Could not find player with name: " + args[1]);
            }
        } catch (final Exception e) {
            throw new CommandException(e.getMessage(), new Object[0]);
        }
        return;
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) ChatComponentText(net.minecraft.util.ChatComponentText) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 58 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class ItemBasicVenus method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (player instanceof EntityPlayerMP && itemStack.getItemDamage() == 0) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        ItemStack gear = stats.getExtendedInventory().getStackInSlot(10);
        if (gear == null) {
            stats.getExtendedInventory().setInventorySlotContents(10, itemStack.copy());
            itemStack.stackSize = 0;
        }
    }
    return itemStack;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 59 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class ItemEmergencyKit method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (player instanceof EntityPlayerMP) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        for (int i = 0; i < SIZE; i++) {
            ItemStack newGear = getContents(i);
            if (newGear.getItem() instanceof ISortableItem && ((ISortableItem) newGear.getItem()).getCategory(newGear.getItemDamage()) == EnumSortCategoryItem.GEAR) {
                newGear = newGear.getItem().onItemRightClick(newGear, world, player);
            }
            if (newGear.stackSize >= 1) {
                ItemHandlerHelper.giveItemToPlayer(player, newGear, 0);
            }
        }
        itemStack.stackSize = 0;
    }
    return itemStack;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 60 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class ItemBlockPanel method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!player.isSneaking()) {
        return false;
    }
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock().isOpaqueCube() && !(state.getBlock() instanceof BlockPanelLighting)) {
        if (world.isRemote) {
            BlockPanelLighting.updateClient(stack.getItemDamage(), state);
        } else {
            int meta = stack.getItemDamage();
            if (meta >= BlockPanelLighting.PANELTYPES_LENGTH)
                meta = 0;
            GCPlayerStats stats = GCPlayerStats.get(player);
            IBlockState[] panels = stats.getPanelLightingBases();
            panels[meta] = state;
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) BlockPanelLighting(micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)

Aggregations

GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)88 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)55 ItemStack (net.minecraft.item.ItemStack)43 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)19 CommandException (net.minecraft.command.CommandException)16 WrongUsageException (net.minecraft.command.WrongUsageException)16 TextComponentString (net.minecraft.util.text.TextComponentString)16 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)14 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)12 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)12 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)12 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)10 TileEntity (net.minecraft.tileentity.TileEntity)10 BlockPos (net.minecraft.util.math.BlockPos)10 WorldServer (net.minecraft.world.WorldServer)10 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)8 Entity (net.minecraft.entity.Entity)7 PotionEffect (net.minecraft.potion.PotionEffect)7 ChatComponentText (net.minecraft.util.ChatComponentText)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)6