use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.
the class EventHandlerGC method getNextSchematic.
@SideOnly(Side.CLIENT)
private static ISchematicPage getNextSchematic(int currentIndex) {
EntityPlayerSP player = PlayerUtil.getPlayerBaseClientFromPlayer(FMLClientHandler.instance().getClient().thePlayer, false);
GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
final int size = stats.getUnlockedSchematics().size();
final HashMap<Integer, Integer> idList = new HashMap<Integer, Integer>(size, 1F);
for (int i = 0; i < size; i++) {
idList.put(i, stats.getUnlockedSchematics().get(i).getPageID());
}
final SortedSet<Integer> keys = new TreeSet<Integer>(idList.keySet());
final Iterator<Integer> iterator = keys.iterator();
for (int count = 0; count < keys.size(); count++) {
final int i = iterator.next();
final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID(idList.get(i));
if (page.getPageID() == currentIndex) {
if (count + 1 < stats.getUnlockedSchematics().size()) {
return stats.getUnlockedSchematics().get(count + 1);
} else {
return null;
}
}
}
return null;
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.
the class KeyHandlerClient method keyDown.
@Override
public void keyDown(Type types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
if (KeyHandlerClient.mc.thePlayer != null && tickEnd) {
EntityPlayerSP playerBase = PlayerUtil.getPlayerBaseClientFromPlayer(KeyHandlerClient.mc.thePlayer, false);
if (playerBase == null) {
return;
}
GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerBase);
if (kb.getKeyCode() == KeyHandlerClient.galaxyMap.getKeyCode()) {
if (KeyHandlerClient.mc.currentScreen == null) {
KeyHandlerClient.mc.thePlayer.openGui(GalacticraftCore.instance, GuiIdsCore.GALAXY_MAP, KeyHandlerClient.mc.theWorld, (int) KeyHandlerClient.mc.thePlayer.posX, (int) KeyHandlerClient.mc.thePlayer.posY, (int) KeyHandlerClient.mc.thePlayer.posZ);
}
} else if (kb.getKeyCode() == KeyHandlerClient.openFuelGui.getKeyCode()) {
if (playerBase.ridingEntity instanceof EntitySpaceshipBase || playerBase.ridingEntity instanceof EntityBuggy) {
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_OPEN_FUEL_GUI, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] { PlayerUtil.getName(playerBase) }));
}
} else if (kb.getKeyCode() == KeyHandlerClient.toggleAdvGoggles.getKeyCode()) {
if (playerBase != null) {
stats.setUsingAdvancedGoggles(!stats.isUsingAdvancedGoggles());
}
}
}
if (KeyHandlerClient.mc.thePlayer != null && KeyHandlerClient.mc.currentScreen == null) {
int keyNum = -1;
if (kb == KeyHandlerClient.accelerateKey) {
keyNum = 0;
} else if (kb == KeyHandlerClient.decelerateKey) {
keyNum = 1;
} else if (kb == KeyHandlerClient.leftKey) {
keyNum = 2;
} else if (kb == KeyHandlerClient.rightKey) {
keyNum = 3;
} else if (kb == KeyHandlerClient.spaceKey) {
keyNum = 4;
} else if (kb == KeyHandlerClient.leftShiftKey) {
keyNum = 5;
}
Entity entityTest = KeyHandlerClient.mc.thePlayer.ridingEntity;
if (entityTest != null && entityTest instanceof IControllableEntity && keyNum != -1) {
IControllableEntity entity = (IControllableEntity) entityTest;
if (kb.getKeyCode() == KeyHandlerClient.mc.gameSettings.keyBindInventory.getKeyCode()) {
KeyBinding.setKeyBindState(KeyHandlerClient.mc.gameSettings.keyBindInventory.getKeyCode(), false);
}
entity.pressKey(keyNum);
} else if (entityTest != null && entityTest instanceof EntityAutoRocket) {
EntityAutoRocket autoRocket = (EntityAutoRocket) entityTest;
if (autoRocket.launchPhase == EnumLaunchPhase.LANDING.ordinal()) {
if (kb == KeyHandlerClient.leftShiftKey) {
autoRocket.motionY -= 0.02D;
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_UPDATE_SHIP_MOTION_Y, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] { autoRocket.getEntityId(), false }));
}
if (kb == KeyHandlerClient.spaceKey) {
autoRocket.motionY += 0.02D;
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_UPDATE_SHIP_MOTION_Y, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] { autoRocket.getEntityId(), true }));
}
}
}
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.
the class OverlaySensorGlasses method renderSensorGlassesValueableBlocks.
public static void renderSensorGlassesValueableBlocks(ItemStack stack, EntityPlayer player, ScaledResolution resolution, float partialTicks) {
final Iterator<BlockVec3> var51 = ClientProxyCore.valueableBlocks.iterator();
double var52;
double var58;
double var59;
double var20;
double var21;
float var60;
while (var51.hasNext()) {
BlockVec3 coords = var51.next();
var52 = ClientProxyCore.playerPosX - coords.x - 0.5D;
var58 = ClientProxyCore.playerPosY - coords.y - 0.5D;
var59 = ClientProxyCore.playerPosZ - coords.z - 0.5D;
var60 = (float) Math.toDegrees(Math.atan2(var52, var59));
var20 = Math.sqrt(var52 * var52 + var58 * var58 + var59 * var59) * 0.5D;
var21 = Math.sqrt(var52 * var52 + var59 * var59) * 0.5D;
final ScaledResolution var5 = ClientUtil.getScaledRes(OverlaySensorGlasses.minecraft, OverlaySensorGlasses.minecraft.displayWidth, OverlaySensorGlasses.minecraft.displayHeight);
final int var6 = var5.getScaledWidth();
final int var7 = var5.getScaledHeight();
boolean var2 = false;
final EntityPlayerSP client = PlayerUtil.getPlayerBaseClientFromPlayer(OverlaySensorGlasses.minecraft.thePlayer, false);
if (client != null) {
GCPlayerStatsClient stats = GCPlayerStatsClient.get(client);
var2 = stats.isUsingAdvancedGoggles();
}
OverlaySensorGlasses.minecraft.fontRendererObj.drawString(GCCoreUtil.translate("gui.sensor.advanced") + ": " + (var2 ? GCCoreUtil.translate("gui.sensor.advancedon") : GCCoreUtil.translate("gui.sensor.advancedoff")), var6 / 2 - 50, 4, 0x03b88f);
try {
GL11.glPushMatrix();
if (var20 < 4.0D) {
GL11.glColor4f(0.0F, 255F / 255F, 198F / 255F, (float) Math.min(1.0D, Math.max(0.2D, (var20 - 1.0D) * 0.1D)));
FMLClientHandler.instance().getClient().renderEngine.bindTexture(OverlaySensorGlasses.indicatorTexture);
GL11.glRotatef(-var60 - ClientProxyCore.playerRotationYaw + 180.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslated(0.0D, var2 ? -var20 * 16 : -var21 * 16, 0.0D);
GL11.glRotatef(-(-var60 - ClientProxyCore.playerRotationYaw + 180.0F), 0.0F, 0.0F, 1.0F);
Overlay.drawCenteringRectangle(var6 / 2, var7 / 2, 1.0D, 8.0D, 8.0D);
}
} finally {
GL11.glPopMatrix();
}
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.
the class GCEntityClientPlayerMP method onLivingUpdate.
@Override
public void onLivingUpdate() {
ClientProxyCore.playerClientHandler.onLivingUpdatePre(this);
try {
if (this.worldObj.provider instanceof IZeroGDimension) {
// from: EntityPlayerSP
if (this.sprintingTicksLeft > 0) {
--this.sprintingTicksLeft;
if (this.sprintingTicksLeft == 0) {
this.setSprinting(false);
}
}
if (this.sprintToggleTimer > 0) {
--this.sprintToggleTimer;
}
this.prevTimeInPortal = this.timeInPortal;
if (this.inPortal) {
if (this.mc.currentScreen != null && !this.mc.currentScreen.doesGuiPauseGame()) {
this.mc.displayGuiScreen((GuiScreen) null);
}
if (this.timeInPortal == 0.0F) {
this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F));
}
this.timeInPortal += 0.0125F;
if (this.timeInPortal >= 1.0F) {
this.timeInPortal = 1.0F;
}
this.inPortal = false;
} else if (this.isPotionActive(Potion.confusion) && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) {
this.timeInPortal += 0.006666667F;
if (this.timeInPortal > 1.0F) {
this.timeInPortal = 1.0F;
}
} else {
if (this.timeInPortal > 0.0F) {
this.timeInPortal -= 0.05F;
}
if (this.timeInPortal < 0.0F) {
this.timeInPortal = 0.0F;
}
}
if (this.timeUntilPortal > 0) {
--this.timeUntilPortal;
}
boolean flag1 = this.movementInput.sneak;
float sprintlevel = 0.8F;
boolean flag2 = this.movementInput.moveForward >= sprintlevel;
this.movementInput.updatePlayerMoveState();
if (this.isUsingItem() && !this.isRiding()) {
this.movementInput.moveStrafe *= 0.2F;
this.movementInput.moveForward *= 0.2F;
this.sprintToggleTimer = 0;
}
// CUSTOM-------------------
GCPlayerStatsClient stats = GCPlayerStatsClient.get(this);
if (stats.getLandingTicks() > 0) {
this.movementInput.moveStrafe *= 0.5F;
this.movementInput.moveForward *= 0.5F;
}
// -----------END CUSTOM
this.pushOutOfBlocks(this.posX - (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double) this.width * 0.35D);
this.pushOutOfBlocks(this.posX - (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ - (double) this.width * 0.35D);
this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ - (double) this.width * 0.35D);
this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double) this.width * 0.35D);
boolean flag3 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying;
if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= sprintlevel && !this.isSprinting() && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness)) {
if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) {
this.sprintToggleTimer = 7;
} else {
this.setSprinting(true);
}
}
if (!this.isSprinting() && this.movementInput.moveForward >= sprintlevel && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.isKeyDown()) {
this.setSprinting(true);
}
if (this.isSprinting() && (this.movementInput.moveForward < sprintlevel || this.isCollidedHorizontally || !flag3)) {
this.setSprinting(false);
}
if (this.capabilities.isFlying && this.isCurrentViewEntity()) {
if (this.movementInput.sneak) {
this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F);
}
if (this.movementInput.jump) {
this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F);
}
}
if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL && this.worldObj.getGameRules().getBoolean("naturalRegeneration")) {
if (this.getHealth() < this.getMaxHealth() && this.ticksExisted % 20 == 0) {
this.heal(1.0F);
}
if (this.foodStats.needFood() && this.ticksExisted % 10 == 0) {
this.foodStats.setFoodLevel(this.foodStats.getFoodLevel() + 1);
}
}
this.inventory.decrementAnimations();
this.prevCameraYaw = this.cameraYaw;
// from: EntityLivingBase
if (this.newPosRotationIncrements > 0) {
double d0 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements;
double d1 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements;
double d2 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements;
double d3 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw);
this.rotationYaw = (float) ((double) this.rotationYaw + d3 / (double) this.newPosRotationIncrements);
this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements);
--this.newPosRotationIncrements;
this.setPosition(d0, d1, d2);
this.setRotation(this.rotationYaw, this.rotationPitch);
} else if (!this.isServerWorld()) {
this.motionX *= 0.98D;
this.motionY *= 0.98D;
this.motionZ *= 0.98D;
}
if (Math.abs(this.motionX) < 0.005D) {
this.motionX = 0.0D;
}
if (Math.abs(this.motionY) < 0.005D) {
this.motionY = 0.0D;
}
if (Math.abs(this.motionZ) < 0.005D) {
this.motionZ = 0.0D;
}
this.worldObj.theProfiler.startSection("ai");
if (this.isMovementBlocked()) {
this.isJumping = false;
this.moveStrafing = 0.0F;
this.moveForward = 0.0F;
this.randomYawVelocity = 0.0F;
} else
this.updateEntityActionState();
this.worldObj.theProfiler.endSection();
this.worldObj.theProfiler.startSection("travel");
this.moveStrafing *= 0.98F;
this.moveForward *= 0.98F;
this.randomYawVelocity *= 0.9F;
// CUSTOM--------------
AxisAlignedBB aABB = this.getEntityBoundingBox();
if ((aABB.minY % 1D) == 0.5D)
this.setEntityBoundingBox(aABB.offset(0D, 0.00001D, 0D));
// -----------END CUSTOM
this.moveEntityWithHeading(this.moveStrafing, this.moveForward);
this.worldObj.theProfiler.endSection();
this.worldObj.theProfiler.startSection("push");
if (!this.worldObj.isRemote) {
this.collideWithNearbyEntities();
}
this.worldObj.theProfiler.endSection();
// -from: EntityPlayer
// Omit IAttributeInstance - seems relevant only on server
// Omit this.jumpMovementFactor = this.speedInAir;
// (no bounding in space)
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
float f1 = (float) (Math.atan(-this.motionY * 0.20000000298023224D) * 15.0D);
if (f > 0.1F) {
f = 0.1F;
}
if (!this.onGround || this.getHealth() <= 0.0F) {
f = 0.0F;
}
if (this.onGround || this.getHealth() <= 0.0F) {
f1 = 0.0F;
}
this.cameraYaw += (f - this.cameraYaw) * 0.4F;
this.cameraPitch += (f1 - this.cameraPitch) * 0.8F;
if (this.getHealth() > 0.0F && !this.isSpectator()) {
AxisAlignedBB axisalignedbb = null;
if (this.ridingEntity != null && !this.ridingEntity.isDead) {
axisalignedbb = this.getEntityBoundingBox().union(this.ridingEntity.getEntityBoundingBox()).expand(1.0D, 0.0D, 1.0D);
} else {
axisalignedbb = this.getEntityBoundingBox().expand(1.0D, 0.5D, 1.0D);
}
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, axisalignedbb);
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
if (!entity.isDead) {
entity.onCollideWithPlayer(this);
}
}
}
// (modified CUSTOM)
if (this.lastIsFlying != this.capabilities.isFlying) {
this.lastIsFlying = this.capabilities.isFlying;
this.sendPlayerAbilities();
}
} else {
super.onLivingUpdate();
}
} catch (RuntimeException e) {
FMLLog.severe("A mod has crashed while Minecraft was doing a normal player tick update. See details below. GCEntityClientPlayerMP is in this because that is the player class name when Galacticraft is installed. This is =*NOT*= a bug in Galacticraft, please report it to the mod indicated by the first lines of the crash report.");
throw (e);
}
ClientProxyCore.playerClientHandler.onLivingUpdatePost(this);
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient in project Galacticraft by micdoodle8.
the class GCEntityClientPlayerMP method isSneaking.
@Override
public boolean isSneaking() {
if (this.worldObj.provider instanceof IZeroGDimension) {
ZeroGravityEvent zeroGEvent = new ZeroGravityEvent.SneakOverride(this);
MinecraftForge.EVENT_BUS.post(zeroGEvent);
if (zeroGEvent.isCanceled()) {
return super.isSneaking();
}
GCPlayerStatsClient stats = GCPlayerStatsClient.get(this);
if (stats.getLandingTicks() > 0) {
if (this.lastLandingTicks == 0)
this.lastLandingTicks = stats.getLandingTicks();
this.sneakLast = stats.getLandingTicks() < this.lastLandingTicks;
return sneakLast;
} else
this.lastLandingTicks = 0;
if (stats.getFreefallHandler().pjumpticks > 0) {
this.sneakLast = true;
return true;
}
if (EventHandlerClient.sneakRenderOverride) {
if (this.movementInput != null && this.movementInput.sneak != this.sneakLast) {
this.sneakLast = this.movementInput.sneak;
return false;
}
// if (stats.freefallHandler.testFreefall(this)) return false;
if (stats.isInFreefall() || stats.getFreefallHandler().onWall) {
this.sneakLast = false;
return false;
}
}
} else if (EventHandlerClient.sneakRenderOverride) {
if (this.onGround && this.inventory.getCurrentItem() != null && this.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(this.ridingEntity instanceof ICameraZoomEntity)) {
IHoldableItem holdableItem = (IHoldableItem) this.inventory.getCurrentItem().getItem();
if (holdableItem.shouldCrouch(this)) {
return true;
}
}
}
this.sneakLast = false;
return super.isSneaking();
}
Aggregations