use of micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids in project Galacticraft by micdoodle8.
the class TeleportTypeAsteroids method getPlayerSpawnLocation.
@Override
public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) {
if (player != null) {
GCPlayerStats stats = GCPlayerStats.get(player);
int x = MathHelper.floor_double(stats.getCoordsTeleportedFromX());
int z = MathHelper.floor_double(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;
}
}
int attemptCount = 0;
// Small pre-generate with a chunk loading radius of 3, to make sure some asteroids get generated
// (if the world is already generated here, this will be very quick)
this.preGenChunks(world, x >> 4, z >> 4);
do {
BlockVec3 bv3 = null;
if (world.provider instanceof WorldProviderAsteroids) {
bv3 = ((WorldProviderAsteroids) world.provider).getClosestAsteroidXZ(x, 0, z, true);
}
if (bv3 != null) {
// Check whether the returned asteroid is too far from the desired entry location in which case, give up
if (bv3.distanceSquared(new BlockVec3(x, 128, z)) > 25600) {
break;
}
if (ConfigManagerCore.enableDebug) {
GCLog.info("Testing asteroid at x" + (bv3.x) + " y" + (bv3.y) + " z" + bv3.z);
}
this.loadChunksAround(bv3.x, bv3.z, 2, world.theChunkProviderServer);
this.loadChunksAround(bv3.x, bv3.z, -3, world.theChunkProviderServer);
if (goodAsteroidEntry(world, bv3.x, bv3.y, bv3.z)) {
return new Vector3(bv3.x, 310, bv3.z);
}
if (goodAsteroidEntry(world, bv3.x + 2, bv3.y, bv3.z + 2)) {
return new Vector3(bv3.x + 2, 310, bv3.z + 2);
}
if (goodAsteroidEntry(world, bv3.x + 2, bv3.y, bv3.z - 2)) {
return new Vector3(bv3.x + 2, 310, bv3.z - 2);
}
if (goodAsteroidEntry(world, bv3.x - 2, bv3.y, bv3.z - 2)) {
return new Vector3(bv3.x - 2, 310, bv3.z - 2);
}
if (goodAsteroidEntry(world, bv3.x - 2, bv3.y, bv3.z + 2)) {
return new Vector3(bv3.x - 2, 310, bv3.z + 2);
}
// Failed to find an asteroid even though there should be one there
if (ConfigManagerCore.enableDebug) {
GCLog.info("Removing drilled out asteroid at x" + (bv3.x) + " z" + (bv3.z));
}
((WorldProviderAsteroids) world.provider).removeAsteroid(bv3.x, bv3.y, bv3.z);
}
attemptCount++;
} while (attemptCount < 5);
FMLLog.info("Failed to find good large asteroid landing spot! Falling back to making a small one.");
this.makeSmallLandingSpot(world, x, z);
return new Vector3(x, 310, z);
}
FMLLog.severe("Null player when teleporting to Asteroids!");
return new Vector3(0, 310, 0);
}
use of micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids in project Galacticraft by micdoodle8.
the class EntityAstroMiner method readEntityFromNBT.
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
final NBTTagList var2 = nbt.getTagList("Items", 10);
this.cargoItems = new ItemStack[this.INV_SIZE];
int itemCount = 0;
if (var2 != null) {
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
final NBTTagCompound var4 = var2.getCompoundTagAt(var3);
final int var5 = var4.getByte("Slot") & 255;
if (var5 < this.cargoItems.length) {
ItemStack read = ItemStack.loadItemStackFromNBT(var4);
if (read != null) {
this.cargoItems[var5] = read;
itemCount += read.stackSize;
}
}
}
}
this.mineCount = itemCount;
if (nbt.hasKey("sindex")) {
this.serverIndex = nbt.getInteger("sindex");
} else {
this.serverIndex = -1;
}
if (nbt.hasKey("Energy")) {
this.energyLevel = nbt.getInteger("Energy");
}
if (nbt.hasKey("BaseX")) {
this.posBase = new BlockVec3(nbt.getInteger("BaseX"), nbt.getInteger("BaseY"), nbt.getInteger("BaseZ"));
this.flagLink = true;
}
if (nbt.hasKey("TargetX")) {
this.posTarget = new BlockVec3(nbt.getInteger("TargetX"), nbt.getInteger("TargetY"), nbt.getInteger("TargetZ"));
}
if (nbt.hasKey("WBaseX")) {
this.waypointBase = new BlockVec3(nbt.getInteger("WBaseX"), nbt.getInteger("WBaseY"), nbt.getInteger("WBaseZ"));
}
if (nbt.hasKey("BaseFacing")) {
this.baseFacing = EnumFacing.getFront(nbt.getInteger("BaseFacing"));
}
if (nbt.hasKey("AIState")) {
this.AIstate = nbt.getInteger("AIState");
}
if (nbt.hasKey("Facing")) {
this.facingAI = EnumFacing.getFront(nbt.getInteger("Facing"));
switch(this.facingAI) {
case NORTH:
this.targetYaw = 180;
break;
case SOUTH:
this.targetYaw = 0;
break;
case WEST:
this.targetYaw = 270;
break;
case EAST:
this.targetYaw = 90;
break;
}
}
this.lastFacing = null;
if (nbt.hasKey("WayPoints")) {
this.wayPoints.clear();
final NBTTagList wpList = nbt.getTagList("WayPoints", 10);
for (int j = 0; j < wpList.tagCount(); j++) {
NBTTagCompound bvTag = wpList.getCompoundTagAt(j);
this.wayPoints.add(BlockVec3.readFromNBT(bvTag));
}
}
if (nbt.hasKey("MinePoints")) {
this.minePoints.clear();
final NBTTagList mpList = nbt.getTagList("MinePoints", 10);
for (int j = 0; j < mpList.tagCount(); j++) {
NBTTagCompound bvTag = mpList.getCompoundTagAt(j);
this.minePoints.add(BlockVec3.readFromNBT(bvTag));
}
}
if (nbt.hasKey("MinePointCurrent")) {
this.minePointCurrent = BlockVec3.readFromNBT(nbt.getCompoundTag("MinePointCurrent"));
} else {
this.minePointCurrent = null;
}
if (nbt.hasKey("playerUUIDMost", 4) && nbt.hasKey("playerUUIDLeast", 4)) {
this.playerUUID = new UUID(nbt.getLong("playerUUIDMost"), nbt.getLong("playerUUIDLeast"));
} else {
this.playerUUID = null;
}
if (nbt.hasKey("speedup")) {
this.speedup = nbt.getDouble("speedup");
} else {
this.speedup = (WorldUtil.getProviderForDimensionServer(this.dimension) instanceof WorldProviderAsteroids) ? SPEEDUP * 1.6D : SPEEDUP;
}
this.pathBlockedCount = nbt.getInteger("pathBlockedCount");
this.spawnedInCreative = nbt.getBoolean("spawnedInCreative");
this.flagCheckPlayer = true;
}
use of micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids in project Galacticraft by micdoodle8.
the class ChunkProviderAsteroids method generateAsteroid.
private void generateAsteroid(Random rand, int asteroidX, int asteroidY, int asteroidZ, int chunkX, int chunkZ, int size, ChunkPrimer primer, boolean flagDataOnly) {
SpecialAsteroidBlock core = this.coreHandler.getBlock(rand, size);
SpecialAsteroidBlock shell = null;
if (rand.nextInt(ChunkProviderAsteroids.ASTEROID_SHELL_CHANCE) == 0) {
shell = this.shellHandler.getBlock(rand, size);
}
boolean isHollow = false;
final float hollowSize = rand.nextFloat() * (ChunkProviderAsteroids.MAX_HOLLOW_SIZE - ChunkProviderAsteroids.MIN_HOLLOW_SIZE) + ChunkProviderAsteroids.MIN_HOLLOW_SIZE;
if (rand.nextInt(ChunkProviderAsteroids.HOLLOW_CHANCE) == 0 && size >= ChunkProviderAsteroids.MIN_RADIUS_FOR_HOLLOW) {
isHollow = true;
shell = new SpecialAsteroidBlock(AsteroidBlocks.blockDenseIce, (byte) 0, 1, .15);
}
// Add to the list of asteroids for external use
((WorldProviderAsteroids) this.worldObj.provider).addAsteroid(asteroidX, asteroidY, asteroidZ, size, isHollow ? -1 : core.index);
final int xMin = this.clamp(Math.max(chunkX, asteroidX - size - ChunkProviderAsteroids.MAX_ASTEROID_SKEW - 2) - chunkX, 0, 16);
final int zMin = this.clamp(Math.max(chunkZ, asteroidZ - size - ChunkProviderAsteroids.MAX_ASTEROID_SKEW - 2) - chunkZ, 0, 16);
final int yMin = asteroidY - size - ChunkProviderAsteroids.MAX_ASTEROID_SKEW - 2;
final int yMax = asteroidY + size + ChunkProviderAsteroids.MAX_ASTEROID_SKEW + 2;
final int xMax = this.clamp(Math.min(chunkX + 16, asteroidX + size + ChunkProviderAsteroids.MAX_ASTEROID_SKEW + 2) - chunkX, 0, 16);
final int zMax = this.clamp(Math.min(chunkZ + 16, asteroidZ + size + ChunkProviderAsteroids.MAX_ASTEROID_SKEW + 2) - chunkZ, 0, 16);
final int xSize = xMax - xMin;
final int ySize = yMax - yMin;
final int zSize = zMax - zMin;
if (xSize <= 0 || ySize <= 0 || zSize <= 0) {
return;
}
final float noiseOffsetX = this.randFromPoint(asteroidX, asteroidY, asteroidZ) * ChunkProviderAsteroids.NOISE_OFFSET_SIZE + chunkX;
final float noiseOffsetY = this.randFromPoint(asteroidX * 7, asteroidY * 11, asteroidZ * 13) * ChunkProviderAsteroids.NOISE_OFFSET_SIZE;
final float noiseOffsetZ = this.randFromPoint(asteroidX * 17, asteroidY * 23, asteroidZ * 29) * ChunkProviderAsteroids.NOISE_OFFSET_SIZE + chunkZ;
this.setOtherAxisFrequency(1F / (size * 2F / 2F));
float[] sizeXArray = new float[ySize * zSize];
float[] sizeZArray = new float[xSize * ySize];
float[] sizeYArray = new float[xSize * zSize];
for (int x = 0; x < xSize; x++) {
int xx = x * zSize;
float xxx = x + noiseOffsetX;
for (int z = 0; z < zSize; z++) {
sizeYArray[xx + z] = this.asteroidSkewY.getNoise(xxx, z + noiseOffsetZ);
}
}
AsteroidData asteroidData = new AsteroidData(isHollow, sizeYArray, xMin, zMin, xMax, zMax, zSize, size, asteroidX, asteroidY, asteroidZ);
this.largeAsteroids.add(asteroidData);
this.largeAsteroidsLastChunkX = chunkX;
this.largeAsteroidsLastChunkZ = chunkZ;
if (flagDataOnly) {
return;
}
for (int y = 0; y < ySize; y++) {
int yy = y * zSize;
float yyy = y + noiseOffsetY;
for (int z = 0; z < zSize; z++) {
sizeXArray[yy + z] = this.asteroidSkewX.getNoise(yyy, z + noiseOffsetZ);
}
}
for (int x = 0; x < xSize; x++) {
int xx = x * ySize;
float xxx = x + noiseOffsetX;
for (int y = 0; y < ySize; y++) {
sizeZArray[xx + y] = this.asteroidSkewZ.getNoise(xxx, y + noiseOffsetY);
}
}
double shellThickness = 0;
int terrainY = 0;
int terrainYY = 0;
IBlockState asteroidShell = null;
if (shell != null) {
asteroidShell = shell.block.getStateFromMeta(shell.meta);
shellThickness = 1.0 - shell.thickness;
}
IBlockState asteroidCore = core.block.getStateFromMeta(core.meta);
IBlockState asteroidRock0 = this.ASTEROID_STONE.getStateFromMeta(this.ASTEROID_STONE_META_0);
IBlockState asteroidRock1 = this.ASTEROID_STONE.getStateFromMeta(this.ASTEROID_STONE_META_1);
IBlockState airBlock = Blocks.air.getDefaultState();
IBlockState dirtBlock = this.DIRT.getStateFromMeta(this.DIRT_META);
IBlockState grassBlock = this.GRASS.getStateFromMeta(this.GRASS_META);
for (int x = xMax - 1; x >= xMin; x--) {
int indexXY = (x - xMin) * ySize - yMin;
int indexXZ = (x - xMin) * zSize - zMin;
int distanceX = asteroidX - (x + chunkX);
int indexBaseX = x * ChunkProviderAsteroids.CHUNK_SIZE_Y << 4;
float xx = x + chunkX;
for (int z = zMin; z < zMax; z++) {
if (isHollow) {
float sizeModY = sizeYArray[indexXZ + z];
terrainY = this.getTerrainHeightFor(sizeModY, asteroidY, size);
terrainYY = this.getTerrainHeightFor(sizeModY, asteroidY - 1, size);
}
float sizeY = size + sizeYArray[indexXZ + z];
sizeY *= sizeY;
int distanceZ = asteroidZ - (z + chunkZ);
int indexBase = indexBaseX | z * ChunkProviderAsteroids.CHUNK_SIZE_Y;
float zz = z + chunkZ;
for (int y = yMin; y < yMax; y++) {
float dSizeX = distanceX / (size + sizeXArray[(y - yMin) * zSize + z - zMin]);
float dSizeZ = distanceZ / (size + sizeZArray[indexXY + y]);
dSizeX *= dSizeX;
dSizeZ *= dSizeZ;
int distanceY = asteroidY - y;
distanceY *= distanceY;
float distance = dSizeX + distanceY / sizeY + dSizeZ;
float distanceAbove = distance;
distance += this.asteroidTurbulance.getNoise(xx, y, zz);
if (isHollow && distance <= hollowSize) {
distanceAbove += this.asteroidTurbulance.getNoise(xx, y + 1, zz);
if (distanceAbove <= 1) {
if ((y - 1) == terrainYY) {
int index = indexBase | (y + 1);
primer.setBlockState(index, this.LIGHT.getStateFromMeta(this.LIGHT_META));
// blockArray[index] = this.LIGHT;
// metaArray[index] = this.LIGHT_META;
}
}
}
if (distance <= 1) {
int index = indexBase | y;
if (isHollow && distance <= hollowSize) {
if (y == terrainY) {
primer.setBlockState(index, grassBlock);
// blockArray[index] = this.GRASS;
// metaArray[index] = this.GRASS_META;
} else if (y < terrainY) {
primer.setBlockState(index, dirtBlock);
// blockArray[index] = this.DIRT;
// metaArray[index] = this.DIRT_META;
} else {
primer.setBlockState(index, airBlock);
// blockArray[index] = Blocks.air;
// metaArray[index] = 0;
}
} else if (distance <= core.thickness) {
if (rand.nextBoolean()) {
primer.setBlockState(index, asteroidCore);
// blockArray[index] = core.block;
// metaArray[index] = core.meta;
} else {
primer.setBlockState(index, asteroidRock0);
// blockArray[index] = this.ASTEROID_STONE;
// metaArray[index] = this.ASTEROID_STONE_META_0;
}
} else if (shell != null && distance >= shellThickness) {
primer.setBlockState(index, asteroidShell);
// blockArray[index] = shell.block;
// metaArray[index] = shell.meta;
} else {
primer.setBlockState(index, asteroidRock1);
// blockArray[index] = this.ASTEROID_STONE;
// metaArray[index] = this.ASTEROID_STONE_META_1;
}
}
}
}
}
if (isHollow) {
shellThickness = 0;
if (shell != null) {
shellThickness = 1.0 - shell.thickness;
}
for (int x = xMin; x < xMax; x++) {
int indexXY = (x - xMin) * ySize - yMin;
int indexXZ = (x - xMin) * zSize - zMin;
int distanceX = asteroidX - (x + chunkX);
distanceX *= distanceX;
int indexBaseX = x * ChunkProviderAsteroids.CHUNK_SIZE_Y << 4;
for (int z = zMin; z < zMax; z++) {
float sizeModY = sizeYArray[indexXZ + z];
float sizeY = size + sizeYArray[indexXZ + z];
sizeY *= sizeY;
int distanceZ = asteroidZ - (z + chunkZ);
distanceZ *= distanceZ;
int indexBase = indexBaseX | z * ChunkProviderAsteroids.CHUNK_SIZE_Y;
for (int y = yMin; y < yMax; y++) {
float sizeX = size + sizeXArray[(y - yMin) * zSize + z - zMin];
float sizeZ = size + sizeZArray[indexXY + y];
sizeX *= sizeX;
sizeZ *= sizeZ;
int distanceY = asteroidY - y;
distanceY *= distanceY;
float distance = distanceX / sizeX + distanceY / sizeY + distanceZ / sizeZ;
distance += this.asteroidTurbulance.getNoise(x + chunkX, y, z + chunkZ);
if (distance <= 1) {
int index = indexBase | y;
int indexAbove = indexBase | (y + 1);
IBlockState state = primer.getBlockState(index);
IBlockState stateAbove = primer.getBlockState(indexAbove);
if (Blocks.air == stateAbove.getBlock() && (state.getBlock() == ASTEROID_STONE || state.getBlock() == GRASS)) {
if (this.rand.nextInt(GLOWSTONE_CHANCE) == 0) {
primer.setBlockState(index, this.LIGHT.getStateFromMeta(this.LIGHT_META));
// blockArray[index] = this.LIGHT;
// metaArray[index] = this.LIGHT_META;
}
}
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids in project Galacticraft by micdoodle8.
the class ChunkProviderAsteroids method provideChunk.
@Override
public Chunk provideChunk(int par1, int par2) {
ChunkPrimer primer = new ChunkPrimer();
// long time1 = System.nanoTime();
this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);
// final Block[] ids = new Block[65536];
// final byte[] meta = new byte[65536];
this.generateTerrain(par1, par2, primer, false);
if (this.worldObj.provider instanceof WorldProviderAsteroids && ((WorldProviderAsteroids) this.worldObj.provider).checkHasAsteroids()) {
this.dungeonGenerator.generate(this, this.worldObj, par1, par2, primer);
}
// long time2 = System.nanoTime();
final Chunk var4 = new Chunk(this.worldObj, primer, par1, par2);
final byte[] var5 = var4.getBiomeArray();
for (int var6 = 0; var6 < var5.length; ++var6) {
var5[var6] = (byte) BiomeGenBaseAsteroids.asteroid.biomeID;
}
// long time3 = System.nanoTime();
this.generateSkylightMap(var4, par1, par2);
// }
return var4;
}
use of micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids in project Galacticraft by micdoodle8.
the class GCPlayerHandler method onPlayerUpdate.
public void onPlayerUpdate(EntityPlayerMP player) {
int tick = player.ticksExisted - 1;
// This will speed things up a little
GCPlayerStats stats = GCPlayerStats.get(player);
if ((ConfigManagerCore.challengeSpawnHandling) && stats.getUnlockedSchematics().size() == 0) {
if (stats.getStartDimension().length() > 0) {
stats.setStartDimension("");
} else {
// PlayerAPI is installed
WorldServer worldOld = (WorldServer) player.worldObj;
try {
worldOld.getPlayerManager().removePlayer(player);
} catch (Exception e) {
}
worldOld.playerEntities.remove(player);
worldOld.updateAllPlayersSleepingFlag();
worldOld.loadedEntityList.remove(player);
worldOld.onEntityRemoved(player);
worldOld.getEntityTracker().untrackEntity(player);
if (player.addedToChunk && worldOld.getChunkProvider().chunkExists(player.chunkCoordX, player.chunkCoordZ)) {
Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
chunkOld.removeEntity(player);
chunkOld.setChunkModified();
}
WorldServer worldNew = WorldUtil.getStartWorld(worldOld);
int dimID = GCCoreUtil.getDimensionID(worldNew);
player.dimension = dimID;
GCLog.debug("DEBUG: Sending respawn packet to player for dim " + dimID);
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(dimID, player.worldObj.getDifficulty(), player.worldObj.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
if (worldNew.provider instanceof WorldProviderSpaceStation) {
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}), player);
}
worldNew.spawnEntityInWorld(player);
player.setWorld(worldNew);
player.mcServer.getConfigurationManager().preparePlayer(player, (WorldServer) worldOld);
}
// This is a mini version of the code at WorldUtil.teleportEntity
player.theItemInWorldManager.setWorld((WorldServer) player.worldObj);
final ITeleportType type = GalacticraftRegistry.getTeleportTypeForDimension(player.worldObj.provider.getClass());
Vector3 spawnPos = type.getPlayerSpawnLocation((WorldServer) player.worldObj, player);
ChunkCoordIntPair pair = player.worldObj.getChunkFromChunkCoords(spawnPos.intX() >> 4, spawnPos.intZ() >> 4).getChunkCoordIntPair();
GCLog.debug("Loading first chunk in new dimension.");
((WorldServer) player.worldObj).theChunkProviderServer.loadChunk(pair.chunkXPos, pair.chunkZPos);
player.setLocationAndAngles(spawnPos.x, spawnPos.y, spawnPos.z, player.rotationYaw, player.rotationPitch);
type.setupAdventureSpawn(player);
type.onSpaceDimensionChanged(player.worldObj, player, false);
player.setSpawnChunk(new BlockPos(spawnPos.intX(), spawnPos.intY(), spawnPos.intZ()), true, GCCoreUtil.getDimensionID(player.worldObj));
stats.setNewAdventureSpawn(true);
}
final boolean isInGCDimension = player.worldObj.provider instanceof IGalacticraftWorldProvider;
if (tick >= 25) {
if (ConfigManagerCore.enableSpaceRaceManagerPopup && !stats.hasOpenedSpaceRaceManager()) {
SpaceRace race = SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(player));
if (race == null || race.teamName.equals(SpaceRace.DEFAULT_NAME)) {
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_OPEN_SPACE_RACE_GUI, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}), player);
}
stats.setOpenedSpaceRaceManager(true);
}
if (!stats.hasSentFlags()) {
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_STATS, GCCoreUtil.getDimensionID(player.worldObj), stats.getMiscNetworkedStats()), player);
stats.setSentFlags(true);
}
}
if (stats.getCryogenicChamberCooldown() > 0) {
stats.setCryogenicChamberCooldown(stats.getCryogenicChamberCooldown() - 1);
}
if (!player.onGround && stats.isLastOnGround()) {
stats.setTouchedGround(true);
}
if (stats.getTeleportCooldown() > 0) {
stats.setTeleportCooldown(stats.getTeleportCooldown() - 1);
}
if (stats.getChatCooldown() > 0) {
stats.setChatCooldown(stats.getChatCooldown() - 1);
}
if (stats.getOpenPlanetSelectionGuiCooldown() > 0) {
stats.setOpenPlanetSelectionGuiCooldown(stats.getOpenPlanetSelectionGuiCooldown() - 1);
if (stats.getOpenPlanetSelectionGuiCooldown() == 1 && !stats.hasOpenedPlanetSelectionGui()) {
WorldUtil.toCelestialSelection(player, stats, stats.getSpaceshipTier());
stats.setHasOpenedPlanetSelectionGui(true);
}
}
if (stats.isUsingParachute()) {
if (stats.getLastParachuteInSlot() != null) {
player.fallDistance = 0.0F;
}
if (player.onGround) {
GCPlayerHandler.setUsingParachute(player, stats, false);
}
}
this.checkCurrentItem(player);
if (stats.isUsingPlanetSelectionGui()) {
// This sends the planets list again periodically (forcing the Celestial Selection screen to open) in case of server/client lag
// #PACKETSPAM
this.sendPlanetList(player, stats);
}
/* if (isInGCDimension || player.usingPlanetSelectionGui)
{
player.playerNetServerHandler.ticksForFloatKick = 0;
}
*/
if (stats.getDamageCounter() > 0) {
stats.setDamageCounter(stats.getDamageCounter() - 1);
}
if (isInGCDimension) {
if (tick % 10 == 0) {
boolean doneDungeon = false;
ItemStack current = player.inventory.getCurrentItem();
if (current != null && current.getItem() == GCItems.dungeonFinder) {
this.sendDungeonDirectionPacket(player, stats);
doneDungeon = true;
}
if (tick % 30 == 0) {
GCPlayerHandler.sendAirRemainingPacket(player, stats);
this.sendThermalLevelPacket(player, stats);
if (!doneDungeon) {
for (ItemStack stack : player.inventory.mainInventory) {
if (stack != null && stack.getItem() == GCItems.dungeonFinder) {
this.sendDungeonDirectionPacket(player, stats);
break;
}
}
}
}
}
if (player.ridingEntity instanceof EntityLanderBase) {
stats.setInLander(true);
stats.setJustLanded(false);
} else {
if (stats.isInLander()) {
stats.setJustLanded(true);
}
stats.setInLander(false);
}
if (player.onGround && stats.hasJustLanded()) {
stats.setJustLanded(false);
// Set spawn point here if just descended from a lander for the first time
if (player.getBedLocation(GCCoreUtil.getDimensionID(player.worldObj)) == null || stats.isNewAdventureSpawn()) {
int i = 30000000;
int j = Math.min(i, Math.max(-i, MathHelper.floor_double(player.posX + 0.5D)));
int k = Math.min(256, Math.max(0, MathHelper.floor_double(player.posY + 1.5D)));
int l = Math.min(i, Math.max(-i, MathHelper.floor_double(player.posZ + 0.5D)));
BlockPos coords = new BlockPos(j, k, l);
player.setSpawnChunk(coords, true, GCCoreUtil.getDimensionID(player.worldObj));
stats.setNewAdventureSpawn(false);
}
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}), player);
}
if (player.worldObj.provider instanceof WorldProviderSpaceStation || player.worldObj.provider instanceof IZeroGDimension || GalacticraftCore.isPlanetsLoaded && player.worldObj.provider instanceof WorldProviderAsteroids) {
this.preventFlyingKicks(player);
if (player.worldObj.provider instanceof WorldProviderSpaceStation && stats.isNewInOrbit()) {
((WorldProviderSpaceStation) player.worldObj.provider).getSpinManager().sendPackets(player);
stats.setNewInOrbit(false);
}
} else {
stats.setNewInOrbit(true);
}
} else {
stats.setNewInOrbit(true);
}
checkGear(player, stats, false);
if (stats.getChestSpawnCooldown() > 0) {
stats.setChestSpawnCooldown(stats.getChestSpawnCooldown() - 1);
if (stats.getChestSpawnCooldown() == 180) {
if (stats.getChestSpawnVector() != null) {
EntityParachest chest = new EntityParachest(player.worldObj, stats.getRocketStacks(), stats.getFuelLevel());
chest.setPosition(stats.getChestSpawnVector().x, stats.getChestSpawnVector().y, stats.getChestSpawnVector().z);
chest.color = stats.getParachuteInSlot() == null ? EnumDyeColor.WHITE : ItemParaChute.getDyeEnumFromParachuteDamage(stats.getParachuteInSlot().getItemDamage());
if (!player.worldObj.isRemote) {
player.worldObj.spawnEntityInWorld(chest);
}
}
}
}
if (stats.getLaunchAttempts() > 0 && player.ridingEntity == null) {
stats.setLaunchAttempts(0);
}
this.checkThermalStatus(player, stats);
this.checkOxygen(player, stats);
this.checkShield(player, stats);
if (isInGCDimension && (stats.isOxygenSetupValid() != stats.isLastOxygenSetupValid() || tick % 100 == 0)) {
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_OXYGEN_VALIDITY, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { stats.isOxygenSetupValid() }), player);
}
this.throwMeteors(player);
this.updateSchematics(player, stats);
if (tick % 250 == 0 && stats.getFrequencyModuleInSlot() == null && !stats.hasReceivedSoundWarning() && isInGCDimension && player.onGround && tick > 0 && ((IGalacticraftWorldProvider) player.worldObj.provider).getSoundVolReductionAmount() > 1.0F) {
String[] string2 = GCCoreUtil.translate("gui.frequencymodule.warning1").split(" ");
StringBuilder sb = new StringBuilder();
for (String aString2 : string2) {
sb.append(" ").append(EnumColor.YELLOW).append(aString2);
}
player.addChatMessage(new ChatComponentText(EnumColor.YELLOW + GCCoreUtil.translate("gui.frequencymodule.warning0") + " " + EnumColor.AQUA + GCItems.basicItem.getItemStackDisplayName(new ItemStack(GCItems.basicItem, 1, 19)) + sb.toString()));
stats.setReceivedSoundWarning(true);
}
// Player moves and sprints 18% faster with full set of Titanium Armor
if (GalacticraftCore.isPlanetsLoaded && tick % 40 == 1 && player.inventory != null) {
int titaniumCount = 0;
for (int i = 0; i < 4; i++) {
ItemStack armorPiece = player.getCurrentArmor(i);
if (armorPiece != null && armorPiece.getItem() instanceof ItemArmorAsteroids) {
titaniumCount++;
}
}
if (stats.getSavedSpeed() == 0F) {
if (titaniumCount == 4) {
float speed = player.capabilities.getWalkSpeed();
if (speed < 0.118F) {
try {
Field f = player.capabilities.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "walkSpeed" : "field_75097_g");
f.setAccessible(true);
f.set(player.capabilities, 0.118F);
stats.setSavedSpeed(speed);
} catch (Exception e) {
e.printStackTrace();
}
}
}
} else if (titaniumCount < 4) {
try {
Field f = player.capabilities.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "walkSpeed" : "field_75097_g");
f.setAccessible(true);
f.set(player.capabilities, stats.getSavedSpeed());
stats.setSavedSpeed(0F);
} catch (Exception e) {
e.printStackTrace();
}
}
}
stats.setLastOxygenSetupValid(stats.isOxygenSetupValid());
stats.setLastUnlockedSchematics(stats.getUnlockedSchematics());
stats.setLastOnGround(player.onGround);
}
Aggregations