use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project MorePlanets by SteveKunG.
the class TeleportUtil method startNewDimension.
@Deprecated
public static void startNewDimension(EntityPlayerMP player) {
WorldServer worldOld = (WorldServer) player.world;
WorldServer worldNew = WorldDimensionHelper.getStartWorld(worldOld);
BlockPos blockpos = worldNew.getTopSolidOrLiquidBlock(worldNew.getSpawnPoint());
boolean dimChange = player.world != worldNew;
player.world.updateEntityWithOptionalForce(player, false);
int oldDimID = GCCoreUtil.getDimensionID(player.world);
ChunkPos pair = worldNew.getChunkFromChunkCoords(blockpos.getX(), blockpos.getZ()).getPos();
if (dimChange) {
try {
worldOld.getPlayerChunkMap().removePlayer(player);
} catch (Exception e) {
e.printStackTrace();
}
player.closeScreen();
player.dimension = GCCoreUtil.getDimensionID(worldNew);
player.connection.sendPacket(new SPacketRespawn(GCCoreUtil.getDimensionID(worldNew), player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
worldOld.playerEntities.remove(player);
worldOld.updateAllPlayersSleepingFlag();
if (player.addedToChunk && worldOld.getChunkProvider().chunkExists(player.chunkCoordX, player.chunkCoordZ)) {
Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
chunkOld.removeEntity(player);
chunkOld.setModified(true);
}
worldOld.loadedEntityList.remove(player);
worldOld.onEntityRemoved(player);
worldNew.spawnEntity(player);
player.setWorld(worldNew);
MorePlanetsCore.PROXY.resetFloatingTick(player);
if (!(worldNew.provider instanceof IGalacticraftWorldProvider)) {
MPLog.error("{} is not space world!", ConfigManagerMP.startedPlanet);
throw new RuntimeException(ConfigManagerMP.startedPlanet + " is not space world!");
}
if (worldNew.provider instanceof IStartedDimension) {
IStartedDimension dimension = (IStartedDimension) worldNew.provider;
MPLog.debug("Setting up player gear");
dimension.setup(player);
} else {
GCPlayerStats stats = GCPlayerStats.get(player);
MPLog.debug("Setting up player gear for Non-IStartedDimension world");
// Knows how to build T2 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(GCItems.schematic, 1, 1));
// Knows how to build T3 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(MarsItems.schematic, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(0, new ItemStack(GCItems.oxMask, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(2, new ItemStack(GCItems.oxTankHeavy, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(3, new ItemStack(GCItems.oxTankHeavy, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
stats.getExtendedInventory().setInventorySlotContents(6, new ItemStack(AsteroidsItems.thermalPadding, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(7, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
stats.getExtendedInventory().setInventorySlotContents(8, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
stats.getExtendedInventory().setInventorySlotContents(9, new ItemStack(AsteroidsItems.thermalPadding, 1, 3));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
}
worldNew.getChunkProvider().loadChunk(pair.x, pair.z);
worldNew.updateEntityWithOptionalForce(player, false);
player.setLocationAndAngles(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
player.mcServer.getPlayerList().preparePlayer(player, worldNew);
player.connection.setPlayerLocation(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.interactionManager.setWorld(worldNew);
player.mcServer.getPlayerList().updateTimeAndWeatherForPlayer(player, worldNew);
player.mcServer.getPlayerList().syncPlayerInventory(player);
for (Object o : player.getActivePotionEffects()) {
PotionEffect potion = (PotionEffect) o;
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potion));
}
player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
} else {
player.closeScreen();
worldNew.updateEntityWithOptionalForce(player, false);
player.connection.setPlayerLocation(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.setLocationAndAngles(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
worldNew.updateEntityWithOptionalForce(player, false);
}
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimID, GCCoreUtil.getDimensionID(worldNew));
if (player.onGround && player.getBedLocation(GCCoreUtil.getDimensionID(player.world)) == null) {
int i = 30000000;
int j = Math.min(i, Math.max(-i, MathHelper.floor(player.posX + 0.5D)));
int k = Math.min(256, Math.max(0, MathHelper.floor(player.posY + 1.5D)));
int l = Math.min(i, Math.max(-i, MathHelper.floor(player.posZ + 0.5D)));
BlockPos coords = new BlockPos(j, k, l);
player.setSpawnChunk(coords, true, GCCoreUtil.getDimensionID(player.world));
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class CommandGCHouston method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP playerBase = null;
MinecraftServer server = MinecraftServer.getServer();
boolean isOp = false;
Entity entitySender = sender.getCommandSenderEntity();
if (entitySender == null) {
isOp = true;
} else if (entitySender instanceof EntityPlayer) {
GameProfile prof = ((EntityPlayer) entitySender).getGameProfile();
isOp = server.getConfigurationManager().canSendCommands(prof);
}
if (args.length < 2) {
try {
if (args.length == 0) {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
if (!playerBase.capabilities.isCreativeMode) {
if (ConfigManagerCore.challengeMode || !(playerBase.worldObj.provider instanceof IGalacticraftWorldProvider)) {
CommandBase.notifyOperators(sender, this, "commands.gchouston.fail");
return;
}
}
if (timerList.contains(playerBase)) {
timerList.remove(playerBase);
} else {
timerList.add(playerBase);
TickHandlerServer.timerHoustonCommand = 250;
String msg = EnumColor.YELLOW + GCCoreUtil.translate("commands.gchouston.confirm.1") + " " + EnumColor.WHITE + GCCoreUtil.translate("commands.gchouston.confirm.2");
CommandBase.notifyOperators(sender, this, msg);
return;
}
} else {
if (!isOp) {
CommandBase.notifyOperators(sender, this, "commands.gchouston.noop");
return;
}
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
}
if (playerBase != null) {
int dimID = ConfigManagerCore.idDimensionOverworld;
WorldServer worldserver = server.worldServerForDimension(dimID);
if (worldserver == null) {
worldserver = server.worldServerForDimension(0);
if (worldserver == null) {
throw new Exception("/gchouston could not find Overworld.");
}
dimID = 0;
}
BlockPos spawnPoint = null;
BlockPos bedPos = playerBase.getBedLocation(dimID);
if (bedPos != null) {
spawnPoint = EntityPlayer.getBedSpawnLocation(worldserver, bedPos, false);
}
if (spawnPoint == null) {
spawnPoint = worldserver.getTopSolidOrLiquidBlock(worldserver.getSpawnPoint());
}
GCPlayerStats stats = GCPlayerStats.get(playerBase);
stats.setRocketStacks(new ItemStack[0]);
stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
stats.setRocketItem(null);
stats.setFuelLevel(0);
stats.setCoordsTeleportedFromX(spawnPoint.getX());
stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
stats.setUsingPlanetSelectionGui(false);
playerBase.closeScreen();
Vector3 spawnPos = new Vector3(spawnPoint.getX() + 0.5D, spawnPoint.getY() + 0.25D, spawnPoint.getZ() + 0.5D);
try {
WorldUtil.teleportEntitySimple(worldserver, dimID, playerBase, spawnPos);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
CommandBase.notifyOperators(sender, this, "commands.gchouston.success", 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.getCommandUsage(sender)), new Object[0]);
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class CommandSpaceStationChangeOwner method processCommand.
@Override
public void processCommand(ICommandSender icommandsender, String[] astring) throws CommandException {
String oldOwner = null;
String newOwner = "ERROR";
int stationID = -1;
EntityPlayerMP playerAdmin = PlayerUtil.getPlayerBaseServerFromPlayerUsername(icommandsender.getName(), true);
if (astring.length > 1) {
newOwner = astring[1];
try {
stationID = Integer.parseInt(astring[0]);
} catch (final Exception var6) {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssnewowner.wrong_usage", this.getCommandUsage(icommandsender)), new Object[0]);
}
if (stationID < 2) {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssnewowner.wrong_usage", this.getCommandUsage(icommandsender)), new Object[0]);
}
try {
SpaceStationWorldData stationData = SpaceStationWorldData.getMPSpaceStationData(null, stationID, null);
if (stationData == null) {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssnewowner.wrong_usage", this.getCommandUsage(icommandsender)), new Object[0]);
}
oldOwner = stationData.getOwner();
stationData.getAllowedPlayers().remove(oldOwner);
if (stationData.getSpaceStationName().equals("Station: " + oldOwner)) {
stationData.setSpaceStationName("Station: " + newOwner);
}
stationData.getAllowedPlayers().add(newOwner);
stationData.setOwner(newOwner);
final EntityPlayerMP oldPlayer = PlayerUtil.getPlayerBaseServerFromPlayerUsername(oldOwner, true);
final EntityPlayerMP newPlayer = PlayerUtil.getPlayerBaseServerFromPlayerUsername(newOwner, true);
if (oldPlayer != null) {
GCPlayerStats stats = GCPlayerStats.get(oldPlayer);
SpaceStationWorldData.updateSSOwnership(oldPlayer, oldOwner, stats, stationID, stationData);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SPACESTATION_CLIENT_ID, GCCoreUtil.getDimensionID(oldPlayer.worldObj), new Object[] { WorldUtil.spaceStationDataToString(stats.getSpaceStationDimensionData()) }), oldPlayer);
}
if (newPlayer != null) {
GCPlayerStats stats = GCPlayerStats.get(newPlayer);
SpaceStationWorldData.updateSSOwnership(newPlayer, newOwner.replace(".", ""), stats, stationID, stationData);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SPACESTATION_CLIENT_ID, GCCoreUtil.getDimensionID(oldPlayer.worldObj), new Object[] { WorldUtil.spaceStationDataToString(stats.getSpaceStationDimensionData()) }), newPlayer);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssinvite.wrong_usage", this.getCommandUsage(icommandsender)), new Object[0]);
}
if (playerAdmin != null) {
playerAdmin.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.spacestation.changesuccess", oldOwner, newOwner)));
} else // Console
{
System.out.println(GCCoreUtil.translateWithFormat("gui.spacestation.changesuccess", oldOwner, newOwner));
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class CommandSpaceStationRemoveOwner method getPlayers.
protected String[] getPlayers(ICommandSender sender) {
EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), false);
if (playerBase != null) {
GCPlayerStats stats = GCPlayerStats.get(playerBase);
if (!stats.getSpaceStationDimensionData().isEmpty()) {
String[] allNames = MinecraftServer.getServer().getAllUsernames();
// data.getAllowedPlayers may include some in lowercase
// Convert to correct case at least for those players who are online
HashSet<String> allowedNames = Sets.newHashSet();
for (Map.Entry<Integer, Integer> e : stats.getSpaceStationDimensionData().entrySet()) {
final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.worldObj, e.getValue(), playerBase);
allowedNames.addAll(data.getAllowedPlayers());
}
Iterator<String> itName = allowedNames.iterator();
ArrayList<String> replaceNames = new ArrayList<String>();
while (itName.hasNext()) {
String name = itName.next();
for (String allEntry : allNames) {
if (name.equalsIgnoreCase(allEntry)) {
itName.remove();
replaceNames.add(allEntry);
}
}
}
// This does the conversion to correct case
allowedNames.addAll(replaceNames);
String[] rvsize = new String[allowedNames.size()];
return allowedNames.toArray(rvsize);
}
}
String[] returnvalue = { "" };
return returnvalue;
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class CommandPlanetTeleport method processCommand.
@Override
public void processCommand(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) {
MinecraftServer server = MinecraftServer.getServer();
WorldServer worldserver = server.worldServerForDimension(GCCoreUtil.getDimensionID(server.worldServers[0]));
BlockPos spawnPoint = worldserver.getSpawnPoint();
GCPlayerStats stats = GCPlayerStats.get(playerBase);
stats.setRocketStacks(new ItemStack[2]);
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.notifyOperators(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.getCommandUsage(sender)), new Object[0]);
}
}
Aggregations