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