Search in sources :

Example 86 with GCPlayerStats

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

the class CommandPlanetTeleport method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    EntityPlayerMP playerBase = null;
    if (args.length < 2) {
        try {
            if (args.length == 1) {
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
            } else {
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
            }
            if (playerBase != null) {
                WorldServer worldserver = server.getWorld(GCCoreUtil.getDimensionID(server.worlds[0]));
                BlockPos spawnPoint = worldserver.getSpawnPoint();
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                stats.setRocketStacks(NonNullList.withSize(2, ItemStack.EMPTY));
                stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
                stats.setRocketItem(GCItems.rocketTier1);
                stats.setFuelLevel(1000);
                stats.setCoordsTeleportedFromX(spawnPoint.getX());
                stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
                try {
                    WorldUtil.toCelestialSelection(playerBase, stats, Integer.MAX_VALUE);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw e;
                }
                CommandBase.notifyCommandListener(sender, this, "commands.dimensionteleport", new Object[] { String.valueOf(EnumColor.GREY + "[" + playerBase.getName()), "]" });
            } 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.dimensiontp.too_many", this.getUsage(sender)), new Object[0]);
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) CommandException(net.minecraft.command.CommandException) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 87 with GCPlayerStats

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

the class EntityTier2Rocket method onTeleport.

@Override
public void onTeleport(EntityPlayerMP player) {
    EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    if (playerBase != null) {
        GCPlayerStats stats = GCPlayerStats.get(playerBase);
        if (this.stacks == null || this.stacks.size() == 0) {
            stats.setRocketStacks(NonNullList.withSize(2, ItemStack.EMPTY));
        } else {
            stats.setRocketStacks(this.stacks);
        }
        stats.setRocketType(this.rocketType.getIndex());
        stats.setRocketItem(MarsItems.rocketMars);
        stats.setFuelLevel(this.fuelTank.getFluidAmount());
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 88 with GCPlayerStats

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

the class EntityCreeperBoss method getGuaranteedLoot.

@Override
public ItemStack getGuaranteedLoot(Random rand) {
    List<ItemStack> stackList = new LinkedList<>();
    stackList.addAll(GalacticraftRegistry.getDungeonLoot(2));
    boolean hasT3Rocket = false;
    boolean hasAstroMiner = false;
    // Check if player seems to have Tier 3 rocket or Astro Miner already - in that case we don't want more
    // (we don't really want him giving powerful schematics to his friends who are still on Overworld)
    final EntityPlayer player = this.world.getClosestPlayer(this.posX, this.posY, this.posZ, 20.0, false);
    if (player != null) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        if (stats != null) {
            for (ISchematicPage page : stats.getUnlockedSchematics()) {
                if (page.getPageID() == ConfigManagerAsteroids.idSchematicRocketT3) {
                    hasT3Rocket = true;
                } else if (page.getPageID() == ConfigManagerAsteroids.idSchematicRocketT3 + 1) {
                    hasAstroMiner = true;
                }
            }
        }
    }
    // Remove schematics which he already has
    if (hasT3Rocket && hasAstroMiner) {
        // (but do not remove both, otherwise the list is too short)
        if (stackList.size() == 3) {
            stackList.remove(1 + rand.nextInt(2));
        } else {
            stackList.remove(2);
            stackList.remove(1);
        }
    } else if (hasT3Rocket) {
        stackList.remove(1);
    } else if (hasAstroMiner) {
        stackList.remove(2);
    }
    // If he does not yet have the T3 rocket, limit the list size to 2 so 50% chance of getting it
    // otherwise return the full list (note: addons could have added more schematics to the list)
    int range = (!hasT3Rocket) ? 2 : stackList.size();
    return stackList.get(rand.nextInt(range)).copy();
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) LinkedList(java.util.LinkedList) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)

Example 89 with GCPlayerStats

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

the class TeleportTypeMars method getPlayerSpawnLocation.

@Override
public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) {
    if (player != null) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        double x = stats.getCoordsTeleportedFromX();
        double z = stats.getCoordsTeleportedFromZ();
        int limit = ConfigManagerCore.otherPlanetWorldBorders - 2;
        if (limit > 20) {
            if (x > limit) {
                z *= limit / x;
                x = limit;
            } else if (x < -limit) {
                z *= -limit / x;
                x = -limit;
            }
            if (z > limit) {
                x *= limit / z;
                z = limit;
            } else if (z < -limit) {
                x *= -limit / z;
                z = -limit;
            }
        }
        return new Vector3(x, ConfigManagerCore.disableLander ? 250.0 : 900.0, z);
    }
    return null;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 90 with GCPlayerStats

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

the class TeleportTypeMars method onSpaceDimensionChanged.

@Override
public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) {
    if (!ridingAutoRocket && player != null) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        if (stats.getTeleportCooldown() <= 0) {
            if (player.capabilities.isFlying) {
                player.capabilities.isFlying = false;
            }
            EntityLandingBalloons lander = new EntityLandingBalloons(player);
            if (!newWorld.isRemote) {
                boolean previous = CompatibilityManager.forceLoadChunks((WorldServer) newWorld);
                lander.forceSpawn = true;
                newWorld.spawnEntity(lander);
                CompatibilityManager.forceLoadChunksEnd((WorldServer) newWorld, previous);
            }
            stats.setTeleportCooldown(10);
        }
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityLandingBalloons(micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons)

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