Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.isageek.joethornton.Orientation;
- import net.minecraft.server.ControllerLook;
- import net.minecraft.server.ControllerMove;
- import net.minecraft.server.EntityPlayer;
- import net.minecraft.server.ItemInWorldManager;
- import net.minecraft.server.NBTTagCompound;
- import net.minecraft.server.NetServerHandler;
- public class SafePlayer extends EntityPlayer {
- protected Float realPitch = 0.0F;
- protected Float realYaw = 90.0F;
- private SafeControllerMove mController;
- private SafeControllerLook lController;
- public SafePlayer(EntityPlayer entityplayer) {
- super(entityplayer.server, entityplayer.world, entityplayer.name,
- new ItemInWorldManager(entityplayer.world) /*entityplayer.itemInWorldManager*/);
- this.inventory.items = entityplayer.inventory.getContents();
- this.inventory.armor = entityplayer.inventory.getArmorContents();
- this.inventory.itemInHandIndex = entityplayer.inventory.itemInHandIndex;
- this.inventory.setCarried(entityplayer.inventory.getCarried());
- this.inventory.update();
- this.health = entityplayer.getHealth();
- this.foodData = entityplayer.getFoodData();
- this.expLevel = entityplayer.expLevel;
- this.expTotal = entityplayer.expTotal;
- this.exp = entityplayer.exp;
- this.q = entityplayer.q;
- this.id = entityplayer.id;
- this.locX = entityplayer.locX;
- this.locY = entityplayer.locY;
- this.locZ = entityplayer.locZ;
- this.dimension = entityplayer.dimension;
- this.abilities = entityplayer.abilities;
- this.mController = new SafeControllerMove(this);
- this.lController = new SafeControllerLook(this);
- this.bukkitEntity = entityplayer.getBukkitEntity();
- this.netServerHandler = new NetServerHandler(
- this.server, entityplayer.netServerHandler.networkManager, this);
- this.setRot(this.pitch, this.yaw);
- }
- public void setRot(float p, float y) {
- if (Float.isInfinite(p) || Float.isNaN(p)) {
- if (Float.isInfinite(this.lastPitch) || Float.isNaN(this.lastPitch)) {
- this.lastPitch = this.realPitch;
- this.pitch = this.realPitch;
- }
- this.pitch = this.lastPitch = this.realPitch;
- }
- this.lastPitch = this.pitch = p;
- if (Float.isInfinite(y) || Float.isNaN(y)) {
- if (Float.isInfinite(this.lastYaw) || Float.isNaN(this.lastYaw)) {
- this.lastYaw = this.realYaw;
- this.yaw = this.realYaw;
- }
- this.yaw = this.lastYaw = this.realYaw;
- }
- this.lastYaw = this.yaw = y;
- }
- public void setPitch(float p) {
- if (Float.isInfinite(p) || Float.isNaN(p)) {
- if (Float.isInfinite(this.lastPitch) || Float.isNaN(this.lastPitch)) {
- this.lastPitch = this.realPitch;
- this.pitch = this.realPitch;
- }
- this.pitch = this.lastPitch = this.realPitch;
- }
- this.lastPitch = this.pitch = p;
- }
- public void setYaw(float y) {
- if (Float.isInfinite(y) || Float.isNaN(y)) {
- if (Float.isInfinite(this.lastYaw) || Float.isNaN(this.lastYaw)) {
- this.lastYaw = this.realYaw;
- this.yaw = this.realYaw;
- }
- this.yaw = this.lastYaw = this.realYaw;
- }
- this.lastYaw = this.yaw = y;
- }
- @Override
- public ControllerMove getControllerMove() {
- return this.mController;
- }
- @Override
- public ControllerLook getControllerLook() {
- return this.lController;
- }
- /*
- public Navigation getNavigation() {
- return this.navigation;
- }*/
- @Override
- protected void b(float f, float f1) {
- setRot(f1,f);
- }
- @Override
- public void setLocation(double d0, double d1, double d2, float f, float f1) {
- this.lastX = this.locX = d0;
- this.lastY = this.locY = d1;
- this.lastZ = this.locZ = d2;
- setRot(f1, f);
- this.V = 0.0F;
- double d3 = (double) (this.lastYaw - this.yaw);
- if (d3 < -180.0D) {
- this.lastYaw += 360.0F;
- }
- if (d3 >= 180.0D) {
- this.lastYaw -= 360.0F;
- }
- this.setPosition(this.locX, this.locY, this.locZ);
- this.b(f, f1);
- }
- @Override
- public void setPositionRotation(double d0, double d1, double d2, float f, float f1) {
- this.bL = this.lastX = this.locX = d0;
- this.bM = this.lastY = this.locY = d1 + (double) this.height;
- this.bN = this.lastZ = this.locZ = d2;
- setRot(f1, f);
- this.setPosition(this.locX, this.locY, this.locZ);
- }
- @Override
- public void d(NBTTagCompound nbttagcompound) {
- nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY + (double) this.V, this.locZ}));
- nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
- setRot(this.pitch, this.yaw);
- nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
- nbttagcompound.setFloat("FallDistance", this.fallDistance);
- nbttagcompound.setShort("Fire", (short) this.fireTicks);
- nbttagcompound.setShort("Air", (short) this.getAirTicks());
- nbttagcompound.setBoolean("OnGround", this.onGround);
- // CraftBukkit start
- nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits());
- nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
- nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
- nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
- // CraftBukkit end
- this.b(nbttagcompound);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement