use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension in project Galacticraft by micdoodle8.
the class TileEntityPlatform method updateClient.
@SideOnly(Side.CLIENT)
private void updateClient() {
this.lightOn = false;
if (this.colorTicks > 0) {
if (--this.colorTicks == 0) {
this.colorState = 0;
}
}
IBlockState b = this.worldObj.getBlockState(this.getPos());
if (b.getBlock() == GCBlocks.platform && b.getValue(BlockPlatform.CORNER) == BlockPlatform.EnumCorner.NW) {
// Scan area for player entities and light up
if (this.detection == null) {
this.detection = AxisAlignedBB.fromBounds(this.getPos().getX() + 0.9D, this.getPos().getY() + 0.75D, this.getPos().getZ() + 0.9D, this.getPos().getX() + 1.1D, this.getPos().getY() + 1.85D, this.getPos().getZ() + 1.1D);
}
final List<Entity> list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, detection);
if (list.size() > 0) {
// Light up the platform
this.lightOn = true;
// If this player is within the box
EntityPlayerSP p = FMLClientHandler.instance().getClientPlayerEntity();
GCPlayerStatsClient stats = GCPlayerStatsClient.get(p);
if (list.contains(p) && !stats.getPlatformControlled() && p.ridingEntity == null) {
// TODO: PlayerAPI version of this
if (p.movementInput.sneak) {
int canDescend = this.checkNextPlatform(-1);
if (canDescend == -1) {
this.colorState = 1;
this.colorTicks = 16;
} else if (canDescend > 0) {
TileEntity te = this.worldObj.getTileEntity(this.pos.down(canDescend));
if (te instanceof TileEntityPlatform) {
TileEntityPlatform tep = (TileEntityPlatform) te;
stats.startPlatformAscent(this, tep, this.pos.getY() - canDescend + (this.worldObj.provider instanceof IZeroGDimension ? 0.97D : (double) BlockPlatform.HEIGHT));
this.startMove(tep);
tep.startMove(this);
}
}
} else if (p.movementInput.jump) {
int canAscend = this.checkNextPlatform(1);
if (canAscend == -1) {
this.colorState = 1;
this.colorTicks = 16;
} else if (canAscend > 0) {
TileEntity te = this.worldObj.getTileEntity(this.pos.up(canAscend));
if (te instanceof TileEntityPlatform) {
p.motionY = 0D;
TileEntityPlatform tep = (TileEntityPlatform) te;
stats.startPlatformAscent(tep, this, this.pos.getY() + canAscend + BlockPlatform.HEIGHT);
this.startMove(tep);
tep.startMove(this);
}
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension in project Galacticraft by micdoodle8.
the class EntityGrapple method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
this.prevRotationRoll = this.rotationRoll;
if (!this.worldObj.isRemote) {
this.updateShootingEntity();
if (this.getPullingEntity()) {
EntityPlayer shootingEntity = this.getShootingEntity();
if (shootingEntity != null) {
double deltaPosition = this.getDistanceSqToEntity(shootingEntity);
Vector3 mot = new Vector3(shootingEntity.motionX, shootingEntity.motionY, shootingEntity.motionZ);
if (mot.getMagnitudeSquared() < 0.01 && this.pullingPlayer) {
if (deltaPosition < 10) {
this.onCollideWithPlayer(shootingEntity);
}
this.updatePullingEntity(false);
this.setDead();
}
this.pullingPlayer = true;
}
}
} else {
if (this.getPullingEntity()) {
EntityPlayer shootingEntity = this.getShootingEntity();
if (shootingEntity != null) {
shootingEntity.setVelocity((this.posX - shootingEntity.posX) / 12.0F, (this.posY - shootingEntity.posY) / 12.0F, (this.posZ - shootingEntity.posZ) / 12.0F);
if (shootingEntity.worldObj.isRemote && shootingEntity.worldObj.provider instanceof IZeroGDimension) {
GCPlayerStatsClient stats = GCPlayerStatsClient.get(shootingEntity);
if (stats != null) {
stats.getFreefallHandler().updateFreefall(shootingEntity);
}
}
}
}
}
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float) Math.atan2(this.motionX, this.motionZ) * Constants.RADIANS_TO_DEGREES;
this.prevRotationPitch = this.rotationPitch = (float) Math.atan2(this.motionY, f) * Constants.RADIANS_TO_DEGREES;
}
if (this.hitVec != null) {
Block block = this.worldObj.getBlockState(this.hitVec).getBlock();
if (block.getMaterial() != Material.air) {
block.setBlockBoundsBasedOnState(this.worldObj, this.hitVec);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(this.worldObj, this.hitVec, this.worldObj.getBlockState(this.hitVec));
if (axisalignedbb != null && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) {
this.inGround = true;
}
}
}
if (this.arrowShake > 0) {
--this.arrowShake;
}
if (this.inGround) {
if (this.hitVec != null) {
IBlockState state = this.worldObj.getBlockState(this.hitVec);
Block block = state.getBlock();
int j = block.getMetaFromState(state);
if (block == this.hitBlock && j == this.inData) {
if (this.shootingEntity != null) {
this.shootingEntity.motionX = (this.posX - this.shootingEntity.posX) / 16.0F;
this.shootingEntity.motionY = (this.posY - this.shootingEntity.posY) / 16.0F;
this.shootingEntity.motionZ = (this.posZ - this.shootingEntity.posZ) / 16.0F;
if (this.shootingEntity instanceof EntityPlayerMP)
GalacticraftCore.handler.preventFlyingKicks((EntityPlayerMP) this.shootingEntity);
}
if (!this.worldObj.isRemote && this.ticksInGround < 5) {
this.updatePullingEntity(true);
}
++this.ticksInGround;
if (this.ticksInGround == 1200) {
this.setDead();
}
} else {
this.inGround = false;
this.motionX *= this.rand.nextFloat() * 0.2F;
this.motionY *= this.rand.nextFloat() * 0.2F;
this.motionZ *= this.rand.nextFloat() * 0.2F;
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
} else {
this.rotationRoll += 5;
++this.ticksInAir;
if (!this.worldObj.isRemote) {
this.updatePullingEntity(false);
}
if (this.shootingEntity != null && this.getDistanceSqToEntity(this.shootingEntity) >= 40 * 40) {
this.setDead();
}
Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ);
Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false);
vec31 = new Vec3(this.posX, this.posY, this.posZ);
vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null) {
vec3 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i) {
Entity entity1 = (Entity) list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand(f1, f1, f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null) {
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity != null && !this.shootingEntity.canAttackPlayer(entityplayer)) {
movingobjectposition = null;
}
}
float motion;
if (movingobjectposition != null) {
if (movingobjectposition.entityHit == null) {
this.hitVec = movingobjectposition.getBlockPos();
IBlockState state = this.worldObj.getBlockState(this.hitVec);
this.hitBlock = state.getBlock();
this.inData = state.getBlock().getMetaFromState(state);
this.motionX = (float) (movingobjectposition.hitVec.xCoord - this.posX);
this.motionY = (float) (movingobjectposition.hitVec.yCoord - this.posY);
this.motionZ = (float) (movingobjectposition.hitVec.zCoord - this.posZ);
motion = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / motion * 0.05000000074505806D;
this.posY -= this.motionY / motion * 0.05000000074505806D;
this.posZ -= this.motionZ / motion * 0.05000000074505806D;
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
if (this.hitBlock.getMaterial() != Material.air) {
this.hitBlock.onEntityCollidedWithBlock(this.worldObj, this.hitVec, this);
}
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
motion = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) Math.atan2(this.motionX, this.motionZ) * Constants.RADIANS_TO_DEGREES;
this.rotationPitch = (float) Math.atan2(this.motionY, motion) * Constants.RADIANS_TO_DEGREES;
while (this.rotationPitch - this.prevRotationPitch < -180.0F) {
this.prevRotationPitch -= 360.0F;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.05F;
if (this.isInWater()) {
float f4 = 0.25F;
for (int l = 0; l < 4; ++l) {
this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ);
}
f3 = 0.8F;
}
if (this.isWet()) {
this.extinguish();
}
this.setPosition(this.posX, this.posY, this.posZ);
this.doBlockCollisions();
}
if (!this.worldObj.isRemote && (this.ticksInGround - 1) % 10 == 0) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimpleAsteroids(PacketSimpleAsteroids.EnumSimplePacketAsteroids.C_UPDATE_GRAPPLE_POS, GCCoreUtil.getDimensionID(this.worldObj), new Object[] { this.getEntityId(), new Vector3(this) }), new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(this.worldObj), this.posX, this.posY, this.posZ, 150));
}
}
use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension in project Galacticraft by micdoodle8.
the class TransformerHooks method orientCamera.
@SideOnly(Side.CLIENT)
public static void orientCamera(float partialTicks) {
EntityPlayerSP player = ClientProxyCore.mc.thePlayer;
GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
Entity viewEntity = ClientProxyCore.mc.getRenderViewEntity();
if (player.ridingEntity instanceof ICameraZoomEntity && ClientProxyCore.mc.gameSettings.thirdPersonView == 0) {
Entity entity = player.ridingEntity;
float offset = ((ICameraZoomEntity) entity).getRotateOffset();
if (offset > -10F) {
offset += PLAYER_Y_OFFSET;
GL11.glTranslatef(0, -offset, 0);
float anglePitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
float angleYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks;
GL11.glRotatef(-anglePitch, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(angleYaw, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0, offset, 0);
}
}
if (viewEntity instanceof EntityLivingBase && viewEntity.worldObj.provider instanceof IZeroGDimension && !((EntityLivingBase) viewEntity).isPlayerSleeping()) {
float pitch = viewEntity.prevRotationPitch + (viewEntity.rotationPitch - viewEntity.prevRotationPitch) * partialTicks;
float yaw = viewEntity.prevRotationYaw + (viewEntity.rotationYaw - viewEntity.prevRotationYaw) * partialTicks + 180.0F;
float eyeHeightChange = viewEntity.width / 2.0F;
// GL11.glTranslatef(0.0F, -f1, 0.0F);
GL11.glRotatef(-yaw, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-pitch, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.0F, 0.1F);
EnumGravity gDir = stats.getGdir();
GL11.glRotatef(180.0F * gDir.getThetaX(), 1.0F, 0.0F, 0.0F);
GL11.glRotatef(180.0F * gDir.getThetaZ(), 0.0F, 0.0F, 1.0F);
GL11.glRotatef(pitch * gDir.getPitchGravityX(), 1.0F, 0.0F, 0.0F);
GL11.glRotatef(pitch * gDir.getPitchGravityY(), 0.0F, 1.0F, 0.0F);
GL11.glRotatef(yaw * gDir.getYawGravityX(), 1.0F, 0.0F, 0.0F);
GL11.glRotatef(yaw * gDir.getYawGravityY(), 0.0F, 1.0F, 0.0F);
GL11.glRotatef(yaw * gDir.getYawGravityZ(), 0.0F, 0.0F, 1.0F);
// GL11.glTranslatef(sneakY * gDir.getSneakVecX(), sneakY * gDir.getSneakVecY(), sneakY * gDir.getSneakVecZ());
GL11.glTranslatef(eyeHeightChange * gDir.getEyeVecX(), eyeHeightChange * gDir.getEyeVecY(), eyeHeightChange * gDir.getEyeVecZ());
if (stats.getGravityTurnRate() < 1.0F) {
GL11.glRotatef(90.0F * (stats.getGravityTurnRatePrev() + (stats.getGravityTurnRate() - stats.getGravityTurnRatePrev()) * partialTicks), stats.getGravityTurnVecX(), stats.getGravityTurnVecY(), stats.getGravityTurnVecZ());
}
}
// omit this for interesting 3P views
// GL11.glTranslatef(0.0F, 0.0F, -0.1F);
// GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
// GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F);
// GL11.glTranslatef(0.0F, f1, 0.0F);
}
use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension in project Galacticraft by micdoodle8.
the class GuiTeleporting method updateScreen.
@Override
public void updateScreen() {
super.updateScreen();
if (mc.thePlayer != null && mc.thePlayer.worldObj != null) {
// Screen will exit when the player is in the target dimension and has started moving down
if (mc.thePlayer.worldObj.provider.getDimensionId() == this.targetDimensionID && (mc.thePlayer.worldObj.provider instanceof IZeroGDimension || (mc.thePlayer.posY - mc.thePlayer.lastTickPosY) < 0.0)) {
mc.displayGuiScreen(null);
TickHandlerClient.teleportingGui = null;
}
}
// The following code is copied from GuiDownloadTerrain:
++this.progress;
if (this.progress % 20 == 0) {
this.mc.thePlayer.sendQueue.addToSendQueue(new C00PacketKeepAlive());
}
}
use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension 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