use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class EntityTieredRocket method onReachAtmosphere.
@Override
public void onReachAtmosphere() {
// Launch controlled
if (this.destinationFrequency != -1) {
if (this.worldObj.isRemote) {
// stop the sounds on the client - but do not reset, the rocket may start again
this.stopRocketSound();
return;
}
this.setTarget(true, this.destinationFrequency);
if (this.targetVec != null) {
if (this.targetDimension != this.worldObj.provider.getDimensionId()) {
WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension);
if (targetDim != null && targetDim.worldObj instanceof WorldServer) {
boolean dimensionAllowed = this.targetDimension == ConfigManagerCore.idDimensionOverworld;
if (targetDim instanceof IGalacticraftWorldProvider) {
if (((IGalacticraftWorldProvider) targetDim).canSpaceshipTierPass(this.getRocketTier()))
dimensionAllowed = true;
else
dimensionAllowed = false;
} else // No rocket flight to non-Galacticraft dimensions other than the Overworld allowed unless config
if ((this.targetDimension > 1 || this.targetDimension < -1) && marsConfigAllDimsAllowed != null) {
try {
if (marsConfigAllDimsAllowed.getBoolean(null)) {
dimensionAllowed = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (dimensionAllowed) {
if (this.riddenByEntity != null) {
WorldUtil.transferEntityToDimension(this.riddenByEntity, this.targetDimension, (WorldServer) targetDim.worldObj, false, this);
} else {
Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, (WorldServer) targetDim.worldObj, false, null);
if (e instanceof EntityAutoRocket) {
e.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5f);
((EntityAutoRocket) e).setLaunchPhase(EnumLaunchPhase.LANDING);
((EntityAutoRocket) e).setWaitForPlayer(false);
} else {
GCLog.info("Error: failed to recreate the unmanned rocket in landing mode on target planet.");
e.setDead();
this.setDead();
}
}
return;
}
}
// No destination world found - in this situation continue into regular take-off (as if Not launch controlled)
} else {
// Same dimension controlled rocket flight
this.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
// Stop any lateral motion, otherwise it will update to an incorrect x,z position first tick after spawning above target
this.motionX = this.motionZ = 0.0D;
// Small upward motion initially, to keep clear of own flame trail from launch
this.motionY = 0.1D;
if (this.riddenByEntity != null) {
WorldUtil.forceMoveEntityToPos(this.riddenByEntity, (WorldServer) this.worldObj, new Vector3(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F), false);
this.setWaitForPlayer(true);
GCLog.debug("Rocket repositioned, waiting for player");
}
this.setLaunchPhase(EnumLaunchPhase.LANDING);
// Do not destroy the rocket, we still need it!
return;
}
} else {
// Launch controlled launch but no valid target frequency = rocket loss [INVESTIGATE]
GCLog.info("Error: the launch controlled rocket failed to find a valid landing spot when it reached space.");
this.fuelTank.drain(Integer.MAX_VALUE, true);
this.posY = Math.max(255, (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) - 200);
return;
}
}
// Not launch controlled
if (!this.worldObj.isRemote) {
if (this.riddenByEntity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) this.riddenByEntity;
this.onTeleport(player);
GCPlayerStats stats = GCPlayerStats.get(player);
WorldUtil.toCelestialSelection(player, stats, this.getRocketTier());
}
// Destroy any rocket which reached the top of the atmosphere and is not controlled by a Launch Controller
this.setDead();
}
// Client side, non-launch controlled, do nothing - no reason why it can't continue flying until the GUICelestialSelection activates
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class ModelBipedGC method setRotationAngles.
public static void setRotationAngles(ModelBiped biped, float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
if (!(par7Entity instanceof EntityPlayer))
return;
final EntityPlayer player = (EntityPlayer) par7Entity;
final ItemStack currentItemStack = player.inventory.getCurrentItem();
final float floatPI = 3.1415927F;
if (!par7Entity.onGround && par7Entity.worldObj.provider instanceof IGalacticraftWorldProvider && par7Entity.ridingEntity == null && !(currentItemStack != null && currentItemStack.getItem() instanceof IHoldableItem)) {
float speedModifier = 0.1162F * 2;
float angularSwingArm = MathHelper.cos(par1 * (speedModifier / 2));
float rightMod = biped.heldItemRight != 0 ? 1 : 2;
biped.bipedRightArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * rightMod * par2 * 0.5F;
biped.bipedLeftArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
biped.bipedRightArm.rotateAngleX += -angularSwingArm * 4.0F * par2 * 0.5F;
biped.bipedLeftArm.rotateAngleX += angularSwingArm * 4.0F * par2 * 0.5F;
biped.bipedLeftLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * 1.4F * par2;
biped.bipedLeftLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2 + floatPI) * 1.4F * par2;
biped.bipedRightLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
biped.bipedRightLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2) * 1.4F * par2;
}
PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
if (gearData != null) {
if (gearData.getParachute() != null) {
// Parachute is equipped
biped.bipedLeftArm.rotateAngleX += floatPI;
biped.bipedLeftArm.rotateAngleZ += floatPI / 10;
biped.bipedRightArm.rotateAngleX += floatPI;
biped.bipedRightArm.rotateAngleZ -= floatPI / 10;
}
}
if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(player.ridingEntity instanceof ICameraZoomEntity)) {
Item heldItem = player.inventory.getCurrentItem().getItem();
IHoldableItem holdableItem = (IHoldableItem) heldItem;
IHoldableItemCustom holdableItemCustom = heldItem instanceof IHoldableItemCustom ? (IHoldableItemCustom) heldItem : null;
if (holdableItem.shouldHoldLeftHandUp(player)) {
Vector3 angle = null;
if (holdableItemCustom != null) {
angle = holdableItemCustom.getLeftHandRotation(player);
}
if (angle == null) {
angle = new Vector3(floatPI + 0.3F, 0.0F, floatPI / 10.0F);
}
biped.bipedLeftArm.rotateAngleX = angle.floatX();
biped.bipedLeftArm.rotateAngleY = angle.floatY();
biped.bipedLeftArm.rotateAngleZ = angle.floatZ();
}
if (holdableItem.shouldHoldRightHandUp(player)) {
Vector3 angle = null;
if (holdableItemCustom != null) {
angle = holdableItemCustom.getRightHandRotation(player);
}
if (angle == null) {
angle = new Vector3(floatPI + 0.3F, 0.0F, (float) -Math.PI / 10.0F);
}
biped.bipedRightArm.rotateAngleX = angle.floatX();
biped.bipedRightArm.rotateAngleY = angle.floatY();
biped.bipedRightArm.rotateAngleZ = angle.floatZ();
}
}
final List<?> l = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.fromBounds(player.posX - 20, 0, player.posZ - 20, player.posX + 20, 200, player.posZ + 20));
for (int i = 0; i < l.size(); i++) {
final Entity e = (Entity) l.get(i);
if (e instanceof EntityTieredRocket) {
final EntityTieredRocket ship = (EntityTieredRocket) e;
if (ship.riddenByEntity != null && !(ship.riddenByEntity).equals(player) && (ship.getLaunched() || ship.timeUntilLaunch < 390)) {
biped.bipedRightArm.rotateAngleZ -= floatPI / 8F + MathHelper.sin(par3 * 0.9F) * 0.2F;
biped.bipedRightArm.rotateAngleX = floatPI;
break;
}
}
}
if (player.isPlayerSleeping() && GalacticraftCore.isPlanetsLoaded) {
RenderPlayerGC.RotatePlayerEvent event = new RenderPlayerGC.RotatePlayerEvent((AbstractClientPlayer) player);
MinecraftForge.EVENT_BUS.post(event);
if (event.vanillaOverride && (event.shouldRotate == null || event.shouldRotate)) {
biped.bipedHead.rotateAngleX = (float) (20.0F - Math.sin(player.ticksExisted / 10.0F) / 7.0F);
biped.bipedHead.rotateAngleY = 0.0F;
biped.bipedHead.rotateAngleZ = 0.0F;
biped.bipedLeftArm.rotateAngleX = 0.0F;
biped.bipedLeftArm.rotateAngleY = 0.0F;
biped.bipedLeftArm.rotateAngleZ = 0.0F;
biped.bipedRightArm.rotateAngleX = 0.0F;
biped.bipedRightArm.rotateAngleY = 0.0F;
biped.bipedRightArm.rotateAngleZ = 0.0F;
}
}
if (biped instanceof ModelPlayer) {
ModelBiped.copyModelAngles(biped.bipedHead, ((ModelPlayer) biped).bipedHeadwear);
}
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class ModelFlag method renderFlag.
public void renderFlag(EntityFlag entity, float ticks) {
if (entity.flagData != null) {
GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(0.0F, -1.1F, 0.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_CULL_FACE);
float windLevel = 1.0F;
if (entity.worldObj.provider instanceof IGalacticraftWorldProvider) {
windLevel = ((IGalacticraftWorldProvider) entity.worldObj.provider).getWindLevel();
}
for (int i = 0; i < entity.flagData.getWidth(); i++) {
for (int j = 0; j < entity.flagData.getHeight(); j++) {
GL11.glPushMatrix();
GL11.glTranslatef(0, -1.0F, 0);
float offset = 0.0F;
float offsetAhead = 0.0F;
if (windLevel > 0) {
offset = (float) (Math.sin(ticks / 2.0F + i * 50 + 3) / 25.0F) * i / 30.0F;
offsetAhead = (float) (Math.sin(ticks / 2.0F + (i + 1) * 50 + 3) / 25.0F) * (i + 1) / 30.0F;
offset *= windLevel;
offsetAhead *= windLevel;
}
Vector3 col = entity.flagData.getColorAt(i, j);
GL11.glColor3f(col.floatX(), col.floatY(), col.floatZ());
Tessellator tess = Tessellator.getInstance();
WorldRenderer worldRenderer = tess.getWorldRenderer();
worldRenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION);
worldRenderer.pos(i / 24.0F + 0.0 / 24.0F, j / 24.0F + 0.0 / 24.0F + offset, offset).endVertex();
worldRenderer.pos(i / 24.0F + 0.0 / 24.0F, j / 24.0F + 1.0 / 24.0F + offset, offset).endVertex();
worldRenderer.pos(i / 24.0F + 1.0 / 24.0F, j / 24.0F + 1.0 / 24.0F + offsetAhead, offsetAhead).endVertex();
worldRenderer.pos(i / 24.0F + 0.0 / 24.0F, j / 24.0F + 0.0 / 24.0F + offset, offset).endVertex();
worldRenderer.pos(i / 24.0F + 1.0 / 24.0F, j / 24.0F + 1.0 / 24.0F + offsetAhead, offsetAhead).endVertex();
worldRenderer.pos(i / 24.0F + 1.0 / 24.0F, j / 24.0F + 0.0 / 24.0F + offsetAhead, offsetAhead).endVertex();
tess.draw();
GL11.glColor3f(1, 1, 1);
GL11.glPopMatrix();
}
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
}
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 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);
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class GCPlayerHandler method updateFeet.
protected static void updateFeet(EntityPlayerMP player, double motionX, double motionZ) {
double motionSqrd = motionX * motionX + motionZ * motionZ;
if (motionSqrd > 0.001D && !player.capabilities.isFlying) {
int iPosX = MathHelper.floor_double(player.posX);
int iPosY = MathHelper.floor_double(player.posY - 0.05);
int iPosZ = MathHelper.floor_double(player.posZ);
// If the block below is the moon block
IBlockState state = player.worldObj.getBlockState(new BlockPos(iPosX, iPosY, iPosZ));
if (state.getBlock() == GCBlocks.blockMoon) {
// And is the correct metadata (moon turf)
if (state.getValue(BlockBasicMoon.BASIC_TYPE_MOON) == BlockBasicMoon.EnumBlockBasicMoon.MOON_TURF) {
GCPlayerStats stats = GCPlayerStats.get(player);
// If it has been long enough since the last step
if (stats.getDistanceSinceLastStep() > 0.35D) {
Vector3 pos = new Vector3(player);
// Set the footprint position to the block below and add random number to stop z-fighting
pos.y = MathHelper.floor_double(player.posY - 1D) + player.worldObj.rand.nextFloat() / 100.0F;
// Adjust footprint to left or right depending on step count
switch(stats.getLastStep()) {
case 0:
float a = (-player.rotationYaw + 90F) / Constants.RADIANS_TO_DEGREES;
pos.translate(new Vector3(MathHelper.sin(a) * 0.25F, 0, MathHelper.cos(a) * 0.25F));
break;
case 1:
a = (-player.rotationYaw - 90F) / Constants.RADIANS_TO_DEGREES;
pos.translate(new Vector3(MathHelper.sin(a) * 0.25, 0, MathHelper.cos(a) * 0.25));
break;
}
float rotation = player.rotationYaw - 180;
pos = WorldUtil.getFootprintPosition(player.worldObj, rotation, pos, new BlockVec3(player));
long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
TickHandlerServer.addFootprint(chunkKey, new Footprint(GCCoreUtil.getDimensionID(player.worldObj), pos, rotation, player.getName()), GCCoreUtil.getDimensionID(player.worldObj));
// Increment and cap step counter at 1
stats.setLastStep((stats.getLastStep() + 1) % 2);
stats.setDistanceSinceLastStep(0);
} else {
stats.setDistanceSinceLastStep(stats.getDistanceSinceLastStep() + motionSqrd);
}
}
}
}
}
Aggregations