use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class EntitySpaceshipBase method onUpdate.
@Override
public void onUpdate() {
this.ticks++;
super.onUpdate();
if (this.addToTelemetry) {
this.addToTelemetry = false;
for (BlockVec3Dim vec : new ArrayList<BlockVec3Dim>(this.telemetryList)) {
TileEntity t1 = vec.getTileEntityNoLoad();
if (t1 instanceof TileEntityTelemetry && !t1.isInvalid()) {
if (((TileEntityTelemetry) t1).linkedEntity == this)
((TileEntityTelemetry) t1).addTrackedEntity(this);
}
}
}
for (Entity e : this.getPassengers()) {
e.fallDistance = 0.0F;
}
if (this.posY > (this.world.provider instanceof IExitHeight ? ((IExitHeight) this.world.provider).getYCoordinateToTeleport() : 1200) && this.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
this.onReachAtmosphere();
// if (this.world.isRemote)
// this.posY = 1 + (this.world.provider instanceof IExitHeight ? ((IExitHeight) this.world.provider).getYCoordinateToTeleport() : 1200);
}
if (this.rollAmplitude > 0) {
this.rollAmplitude--;
}
if (this.shipDamage > 0) {
this.shipDamage--;
}
if (!this.world.isRemote) {
if (this.posY < 0.0D) {
this.setDead();
} else if (this.posY > (this.world.provider instanceof IExitHeight ? ((IExitHeight) this.world.provider).getYCoordinateToTeleport() : 1200) + (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() ? 355 : 100)) {
for (Entity e : this.getPassengers()) {
if (e instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(e);
if (stats.isUsingPlanetSelectionGui()) {
this.setDead();
}
} else
this.setDead();
}
}
if (this.timeSinceLaunch > 50 && this.onGround) {
this.failRocket();
}
}
if (this.launchPhase == EnumLaunchPhase.UNIGNITED.ordinal()) {
this.timeUntilLaunch = this.getPreLaunchWait();
}
if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
this.timeSinceLaunch++;
} else {
this.timeSinceLaunch = 0;
}
if (this.timeUntilLaunch > 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
this.timeUntilLaunch--;
}
AxisAlignedBB box = this.getEntityBoundingBox().grow(0.2D);
final List<?> var15 = this.world.getEntitiesWithinAABBExcludingEntity(this, box);
if (var15 != null && !var15.isEmpty()) {
for (int var52 = 0; var52 < var15.size(); ++var52) {
final Entity var17 = (Entity) var15.get(var52);
if (this.getPassengers().contains(var17)) {
var17.applyEntityCollision(this);
}
}
}
if (this.timeUntilLaunch == 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
this.setLaunchPhase(EnumLaunchPhase.LAUNCHED);
this.onLaunch();
}
if (this.rotationPitch > 90) {
this.rotationPitch = 90;
}
if (this.rotationPitch < -90) {
this.rotationPitch = -90;
}
this.motionX = -(50 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
this.motionZ = -(50 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal()) {
this.motionX = this.motionY = this.motionZ = 0.0F;
}
if (this.world.isRemote) {
this.setPosition(this.posX, this.posY, this.posZ);
if (this.shouldMoveClientSide()) {
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
}
} else {
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
}
this.setRotation(this.rotationYaw, this.rotationPitch);
if (this.world.isRemote) {
this.setPosition(this.posX, this.posY, this.posZ);
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (!this.world.isRemote && this.ticks % 3 == 0) {
GalacticraftCore.packetPipeline.sendToDimension(new PacketDynamic(this), this.world.provider.getDimension());
// PacketDispatcher.sendPacketToAllInDimension(GCCorePacketManager.getPacket(GalacticraftCore.CHANNELENTITIES,
// this, this.getNetworkedData(new ArrayList())),
// this.world.provider.getDimension());
}
if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
if (// When the screen changes to the map, the player is not riding the rocket anymore.
getPassengers().size() >= 1) {
if (getPassengers().get(0) instanceof EntityPlayerMP) {
GCTriggers.LAUNCH_ROCKET.trigger(((EntityPlayerMP) getPassengers().get(0)));
}
}
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class TeleportTypeMoon method onSpaceDimensionChanged.
@Override
public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) {
GCPlayerStats stats = GCPlayerStats.get(player);
if (!ridingAutoRocket && !ConfigManagerCore.disableLander && stats.getTeleportCooldown() <= 0) {
if (player.capabilities.isFlying) {
player.capabilities.isFlying = false;
}
EntityLander lander = new EntityLander(player);
lander.setPosition(player.posX, player.posY, player.posZ);
if (!newWorld.isRemote) {
boolean previous = CompatibilityManager.forceLoadChunks((WorldServer) newWorld);
lander.forceSpawn = true;
newWorld.spawnEntity(lander);
lander.setWorld(newWorld);
newWorld.updateEntityWithOptionalForce(lander, true);
player.startRiding(lander);
CompatibilityManager.forceLoadChunksEnd((WorldServer) newWorld, previous);
GCLog.debug("Entering lander at : " + player.posX + "," + player.posZ + " lander spawn at: " + lander.posX + "," + lander.posZ);
}
stats.setTeleportCooldown(10);
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class TeleportTypeMoon 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 CommandGCInv method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (CommandGCInv.firstuse) {
CommandGCInv.firstuse = false;
CommandGCInv.initialise();
}
if (args.length == 2) {
try {
EntityPlayerMP thePlayer = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[1], true);
if (thePlayer != null && !thePlayer.isDead && thePlayer.world != null) {
GCPlayerStats stats = GCPlayerStats.get(thePlayer);
if (args[0].equalsIgnoreCase("drop")) {
InventoryExtended gcInventory = stats.getExtendedInventory();
gcInventory.dropExtendedItems(thePlayer);
} else if (args[0].equalsIgnoreCase("save")) {
InventoryExtended gcInventory = stats.getExtendedInventory();
ItemStack[] saveinv = new ItemStack[gcInventory.getSizeInventory()];
for (int i = 0; i < gcInventory.getSizeInventory(); i++) {
saveinv[i] = gcInventory.getStackInSlot(i);
gcInventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
CommandGCInv.savedata.put(args[1].toLowerCase(), saveinv);
CommandGCInv.dontload.add(args[1].toLowerCase());
CommandGCInv.writefile();
System.out.println("[GCInv] Saving and clearing GC inventory slots of " + PlayerUtil.getName(thePlayer));
} else if (args[0].equalsIgnoreCase("restore")) {
ItemStack[] saveinv = CommandGCInv.savedata.get(args[1].toLowerCase());
CommandGCInv.dontload.remove(args[1].toLowerCase());
if (saveinv == null) {
System.out.println("[GCInv] Tried to restore but player " + PlayerUtil.getName(thePlayer) + " had no saved GC inventory items.");
return;
}
CommandGCInv.doLoad(thePlayer);
} else if (args[0].equalsIgnoreCase("clear")) {
InventoryExtended gcInventory = stats.getExtendedInventory();
for (int i = 0; i < gcInventory.getSizeInventory(); i++) {
gcInventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
} else {
throw new WrongUsageException("Invalid GCInv command. Usage: " + this.getUsage(sender));
}
} else {
// inventory already)
if (args[0].equalsIgnoreCase("restore")) {
ItemStack[] saveinv = CommandGCInv.savedata.get(args[1].toLowerCase());
if (saveinv != null) {
System.out.println("[GCInv] Restore command for offline player " + args[1] + ", setting to restore GCInv on next login.");
CommandGCInv.dontload.remove(args[1].toLowerCase());
// Now it can autoload on next player logon
return;
}
}
// No player found, and not a 'restore' command
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("save") || args[0].equalsIgnoreCase("drop")) {
System.out.println("GCInv command: player " + args[1] + " not found.");
} else {
throw new WrongUsageException("Invalid GCInv command. Usage: " + this.getUsage(sender), new Object[0]);
}
}
} catch (final Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
} else {
throw new WrongUsageException("Not enough command arguments! Usage: " + this.getUsage(sender), new Object[0]);
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class CommandJoinSpaceRace method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
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.world), 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.getUsage(sender)), new Object[0]);
}
}
Aggregations