add camera system
This commit is contained in:
parent
e0a031c5d0
commit
a76c0c66e1
17 changed files with 464 additions and 207 deletions
|
@ -110,6 +110,7 @@ import common.effect.Effect;
|
|||
import common.effect.StatusEffect;
|
||||
import common.entity.Entity;
|
||||
import common.entity.animal.EntityHorse;
|
||||
import common.entity.item.EntityCamera;
|
||||
import common.entity.item.EntityCart;
|
||||
import common.entity.npc.Energy;
|
||||
import common.entity.npc.EntityCpu;
|
||||
|
@ -150,7 +151,9 @@ import common.network.PacketSplitter;
|
|||
import common.network.NetHandler.ThreadQuickExitException;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketCheat;
|
||||
import common.packet.CPacketInput;
|
||||
import common.packet.CPacketMessage;
|
||||
import common.packet.CPacketPlayerPosLook;
|
||||
import common.packet.HPacketHandshake;
|
||||
import common.packet.CPacketAction.Action;
|
||||
import common.properties.Property;
|
||||
|
@ -847,7 +850,7 @@ public class Client implements IThreadListener {
|
|||
|
||||
else
|
||||
{
|
||||
if (Bind.PERSPECTIVE.isPressed())
|
||||
if (Bind.PERSPECTIVE.isPressed() && this.viewEntity == this.player)
|
||||
{
|
||||
++this.thirdPersonView;
|
||||
|
||||
|
@ -864,35 +867,37 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
|
||||
boolean hadZoom = this.zooming;
|
||||
this.zooming = Bind.ZOOM.isDown();
|
||||
this.zooming = Bind.ZOOM.isDown() || this.viewEntity != this.player;
|
||||
if(this.zooming && !hadZoom) {
|
||||
this.zoomLevel = 2.0f;
|
||||
this.zoomLevel = this.viewEntity != this.player ? 1.0f : 2.0f;
|
||||
}
|
||||
|
||||
for (int l = 0; l < 9; ++l)
|
||||
{
|
||||
if (this.keyBindsHotbar[l].isPressed())
|
||||
{
|
||||
if(this.player.getSelectedIndex() != l)
|
||||
this.controller.resetUseCooldown();
|
||||
this.player.setSelectedIndex(l);
|
||||
}
|
||||
if(this.viewEntity == this.player) {
|
||||
for (int l = 0; l < 9; ++l)
|
||||
{
|
||||
if (this.keyBindsHotbar[l].isPressed())
|
||||
{
|
||||
if(this.player.getSelectedIndex() != l)
|
||||
this.controller.resetUseCooldown();
|
||||
this.player.setSelectedIndex(l);
|
||||
}
|
||||
}
|
||||
|
||||
if (Bind.THROW.isPressed())
|
||||
{
|
||||
this.player.dropOneItem(this.ctrl());
|
||||
}
|
||||
else if(Bind.RENAME.isPressed()) {
|
||||
ItemStack stack = this.player.getHeldItem();
|
||||
if(stack != null)
|
||||
this.show(new GuiRename(-1, stack, null));
|
||||
}
|
||||
|
||||
this.primary |= Bind.PRIMARY.isPressed();
|
||||
this.secondary |= Bind.SECONDARY.isPressed();
|
||||
this.tertiary |= Bind.TERTIARY.isPressed();
|
||||
this.quarternary |= Bind.QUARTERNARY.isPressed();
|
||||
}
|
||||
|
||||
if (Bind.THROW.isPressed())
|
||||
{
|
||||
this.player.dropOneItem(this.ctrl());
|
||||
}
|
||||
else if(Bind.RENAME.isPressed()) {
|
||||
ItemStack stack = this.player.getHeldItem();
|
||||
if(stack != null)
|
||||
this.show(new GuiRename(-1, stack, null));
|
||||
}
|
||||
|
||||
this.primary |= Bind.PRIMARY.isPressed();
|
||||
this.secondary |= Bind.SECONDARY.isPressed();
|
||||
this.tertiary |= Bind.TERTIARY.isPressed();
|
||||
this.quarternary |= Bind.QUARTERNARY.isPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -932,7 +937,7 @@ public class Client implements IThreadListener {
|
|||
if (this.open == null && this.player != null) {
|
||||
if (this.player.isUsingItem())
|
||||
{
|
||||
if (!Bind.SECONDARY.isDown())
|
||||
if (!Bind.SECONDARY.isDown() || this.viewEntity != this.player)
|
||||
{
|
||||
this.controller.stopUsing(this.player);
|
||||
}
|
||||
|
@ -960,12 +965,12 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (Bind.SECONDARY.isDown() && this.rightClickTimer == 0 && !this.player.isUsingItem())
|
||||
if (Bind.SECONDARY.isDown() && this.rightClickTimer == 0 && !this.player.isUsingItem() && this.viewEntity == this.player)
|
||||
{
|
||||
this.secondary();
|
||||
}
|
||||
|
||||
this.sendClickBlockToController(this.open == null && Bind.PRIMARY.isDown());
|
||||
this.sendClickBlockToController(this.open == null && Bind.PRIMARY.isDown() && this.viewEntity == this.player);
|
||||
}
|
||||
|
||||
this.primary = this.secondary = this.tertiary = this.quarternary = false;
|
||||
|
@ -1014,13 +1019,15 @@ public class Client implements IThreadListener {
|
|||
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
|
||||
}
|
||||
if(this.open == null) {
|
||||
if(this.player != null)
|
||||
if(this.player != null && this.viewEntity == this.player)
|
||||
this.player.setAngles(this.deltaX, this.deltaY);
|
||||
else if(this.player != null && this.viewEntity instanceof EntityCamera camera)
|
||||
camera.setAnglesClamped(this.deltaX, this.deltaY);
|
||||
this.deltaX = this.deltaY = 0.0f;
|
||||
}
|
||||
if(this.player != null)
|
||||
this.soundManager.setListener(this.player, (float)this.tickFraction);
|
||||
if(this.player != null && this.player.isEntityInsideOpaqueBlock())
|
||||
if(this.player != null && (this.player.isEntityInsideOpaqueBlock() || this.viewEntity != this.player))
|
||||
this.thirdPersonView = 0;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glClear(16640);
|
||||
|
@ -1384,7 +1391,7 @@ public class Client implements IThreadListener {
|
|||
|
||||
public void scroll(int dir) {
|
||||
if(this.zooming)
|
||||
this.zoomLevel = ExtMath.clampf(this.zoomLevel + (dir < 0 ? -0.25f : 0.25f), 2.0f, 16.0f);
|
||||
this.zoomLevel = ExtMath.clampf(this.zoomLevel + (dir < 0 ? -0.25f : 0.25f), this.viewEntity != this.player ? 1.0f : 2.0f, 16.0f);
|
||||
else if(this.player != null) {
|
||||
this.player.setSelectedIndex(this.player.getSelectedIndex() - dir);
|
||||
if(this.player.getSelectedIndex() < 0)
|
||||
|
@ -1827,6 +1834,15 @@ public class Client implements IThreadListener {
|
|||
this.moveStrafe = (float)((double)this.moveStrafe * 0.3D);
|
||||
this.moveForward = (float)((double)this.moveForward * 0.3D);
|
||||
}
|
||||
|
||||
if(this.viewEntity instanceof EntityCamera camera) {
|
||||
camera.onUpdate();
|
||||
camera.setMovement(this.moveStrafe, this.moveForward, this.jump, this.sneak);
|
||||
this.getNetHandler().addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.jump, this.sneak, true));
|
||||
this.getNetHandler().addToSendQueue(new CPacketPlayerPosLook(camera.posX, camera.posY, camera.posZ, camera.rotYaw, camera.rotPitch, this.sprint).setCamera());
|
||||
// if(!camera.fixed && this.sprint)
|
||||
// this.viewEntity = this.player;
|
||||
}
|
||||
}
|
||||
|
||||
public String getLeft() {
|
||||
|
@ -3110,7 +3126,7 @@ public class Client implements IThreadListener {
|
|||
GlState.depthMask(false);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)(this.fbX / 2), (float)(this.fbY / 2), 0.0F);
|
||||
this.renderer.rotateCamera(this.viewEntity, partialTicks);
|
||||
this.renderer.rotateCamera(this.viewEntity, partialTicks, true);
|
||||
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255);
|
||||
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255);
|
||||
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255);
|
||||
|
|
|
@ -39,6 +39,7 @@ import common.entity.DataWatcher;
|
|||
import common.entity.Entity;
|
||||
import common.entity.effect.EntityLightning;
|
||||
import common.entity.item.EntityBoat;
|
||||
import common.entity.item.EntityCamera;
|
||||
import common.entity.item.EntityXp;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.npc.PlayerCharacter;
|
||||
|
@ -693,7 +694,8 @@ public class ClientPlayer implements IClientPlayer
|
|||
}
|
||||
|
||||
entityplayer.setPositionAndRotation(d0, d1, d2, f, f1);
|
||||
this.connection.sendPacket(new CPacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotYaw, entityplayer.rotPitch, false));
|
||||
if(this.gm.getRenderViewEntity() == entityplayer)
|
||||
this.connection.sendPacket(new CPacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotYaw, entityplayer.rotPitch, false));
|
||||
|
||||
if (!this.loaded)
|
||||
{
|
||||
|
@ -1663,12 +1665,8 @@ public class ClientPlayer implements IClientPlayer
|
|||
public void handleCamera(SPacketCamera packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||
Entity entity = packetIn.getEntity(this.world);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
this.gm.setRenderViewEntity(entity);
|
||||
}
|
||||
EntityCamera camera = packetIn.getEntity(this.world);
|
||||
this.gm.setRenderViewEntity(camera == null ? this.gm.player : camera);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package client.renderer;
|
||||
|
||||
public class BlockRenderer
|
||||
{
|
||||
}
|
|
@ -668,38 +668,26 @@ public class Renderer {
|
|||
|
||||
if (!this.gm.debugCamEnable || this.gm.thirdPersonView == 0)
|
||||
{
|
||||
GL11.glRotatef(entity.prevPitch + (entity.rotPitch - entity.prevPitch) * partialTicks, 1.0F, 0.0F, 0.0F);
|
||||
|
||||
if (entity instanceof EntityAnimal)
|
||||
{
|
||||
EntityAnimal entityanimal = (EntityAnimal)entity;
|
||||
GL11.glRotatef(entityanimal.prevHeadYaw + (entityanimal.headYaw - entityanimal.prevHeadYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glRotatef(entity.prevYaw + (entity.rotYaw - entity.prevYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
this.rotateCamera(entity, partialTicks, false);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(0.0F, -f, 0.0F);
|
||||
d0 = entity.prevX + (entity.posX - entity.prevX) * (double)partialTicks;
|
||||
d1 = entity.prevY + (entity.posY - entity.prevY) * (double)partialTicks + (double)f;
|
||||
d2 = entity.prevZ + (entity.posZ - entity.prevZ) * (double)partialTicks;
|
||||
}
|
||||
|
||||
public void rotateCamera(Entity entity, float partialTicks) {
|
||||
GL11.glRotatef(360.0f - (entity.prevPitch + (entity.rotPitch - entity.prevPitch) * partialTicks), 1.0F, 0.0F, 0.0F);
|
||||
|
||||
if (entity instanceof EntityAnimal)
|
||||
{
|
||||
EntityAnimal entityanimal = (EntityAnimal)entity;
|
||||
GL11.glRotatef(entityanimal.prevHeadYaw + (entityanimal.headYaw - entityanimal.prevHeadYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glRotatef(entity.prevYaw + (entity.rotYaw - entity.prevYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
public void rotateCamera(Entity entity, float partialTicks, boolean invert) {
|
||||
if(invert)
|
||||
GL11.glRotatef(360.0f - (entity.prevPitch + (entity.rotPitch - entity.prevPitch) * partialTicks), 1.0F, 0.0F, 0.0F);
|
||||
else
|
||||
GL11.glRotatef(entity.prevPitch + (entity.rotPitch - entity.prevPitch) * partialTicks, 1.0F, 0.0F, 0.0F);
|
||||
|
||||
if(entity instanceof EntityAnimal) {
|
||||
EntityAnimal entityanimal = (EntityAnimal)entity;
|
||||
GL11.glRotatef(entityanimal.prevHeadYaw + (entityanimal.headYaw - entityanimal.prevHeadYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else {
|
||||
GL11.glRotatef(entity.prevYaw + (entity.rotYaw - entity.prevYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCameraTransform(float partialTicks)
|
||||
{
|
||||
|
@ -1208,7 +1196,7 @@ public class Renderer {
|
|||
this.setupFog(0, partialTicks);
|
||||
this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS);
|
||||
ItemRenderer.disableStandardItemLighting();
|
||||
this.setupTerrain(entity, (double)partialTicks, this.frameCount++, this.gm.player.noclip);
|
||||
this.setupTerrain(entity, (double)partialTicks, this.frameCount++, entity != this.gm.player || this.gm.player.noclip);
|
||||
this.updateChunks(finishTimeNano);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glPushMatrix();
|
||||
|
@ -1292,11 +1280,11 @@ public class Renderer {
|
|||
this.renderCloudsCheck(partialTicks);
|
||||
}
|
||||
|
||||
// if (this.renderHand)
|
||||
// {
|
||||
GL11.glClear(256);
|
||||
this.renderHand(partialTicks);
|
||||
// }
|
||||
if (entity == this.gm.player)
|
||||
{
|
||||
GL11.glClear(256);
|
||||
this.renderHand(partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderCloudsCheck(float partialTicks)
|
||||
|
|
|
@ -69,16 +69,13 @@ public class RenderHumanoid extends RenderNpc
|
|||
|
||||
public void doRender(EntityNPC entity, double x, double y, double z, float partialTicks)
|
||||
{
|
||||
if (entity != this.manager.gm.player || this.manager.livingPlayer == entity)
|
||||
{
|
||||
// if(entity.isBoss())
|
||||
// BossStatus.setBossStatus(entity);
|
||||
double d0 = y;
|
||||
if(/* this.canSneak() && */ entity.isSneakingVisually() && entity != this.manager.gm.player)
|
||||
d0 = y - 0.125D;
|
||||
this.setModelVisibilities(entity);
|
||||
super.doRender(entity, x, d0, z, partialTicks);
|
||||
}
|
||||
// if(entity.isBoss())
|
||||
// BossStatus.setBossStatus(entity);
|
||||
double d0 = y;
|
||||
if(/* this.canSneak() && */ entity.isSneakingVisually())
|
||||
d0 = y - 0.125D;
|
||||
this.setModelVisibilities(entity);
|
||||
super.doRender(entity, x, d0, z, partialTicks);
|
||||
}
|
||||
|
||||
protected void renderLayers(EntityNPC entity, float swing, float amount, float partial, float time, float dYaw, float dPitch, float scale) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue