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]);
}
}
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;
}
}
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;
}
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;
}
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;
}
Aggregations