| 1 | package net.minecraft.client.entity;
|
| 2 |
|
| 3 | import com.mojang.authlib.GameProfile;
|
| 4 | import net.minecraft.client.Minecraft;
|
| 5 | import net.minecraft.item.ItemStack;
|
| 6 | import net.minecraft.util.BlockPos;
|
| 7 | import net.minecraft.util.DamageSource;
|
| 8 | import net.minecraft.util.IChatComponent;
|
| 9 | import net.minecraft.util.MathHelper;
|
| 10 | import net.minecraft.world.World;
|
| 11 |
|
| 12 | public class EntityOtherPlayerMP extends AbstractClientPlayer
|
| 13 | {
|
| 14 | private boolean isItemInUse;
|
| 15 | private int otherPlayerMPPosRotationIncrements;
|
| 16 | private double otherPlayerMPX;
|
| 17 | private double otherPlayerMPY;
|
| 18 | private double otherPlayerMPZ;
|
| 19 | private double otherPlayerMPYaw;
|
| 20 | private double otherPlayerMPPitch;
|
| 21 |
|
| 22 | public EntityOtherPlayerMP(World worldIn, GameProfile gameProfileIn)
|
| 23 | {
|
| 24 | super(worldIn, gameProfileIn);
|
| 25 | this.stepHeight = 0.0F;
|
| 26 | this.noClip = true;
|
| 27 | this.renderOffsetY = 0.25F;
|
| 28 | this.renderDistanceWeight = 10.0D;
|
| 29 | }
|
| 30 |
|
| 31 | /**
|
| 32 | * Called when the entity is attacked.
|
| 33 | */
|
| 34 | public boolean attackEntityFrom(DamageSource source, float amount)
|
| 35 | {
|
| 36 | return true;
|
| 37 | }
|
| 38 |
|
| 39 | public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
| 40 | {
|
| 41 | this.otherPlayerMPX = x;
|
| 42 | this.otherPlayerMPY = y;
|
| 43 | this.otherPlayerMPZ = z;
|
| 44 | this.otherPlayerMPYaw = (double)yaw;
|
| 45 | this.otherPlayerMPPitch = (double)pitch;
|
| 46 | this.otherPlayerMPPosRotationIncrements = posRotationIncrements;
|
| 47 | }
|
| 48 |
|
| 49 | /**
|
| 50 | * Called to update the entity's position/logic.
|
| 51 | */
|
| 52 | public void onUpdate()
|
| 53 | {
|
| 54 | this.renderOffsetY = 0.0F;
|
| 55 | super.onUpdate();
|
| 56 | this.prevLimbSwingAmount = this.limbSwingAmount;
|
| 57 | double d0 = this.posX - this.prevPosX;
|
| 58 | double d1 = this.posZ - this.prevPosZ;
|
| 59 | float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F;
|
| 60 |
|
| 61 | if (f > 1.0F)
|
| 62 | {
|
| 63 | f = 1.0F;
|
| 64 | }
|
| 65 |
|
| 66 | this.limbSwingAmount += (f - this.limbSwingAmount) * 0.4F;
|
| 67 | this.limbSwing += this.limbSwingAmount;
|
| 68 |
|
| 69 | if (!this.isItemInUse && this.isEating() && this.inventory.mainInventory[this.inventory.currentItem] != null)
|
| 70 | {
|
| 71 | ItemStack itemstack = this.inventory.mainInventory[this.inventory.currentItem];
|
| 72 | this.setItemInUse(this.inventory.mainInventory[this.inventory.currentItem], itemstack.getItem().getMaxItemUseDuration(itemstack));
|
| 73 | this.isItemInUse = true;
|
| 74 | }
|
| 75 | else if (this.isItemInUse && !this.isEating())
|
| 76 | {
|
| 77 | this.clearItemInUse();
|
| 78 | this.isItemInUse = false;
|
| 79 | }
|
| 80 | }
|
| 81 |
|
| 82 | /**
|
| 83 | * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
|
| 84 | * use this to react to sunlight and start to burn.
|
| 85 | */
|
| 86 | public void onLivingUpdate()
|
| 87 | {
|
| 88 | if (this.otherPlayerMPPosRotationIncrements > 0)
|
| 89 | {
|
| 90 | double d0 = this.posX + (this.otherPlayerMPX - this.posX) / (double)this.otherPlayerMPPosRotationIncrements;
|
| 91 | double d1 = this.posY + (this.otherPlayerMPY - this.posY) / (double)this.otherPlayerMPPosRotationIncrements;
|
| 92 | double d2 = this.posZ + (this.otherPlayerMPZ - this.posZ) / (double)this.otherPlayerMPPosRotationIncrements;
|
| 93 | double d3;
|
| 94 |
|
| 95 | for (d3 = this.otherPlayerMPYaw - (double)this.rotationYaw; d3 < -180.0D; d3 += 360.0D)
|
| 96 | {
|
| 97 | ;
|
| 98 | }
|
| 99 |
|
| 100 | while (d3 >= 180.0D)
|
| 101 | {
|
| 102 | d3 -= 360.0D;
|
| 103 | }
|
| 104 |
|
| 105 | this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.otherPlayerMPPosRotationIncrements);
|
| 106 | this.rotationPitch = (float)((double)this.rotationPitch + (this.otherPlayerMPPitch - (double)this.rotationPitch) / (double)this.otherPlayerMPPosRotationIncrements);
|
| 107 | --this.otherPlayerMPPosRotationIncrements;
|
| 108 | this.setPosition(d0, d1, d2);
|
| 109 | this.setRotation(this.rotationYaw, this.rotationPitch);
|
| 110 | }
|
| 111 |
|
| 112 | this.prevCameraYaw = this.cameraYaw;
|
| 113 | this.updateArmSwingProgress();
|
| 114 | float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
| 115 | float f = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
|
| 116 |
|
| 117 | if (f1 > 0.1F)
|
| 118 | {
|
| 119 | f1 = 0.1F;
|
| 120 | }
|
| 121 |
|
| 122 | if (!this.onGround || this.getHealth() <= 0.0F)
|
| 123 | {
|
| 124 | f1 = 0.0F;
|
| 125 | }
|
| 126 |
|
| 127 | if (this.onGround || this.getHealth() <= 0.0F)
|
| 128 | {
|
| 129 | f = 0.0F;
|
| 130 | }
|
| 131 |
|
| 132 | this.cameraYaw += (f1 - this.cameraYaw) * 0.4F;
|
| 133 | this.cameraPitch += (f - this.cameraPitch) * 0.8F;
|
| 134 | }
|
| 135 |
|
| 136 | /**
|
| 137 | * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
|
| 138 | */
|
| 139 | public void setCurrentItemOrArmor(int slotIn, ItemStack stack)
|
| 140 | {
|
| 141 | if (slotIn == 0)
|
| 142 | {
|
| 143 | this.inventory.mainInventory[this.inventory.currentItem] = stack;
|
| 144 | }
|
| 145 | else
|
| 146 | {
|
| 147 | this.inventory.armorInventory[slotIn - 1] = stack;
|
| 148 | }
|
| 149 | }
|
| 150 |
|
| 151 | /**
|
| 152 | * Send a chat message to the CommandSender
|
| 153 | */
|
| 154 | public void addChatMessage(IChatComponent component)
|
| 155 | {
|
| 156 | Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(component);
|
| 157 | }
|
| 158 |
|
| 159 | /**
|
| 160 | * Returns {@code true} if the CommandSender is allowed to execute the command, {@code false} if not
|
| 161 | */
|
| 162 | public boolean canCommandSenderUseCommand(int permLevel, String commandName)
|
| 163 | {
|
| 164 | return false;
|
| 165 | }
|
| 166 |
|
| 167 | /**
|
| 168 | * Get the position in the world. <b>{@code null} is not allowed!</b> If you are not an entity in the world, return
|
| 169 | * the coordinates 0, 0, 0
|
| 170 | */
|
| 171 | public BlockPos getPosition()
|
| 172 | {
|
| 173 | return new BlockPos(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D);
|
| 174 | }
|
| 175 | }
|
| 176 |
|