| 1 | package net.minecraft.client.entity;
|
| 2 |
|
| 3 | import info.sigmaclient.Client;
|
| 4 | import info.sigmaclient.event.EventSystem;
|
| 5 | import info.sigmaclient.event.impl.EventChat;
|
| 6 | import info.sigmaclient.event.impl.EventUpdate;
|
| 7 | import info.sigmaclient.event.impl.EventMove;
|
| 8 | import info.sigmaclient.event.impl.EventPushBlock;
|
| 9 | import info.sigmaclient.module.Module;
|
| 10 | import info.sigmaclient.module.data.Options;
|
| 11 | import info.sigmaclient.module.impl.combat.AntiBot;
|
| 12 | import info.sigmaclient.module.impl.movement.NoSlowdown;
|
| 13 | import info.sigmaclient.module.impl.movement.Phase;
|
| 14 | import info.sigmaclient.module.impl.movement.Sprint;
|
| 15 | import info.sigmaclient.util.misc.ChatUtil;
|
| 16 | import net.minecraft.client.Minecraft;
|
| 17 | import net.minecraft.client.audio.MovingSoundMinecartRiding;
|
| 18 | import net.minecraft.client.audio.PositionedSoundRecord;
|
| 19 | import net.minecraft.client.gui.GuiCommandBlock;
|
| 20 | import net.minecraft.client.gui.GuiEnchantment;
|
| 21 | import net.minecraft.client.gui.GuiHopper;
|
| 22 | import net.minecraft.client.gui.GuiMerchant;
|
| 23 | import net.minecraft.client.gui.GuiRepair;
|
| 24 | import net.minecraft.client.gui.GuiScreen;
|
| 25 | import net.minecraft.client.gui.GuiScreenBook;
|
| 26 | import net.minecraft.client.gui.inventory.GuiBeacon;
|
| 27 | import net.minecraft.client.gui.inventory.GuiBrewingStand;
|
| 28 | import net.minecraft.client.gui.inventory.GuiChest;
|
| 29 | import net.minecraft.client.gui.inventory.GuiCrafting;
|
| 30 | import net.minecraft.client.gui.inventory.GuiDispenser;
|
| 31 | import net.minecraft.client.gui.inventory.GuiEditSign;
|
| 32 | import net.minecraft.client.gui.inventory.GuiFurnace;
|
| 33 | import net.minecraft.client.gui.inventory.GuiScreenHorseInventory;
|
| 34 | import net.minecraft.client.network.NetHandlerPlayClient;
|
| 35 | import net.minecraft.command.server.CommandBlockLogic;
|
| 36 | import net.minecraft.entity.Entity;
|
| 37 | import net.minecraft.entity.IMerchant;
|
| 38 | import net.minecraft.entity.item.EntityItem;
|
| 39 | import net.minecraft.entity.item.EntityMinecart;
|
| 40 | import net.minecraft.entity.passive.EntityHorse;
|
| 41 | import net.minecraft.init.Items;
|
| 42 | import net.minecraft.inventory.IInventory;
|
| 43 | import net.minecraft.item.Item;
|
| 44 | import net.minecraft.item.ItemBow;
|
| 45 | import net.minecraft.item.ItemStack;
|
| 46 | import net.minecraft.item.ItemSword;
|
| 47 | import net.minecraft.network.play.client.C01PacketChatMessage;
|
| 48 | import net.minecraft.network.play.client.C03PacketPlayer;
|
| 49 | import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
| 50 | import net.minecraft.network.play.client.C0APacketAnimation;
|
| 51 | import net.minecraft.network.play.client.C0BPacketEntityAction;
|
| 52 | import net.minecraft.network.play.client.C0CPacketInput;
|
| 53 | import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
| 54 | import net.minecraft.network.play.client.C13PacketPlayerAbilities;
|
| 55 | import net.minecraft.network.play.client.C16PacketClientStatus;
|
| 56 | import net.minecraft.potion.Potion;
|
| 57 | import net.minecraft.stats.StatBase;
|
| 58 | import net.minecraft.stats.StatFileWriter;
|
| 59 | import net.minecraft.tileentity.TileEntitySign;
|
| 60 | import net.minecraft.util.BlockPos;
|
| 61 | import net.minecraft.util.DamageSource;
|
| 62 | import net.minecraft.util.EnumFacing;
|
| 63 | import net.minecraft.util.EnumParticleTypes;
|
| 64 | import net.minecraft.util.IChatComponent;
|
| 65 | import net.minecraft.util.MovementInput;
|
| 66 | import net.minecraft.util.ResourceLocation;
|
| 67 | import net.minecraft.world.IInteractionObject;
|
| 68 | import net.minecraft.world.World;
|
| 69 |
|
| 70 | public class EntityPlayerSP extends AbstractClientPlayer {
|
| 71 | public final NetHandlerPlayClient sendQueue;
|
| 72 | private final StatFileWriter field_146108_bO;
|
| 73 | private double field_175172_bI;
|
| 74 | public double lastReportedPosY;
|
| 75 | private double field_175167_bK;
|
| 76 | private float field_175164_bL;
|
| 77 | public float lastReportedPitch;
|
| 78 | private boolean field_175170_bN;
|
| 79 | private boolean field_175171_bO;
|
| 80 | private int field_175168_bP;
|
| 81 | private boolean field_175169_bQ;
|
| 82 | private String clientBrand;
|
| 83 | public MovementInput movementInput;
|
| 84 | protected Minecraft mc;
|
| 85 |
|
| 86 | /**
|
| 87 | * Used to tell if the player pressed forward twice. If this is at 0 and
|
| 88 | * it's pressed (And they are allowed to sprint, aka enough food on the
|
| 89 | * ground etc) it sets this to 7. If it's pressed and it's greater than 0
|
| 90 | * enable sprinting.
|
| 91 | */
|
| 92 | protected int sprintToggleTimer;
|
| 93 |
|
| 94 | /**
|
| 95 | * Ticks left before sprinting is disabled.
|
| 96 | */
|
| 97 | public int sprintingTicksLeft;
|
| 98 | public float renderArmYaw;
|
| 99 | public float renderArmPitch;
|
| 100 | public float prevRenderArmYaw;
|
| 101 | public float prevRenderArmPitch;
|
| 102 | private int horseJumpPowerCounter;
|
| 103 | private float horseJumpPower;
|
| 104 |
|
| 105 | /**
|
| 106 | * The amount of time an entity has been in a Portal
|
| 107 | */
|
| 108 | public float timeInPortal;
|
| 109 |
|
| 110 | /**
|
| 111 | * The amount of time an entity has been in a Portal the previous tick
|
| 112 | */
|
| 113 | public float prevTimeInPortal;
|
| 114 | private static final String __OBFID = "CL_00000938";
|
| 115 |
|
| 116 | public EntityPlayerSP(Minecraft mcIn, World worldIn, NetHandlerPlayClient p_i46278_3_, StatFileWriter p_i46278_4_) {
|
| 117 | super(worldIn, p_i46278_3_.func_175105_e());
|
| 118 | this.sendQueue = p_i46278_3_;
|
| 119 | this.field_146108_bO = p_i46278_4_;
|
| 120 | this.mc = mcIn;
|
| 121 | this.dimension = 0;
|
| 122 | }
|
| 123 |
|
| 124 | public boolean isEntityInsideOpaqueBlock() {
|
| 125 | return false;
|
| 126 | //return super.isEntityInsideOpaqueBlock();
|
| 127 | }
|
| 128 |
|
| 129 | /**
|
| 130 | * Called when the entity is attacked.
|
| 131 | */
|
| 132 | public boolean attackEntityFrom(DamageSource source, float amount) {
|
| 133 | return false;
|
| 134 | }
|
| 135 |
|
| 136 | /**
|
| 137 | * Heal living entity (param: amount of half-hearts)
|
| 138 | */
|
| 139 | public void heal(float p_70691_1_) {
|
| 140 |
|
| 141 | }
|
| 142 |
|
| 143 | public void moveEntity(double x, double y, double z) {
|
| 144 | EventMove em = (EventMove) EventSystem.getInstance(EventMove.class);
|
| 145 | em.fire(x, y, z);
|
| 146 | super.moveEntity(em.getX(), em.getY(), em.getZ());
|
| 147 | }
|
| 148 |
|
| 149 | /**
|
| 150 | * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
|
| 151 | */
|
| 152 | public void mountEntity(Entity entityIn) {
|
| 153 | super.mountEntity(entityIn);
|
| 154 |
|
| 155 | if (entityIn instanceof EntityMinecart) {
|
| 156 | this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart) entityIn));
|
| 157 | }
|
| 158 | }
|
| 159 |
|
| 160 | /**
|
| 161 | * Called to update the entity's position/logic.
|
| 162 | */
|
| 163 | public void onUpdate() {
|
| 164 | if (this.worldObj.isBlockLoaded(new BlockPos(this.posX, 0.0D, this.posZ))) {
|
| 165 | super.onUpdate();
|
| 166 | if (this.isRiding()) {
|
| 167 | this.sendQueue.addToSendQueue(
|
| 168 | new C03PacketPlayer.C05PacketPlayerLook(this.rotationYaw, this.rotationPitch, this.onGround));
|
| 169 | this.sendQueue.addToSendQueue(new C0CPacketInput(this.moveStrafing, this.moveForward,
|
| 170 | this.movementInput.jump, this.movementInput.sneak));
|
| 171 | } else {
|
| 172 | this.motionUpdates();
|
| 173 | }
|
| 174 | }
|
| 175 | }
|
| 176 |
|
| 177 | public void motionUpdates() {
|
| 178 | EventUpdate em = (EventUpdate) EventSystem.getInstance(EventUpdate.class);
|
| 179 | em.fire(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch, this.isSneaking(), this.onGround);
|
| 180 | if (em.isCancelled()) {
|
| 181 | em.fire();
|
| 182 | return;
|
| 183 | }
|
| 184 | boolean var1 = this.isSprinting();
|
| 185 | if (var1 != this.field_175171_bO) {
|
| 186 | if (var1) {
|
| 187 | this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SPRINTING));
|
| 188 | } else {
|
| 189 | this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SPRINTING));
|
| 190 | }
|
| 191 |
|
| 192 | this.field_175171_bO = var1;
|
| 193 | }
|
| 194 | boolean var2 = em.isSneaking();
|
| 195 | if (var2 != this.field_175170_bN) {
|
| 196 | if (var2) {
|
| 197 | this.sendQueue
|
| 198 | .addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SNEAKING));
|
| 199 | } else {
|
| 200 | this.sendQueue
|
| 201 | .addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SNEAKING));
|
| 202 | }
|
| 203 | this.field_175170_bN = var2;
|
| 204 | }
|
| 205 | if (this.func_175160_A()) {
|
| 206 | double var3 = em.getX() - this.field_175172_bI;
|
| 207 | double var5 = em.getY() - this.lastReportedPosY;
|
| 208 | double var7 = em.getZ() - this.field_175167_bK;
|
| 209 | double var9 = em.getYaw() - this.field_175164_bL;
|
| 210 | double var11 = em.getPitch() - this.lastReportedPitch;
|
| 211 | boolean var13 = var3 * var3 + var5 * var5 + var7 * var7 > 9.0E-4D || this.field_175168_bP >= 20;
|
| 212 | boolean var14 = var9 != 0.0D || var11 != 0.0D;
|
| 213 | if (this.ridingEntity == null) {
|
| 214 | if (((var13) && (var14)) || (em.shouldAlwaysSend())) {
|
| 215 | this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(em.getX(), em.getY(), em.getZ(), em.getYaw(), em.getPitch(), em.isOnground()));
|
| 216 | } else if (var13) {
|
| 217 | this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(em.getX(), em.getY(), em.getZ(), em.isOnground()));
|
| 218 | } else if (var14) {
|
| 219 | this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(em.getYaw(), em.getPitch(), em.isOnground()));
|
| 220 | } else {
|
| 221 | this.sendQueue.addToSendQueue(new C03PacketPlayer(em.isOnground()));
|
| 222 | }
|
| 223 | } else {
|
| 224 | this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D,
|
| 225 | this.motionZ, this.rotationYaw, this.rotationPitch, this.onGround));
|
| 226 | var13 = false;
|
| 227 | }
|
| 228 | ++this.field_175168_bP;
|
| 229 | if (var13) {
|
| 230 | this.field_175172_bI = this.posX;
|
| 231 | this.lastReportedPosY = this.getEntityBoundingBox().minY;
|
| 232 | this.field_175167_bK = this.posZ;
|
| 233 | this.field_175168_bP = 0;
|
| 234 | }
|
| 235 | if (var14) {
|
| 236 | this.field_175164_bL = em.getYaw();
|
| 237 | this.lastReportedPitch = em.getPitch();
|
| 238 | }
|
| 239 | }
|
| 240 | em.fire();
|
| 241 | }
|
| 242 |
|
| 243 | /**
|
| 244 | * Called when player presses the drop item key
|
| 245 | */
|
| 246 | public EntityItem dropOneItem(boolean p_71040_1_) {
|
| 247 | C07PacketPlayerDigging.Action var2 = p_71040_1_ ? C07PacketPlayerDigging.Action.DROP_ALL_ITEMS
|
| 248 | : C07PacketPlayerDigging.Action.DROP_ITEM;
|
| 249 | this.sendQueue.addToSendQueue(new C07PacketPlayerDigging(var2, BlockPos.ORIGIN, EnumFacing.DOWN));
|
| 250 | return null;
|
| 251 | }
|
| 252 |
|
| 253 | /**
|
| 254 | * Joins the passed in entity item with the world. Args: entityItem
|
| 255 | */
|
| 256 | protected void joinEntityItemWithWorld(EntityItem p_71012_1_) {
|
| 257 | }
|
| 258 |
|
| 259 | /**
|
| 260 | * Sends a chat message from the player. Args: chatMessage
|
| 261 | */
|
| 262 | public void sendChatMessage(String text) {
|
| 263 | EventChat ec = (EventChat) EventSystem.getInstance(EventChat.class);
|
| 264 | ec.fire(text);
|
| 265 | if (ec.isCancelled()) {
|
| 266 | return;
|
| 267 | }
|
| 268 | this.sendQueue.addToSendQueue(new C01PacketChatMessage(ec.getText()));
|
| 269 | }
|
| 270 |
|
| 271 | /**
|
| 272 | * Swings the item the player is holding.
|
| 273 | */
|
| 274 | public void swingItem() {
|
| 275 | super.swingItem();
|
| 276 | this.sendQueue.addToSendQueue(new C0APacketAnimation());
|
| 277 | }
|
| 278 |
|
| 279 | public void respawnPlayer() {
|
| 280 | this.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN));
|
| 281 | }
|
| 282 |
|
| 283 | /**
|
| 284 | * Deals damage to the entity. If its a EntityPlayer then will take damage
|
| 285 | * from the armor first and then health second with the reduced value. Args:
|
| 286 | * damageAmount
|
| 287 | */
|
| 288 | protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_) {
|
| 289 | if (!this.func_180431_b(p_70665_1_)) {
|
| 290 | this.setHealth(this.getHealth() - p_70665_2_);
|
| 291 | }
|
| 292 | }
|
| 293 |
|
| 294 | /**
|
| 295 | * set current crafting inventory back to the 2x2 square
|
| 296 | */
|
| 297 | public void closeScreen() {
|
| 298 | this.sendQueue.addToSendQueue(new C0DPacketCloseWindow(this.openContainer.windowId));
|
| 299 | this.func_175159_q();
|
| 300 | }
|
| 301 |
|
| 302 | public void func_175159_q() {
|
| 303 | this.inventory.setItemStack((ItemStack) null);
|
| 304 | super.closeScreen();
|
| 305 | this.mc.displayGuiScreen((GuiScreen) null);
|
| 306 | }
|
| 307 |
|
| 308 | /**
|
| 309 | * Updates health locally.
|
| 310 | */
|
| 311 | public void setPlayerSPHealth(float p_71150_1_) {
|
| 312 | if (this.field_175169_bQ) {
|
| 313 | float var2 = this.getHealth() - p_71150_1_;
|
| 314 |
|
| 315 | if (var2 <= 0.0F) {
|
| 316 | this.setHealth(p_71150_1_);
|
| 317 |
|
| 318 | if (var2 < 0.0F) {
|
| 319 | this.hurtResistantTime = this.maxHurtResistantTime / 2;
|
| 320 | }
|
| 321 | } else {
|
| 322 | this.lastDamage = var2;
|
| 323 | this.setHealth(this.getHealth());
|
| 324 | this.hurtResistantTime = this.maxHurtResistantTime;
|
| 325 | this.damageEntity(DamageSource.generic, var2);
|
| 326 | this.hurtTime = this.maxHurtTime = 10;
|
| 327 | }
|
| 328 | } else {
|
| 329 | this.setHealth(p_71150_1_);
|
| 330 | this.field_175169_bQ = true;
|
| 331 | }
|
| 332 | }
|
| 333 |
|
| 334 | /**
|
| 335 | * Adds a value to a statistic field.
|
| 336 | */
|
| 337 | public void addStat(StatBase p_71064_1_, int p_71064_2_) {
|
| 338 | if (p_71064_1_ != null) {
|
| 339 | if (p_71064_1_.isIndependent) {
|
| 340 | super.addStat(p_71064_1_, p_71064_2_);
|
| 341 | }
|
| 342 | }
|
| 343 | }
|
| 344 |
|
| 345 | /**
|
| 346 | * Sends the player's abilities to the server (if there is one).
|
| 347 | */
|
| 348 | public void sendPlayerAbilities() {
|
| 349 | this.sendQueue.addToSendQueue(new C13PacketPlayerAbilities(this.capabilities));
|
| 350 | }
|
| 351 |
|
| 352 | public boolean func_175144_cb() {
|
| 353 | return true;
|
| 354 | }
|
| 355 |
|
| 356 | protected void sendHorseJump() {
|
| 357 | this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.RIDING_JUMP,
|
| 358 | (int) (this.getHorseJumpPower() * 100.0F)));
|
| 359 | }
|
| 360 |
|
| 361 | public void func_175163_u() {
|
| 362 | this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.OPEN_INVENTORY));
|
| 363 | }
|
| 364 |
|
| 365 | public void func_175158_f(String p_175158_1_) {
|
| 366 | this.clientBrand = p_175158_1_;
|
| 367 | }
|
| 368 |
|
| 369 | public String getClientBrand() {
|
| 370 | return this.clientBrand;
|
| 371 | }
|
| 372 |
|
| 373 | public StatFileWriter getStatFileWriter() {
|
| 374 | return this.field_146108_bO;
|
| 375 | }
|
| 376 |
|
| 377 | public void addChatComponentMessage(IChatComponent p_146105_1_) {
|
| 378 | this.mc.ingameGUI.getChatGUI().printChatMessage(p_146105_1_);
|
| 379 | }
|
| 380 |
|
| 381 | protected boolean pushOutOfBlocks(double x, double y, double z) {
|
| 382 | EventPushBlock epb = (EventPushBlock) EventSystem.getInstance(EventPushBlock.class);
|
| 383 | epb.fire(true);
|
| 384 | if (this.noClip || epb.isCancelled()) {
|
| 385 | return false;
|
| 386 | } else {
|
| 387 | BlockPos var7 = new BlockPos(x, y, z);
|
| 388 | double var8 = x - (double) var7.getX();
|
| 389 | double var10 = z - (double) var7.getZ();
|
| 390 |
|
| 391 | if (!this.func_175162_d(var7)) {
|
| 392 | byte var12 = -1;
|
| 393 | double var13 = 9999.0D;
|
| 394 |
|
| 395 | if (this.func_175162_d(var7.offsetWest()) && var8 < var13) {
|
| 396 | var13 = var8;
|
| 397 | var12 = 0;
|
| 398 | }
|
| 399 |
|
| 400 | if (this.func_175162_d(var7.offsetEast()) && 1.0D - var8 < var13) {
|
| 401 | var13 = 1.0D - var8;
|
| 402 | var12 = 1;
|
| 403 | }
|
| 404 |
|
| 405 | if (this.func_175162_d(var7.offsetNorth()) && var10 < var13) {
|
| 406 | var13 = var10;
|
| 407 | var12 = 4;
|
| 408 | }
|
| 409 |
|
| 410 | if (this.func_175162_d(var7.offsetSouth()) && 1.0D - var10 < var13) {
|
| 411 | var13 = 1.0D - var10;
|
| 412 | var12 = 5;
|
| 413 | }
|
| 414 |
|
| 415 | float var15 = 0.1F;
|
| 416 |
|
| 417 | if (var12 == 0) {
|
| 418 | this.motionX = (double) (-var15);
|
| 419 | }
|
| 420 |
|
| 421 | if (var12 == 1) {
|
| 422 | this.motionX = (double) var15;
|
| 423 | }
|
| 424 |
|
| 425 | if (var12 == 4) {
|
| 426 | this.motionZ = (double) (-var15);
|
| 427 | }
|
| 428 |
|
| 429 | if (var12 == 5) {
|
| 430 | this.motionZ = (double) var15;
|
| 431 | }
|
| 432 | }
|
| 433 | epb.fire(false);
|
| 434 | return false;
|
| 435 | }
|
| 436 |
|
| 437 | }
|
| 438 |
|
| 439 | private boolean func_175162_d(BlockPos p_175162_1_) {
|
| 440 | return !this.worldObj.getBlockState(p_175162_1_).getBlock().isNormalCube()
|
| 441 | && !this.worldObj.getBlockState(p_175162_1_.offsetUp()).getBlock().isNormalCube();
|
| 442 | }
|
| 443 |
|
| 444 | /**
|
| 445 | * Set sprinting switch for Entity.
|
| 446 | */
|
| 447 | public void setSprinting(boolean sprinting) {
|
| 448 | super.setSprinting(sprinting);
|
| 449 | this.sprintingTicksLeft = sprinting ? 600 : 0;
|
| 450 | }
|
| 451 |
|
| 452 | /**
|
| 453 | * Sets the current XP, total XP, and level number.
|
| 454 | */
|
| 455 | public void setXPStats(float p_71152_1_, int p_71152_2_, int p_71152_3_) {
|
| 456 | this.experience = p_71152_1_;
|
| 457 | this.experienceTotal = p_71152_2_;
|
| 458 | this.experienceLevel = p_71152_3_;
|
| 459 | }
|
| 460 |
|
| 461 | /**
|
| 462 | * Notifies this sender of some sort of information. This is for messages
|
| 463 | * intended to display to the user. Used for typical output (like "you asked
|
| 464 | * for whether or not this game rule is set, so here's your answer" ),
|
| 465 | * warnings (like "I fetched this block for you by ID, but I'd like you to
|
| 466 | * know that every time you do this, I die a little inside "), and errors
|
| 467 | * (like "it's not called iron_pixacke, silly").
|
| 468 | */
|
| 469 | public void addChatMessage(IChatComponent message) {
|
| 470 | this.mc.ingameGUI.getChatGUI().printChatMessage(message);
|
| 471 | }
|
| 472 |
|
| 473 | /**
|
| 474 | * Returns true if the command sender is allowed to use the given command.
|
| 475 | */
|
| 476 | public boolean canCommandSenderUseCommand(int permissionLevel, String command) {
|
| 477 | return permissionLevel <= 0;
|
| 478 | }
|
| 479 |
|
| 480 | public BlockPos getPosition() {
|
| 481 | return new BlockPos(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D);
|
| 482 | }
|
| 483 |
|
| 484 | public void playSound(String name, float volume, float pitch) {
|
| 485 | this.worldObj.playSound(this.posX, this.posY, this.posZ, name, volume, pitch, false);
|
| 486 | }
|
| 487 |
|
| 488 | /**
|
| 489 | * Returns whether the entity is in a server world
|
| 490 | */
|
| 491 | public boolean isServerWorld() {
|
| 492 | return true;
|
| 493 | }
|
| 494 |
|
| 495 | public boolean isRidingHorse() {
|
| 496 | return this.ridingEntity != null && this.ridingEntity instanceof EntityHorse
|
| 497 | && ((EntityHorse) this.ridingEntity).isHorseSaddled();
|
| 498 | }
|
| 499 |
|
| 500 | public float getHorseJumpPower() {
|
| 501 | return this.horseJumpPower;
|
| 502 | }
|
| 503 |
|
| 504 | public void func_175141_a(TileEntitySign p_175141_1_) {
|
| 505 | this.mc.displayGuiScreen(new GuiEditSign(p_175141_1_));
|
| 506 | }
|
| 507 |
|
| 508 | public void func_146095_a(CommandBlockLogic p_146095_1_) {
|
| 509 | this.mc.displayGuiScreen(new GuiCommandBlock(p_146095_1_));
|
| 510 | }
|
| 511 |
|
| 512 | /**
|
| 513 | * Displays the GUI for interacting with a book.
|
| 514 | */
|
| 515 | public void displayGUIBook(ItemStack bookStack) {
|
| 516 | Item var2 = bookStack.getItem();
|
| 517 |
|
| 518 | if (var2 == Items.writable_book) {
|
| 519 | this.mc.displayGuiScreen(new GuiScreenBook(this, bookStack, true));
|
| 520 | }
|
| 521 | }
|
| 522 |
|
| 523 | /**
|
| 524 | * Displays the GUI for interacting with a chest inventory. Args:
|
| 525 | * chestInventory
|
| 526 | */
|
| 527 | public void displayGUIChest(IInventory chestInventory) {
|
| 528 | String var2 = chestInventory instanceof IInteractionObject ? ((IInteractionObject) chestInventory).getGuiID()
|
| 529 | : "minecraft:container";
|
| 530 |
|
| 531 | if ("minecraft:chest".equals(var2)) {
|
| 532 | this.mc.displayGuiScreen(new GuiChest(this.inventory, chestInventory));
|
| 533 | } else if ("minecraft:hopper".equals(var2)) {
|
| 534 | this.mc.displayGuiScreen(new GuiHopper(this.inventory, chestInventory));
|
| 535 | } else if ("minecraft:furnace".equals(var2)) {
|
| 536 | this.mc.displayGuiScreen(new GuiFurnace(this.inventory, chestInventory));
|
| 537 | } else if ("minecraft:brewing_stand".equals(var2)) {
|
| 538 | this.mc.displayGuiScreen(new GuiBrewingStand(this.inventory, chestInventory));
|
| 539 | } else if ("minecraft:beacon".equals(var2)) {
|
| 540 | this.mc.displayGuiScreen(new GuiBeacon(this.inventory, chestInventory));
|
| 541 | } else if (!"minecraft:dispenser".equals(var2) && !"minecraft:dropper".equals(var2)) {
|
| 542 | this.mc.displayGuiScreen(new GuiChest(this.inventory, chestInventory));
|
| 543 | } else {
|
| 544 | this.mc.displayGuiScreen(new GuiDispenser(this.inventory, chestInventory));
|
| 545 | }
|
| 546 | }
|
| 547 |
|
| 548 | public void displayGUIHorse(EntityHorse p_110298_1_, IInventory p_110298_2_) {
|
| 549 | this.mc.displayGuiScreen(new GuiScreenHorseInventory(this.inventory, p_110298_2_, p_110298_1_));
|
| 550 | }
|
| 551 |
|
| 552 | public void displayGui(IInteractionObject guiOwner) {
|
| 553 | String var2 = guiOwner.getGuiID();
|
| 554 |
|
| 555 | if ("minecraft:crafting_table".equals(var2)) {
|
| 556 | this.mc.displayGuiScreen(new GuiCrafting(this.inventory, this.worldObj));
|
| 557 | } else if ("minecraft:enchanting_table".equals(var2)) {
|
| 558 | this.mc.displayGuiScreen(new GuiEnchantment(this.inventory, this.worldObj, guiOwner));
|
| 559 | } else if ("minecraft:anvil".equals(var2)) {
|
| 560 | this.mc.displayGuiScreen(new GuiRepair(this.inventory, this.worldObj));
|
| 561 | }
|
| 562 | }
|
| 563 |
|
| 564 | public void displayVillagerTradeGui(IMerchant villager) {
|
| 565 | this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.worldObj));
|
| 566 | }
|
| 567 |
|
| 568 | /**
|
| 569 | * Called when the player performs a critical hit on the Entity. Args:
|
| 570 | * entity that was hit critically
|
| 571 | */
|
| 572 | public void onCriticalHit(Entity p_71009_1_) {
|
| 573 | this.mc.effectRenderer.func_178926_a(p_71009_1_, EnumParticleTypes.CRIT);
|
| 574 | }
|
| 575 |
|
| 576 | public void onEnchantmentCritical(Entity p_71047_1_) {
|
| 577 | this.mc.effectRenderer.func_178926_a(p_71047_1_, EnumParticleTypes.CRIT_MAGIC);
|
| 578 | }
|
| 579 |
|
| 580 | /**
|
| 581 | * Returns if this entity is sneaking.
|
| 582 | */
|
| 583 | public boolean isSneaking() {
|
| 584 | boolean var1 = this.movementInput != null ? this.movementInput.sneak : false;
|
| 585 | return var1 && !this.sleeping;
|
| 586 | }
|
| 587 |
|
| 588 | public void updateEntityActionState() {
|
| 589 | super.updateEntityActionState();
|
| 590 |
|
| 591 | if (this.func_175160_A()) {
|
| 592 | this.moveStrafing = this.movementInput.moveStrafe;
|
| 593 | this.moveForward = this.movementInput.moveForward;
|
| 594 | this.isJumping = this.movementInput.jump;
|
| 595 | this.prevRenderArmYaw = this.renderArmYaw;
|
| 596 | this.prevRenderArmPitch = this.renderArmPitch;
|
| 597 | this.renderArmPitch = (float) ((double) this.renderArmPitch
|
| 598 | + (double) (this.rotationPitch - this.renderArmPitch) * 0.5D);
|
| 599 | this.renderArmYaw = (float) ((double) this.renderArmYaw
|
| 600 | + (double) (this.rotationYaw - this.renderArmYaw) * 0.5D);
|
| 601 | }
|
| 602 | }
|
| 603 |
|
| 604 | protected boolean func_175160_A() {
|
| 605 | return this.mc.func_175606_aa() == this;
|
| 606 | }
|
| 607 |
|
| 608 | /**
|
| 609 | * Called frequently so the entity can update its state every tick as
|
| 610 | * required. For example, zombies and skeletons use this to react to
|
| 611 | * sunlight and start to burn.
|
| 612 | */
|
| 613 | public void onLivingUpdate() {
|
| 614 | if (this.sprintingTicksLeft > 0) {
|
| 615 | --this.sprintingTicksLeft;
|
| 616 |
|
| 617 | if (this.sprintingTicksLeft == 0) {
|
| 618 | this.setSprinting(false);
|
| 619 | }
|
| 620 | }
|
| 621 |
|
| 622 | if (this.sprintToggleTimer > 0) {
|
| 623 | --this.sprintToggleTimer;
|
| 624 | }
|
| 625 |
|
| 626 | this.prevTimeInPortal = this.timeInPortal;
|
| 627 |
|
| 628 | if (this.inPortal) {
|
| 629 | if (this.mc.currentScreen != null && !this.mc.currentScreen.doesGuiPauseGame()) {
|
| 630 | this.mc.displayGuiScreen((GuiScreen) null);
|
| 631 | }
|
| 632 |
|
| 633 | if (this.timeInPortal == 0.0F) {
|
| 634 | this.mc.getSoundHandler().playSound(PositionedSoundRecord.createPositionedSoundRecord(
|
| 635 | new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F));
|
| 636 | }
|
| 637 |
|
| 638 | this.timeInPortal += 0.0125F;
|
| 639 |
|
| 640 | if (this.timeInPortal >= 1.0F) {
|
| 641 | this.timeInPortal = 1.0F;
|
| 642 | }
|
| 643 |
|
| 644 | this.inPortal = false;
|
| 645 | } else if (this.isPotionActive(Potion.confusion)
|
| 646 | && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) {
|
| 647 | this.timeInPortal += 0.006666667F;
|
| 648 |
|
| 649 | if (this.timeInPortal > 1.0F) {
|
| 650 | this.timeInPortal = 1.0F;
|
| 651 | }
|
| 652 | } else {
|
| 653 | if (this.timeInPortal > 0.0F) {
|
| 654 | this.timeInPortal -= 0.05F;
|
| 655 | }
|
| 656 |
|
| 657 | if (this.timeInPortal < 0.0F) {
|
| 658 | this.timeInPortal = 0.0F;
|
| 659 | }
|
| 660 | }
|
| 661 |
|
| 662 | if (this.timeUntilPortal > 0) {
|
| 663 | --this.timeUntilPortal;
|
| 664 | }
|
| 665 |
|
| 666 | boolean var1 = this.movementInput.jump;
|
| 667 | boolean var2 = this.movementInput.sneak;
|
| 668 | float var3 = 0.8F;
|
| 669 | boolean var4 = this.movementInput.moveForward >= var3;
|
| 670 | this.movementInput.updatePlayerMoveState();
|
| 671 |
|
| 672 | if (this.isUsingItem() && !this.isRiding()) {
|
| 673 | if(!Client.getModuleManager().isEnabled(NoSlowdown.class)){
|
| 674 | this.movementInput.moveStrafe *= 0.2F;
|
| 675 | this.movementInput.moveForward *= 0.2F;
|
| 676 | this.sprintToggleTimer = 0;
|
| 677 | }else{
|
| 678 | Module noSlowDown = Client.getModuleManager().get(NoSlowdown.class);
|
| 679 | if (noSlowDown.getSetting(NoSlowdown.MODE) != null && ((Options) noSlowDown.getSetting(NoSlowdown.MODE).getValue()).getSelected().equals("AAC")) {
|
| 680 | if(mc.thePlayer.inventory.getCurrentItem() != null && (!(mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword))){
|
| 681 | if(!(mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemBow)){
|
| 682 | double slow = (71-mc.thePlayer.itemInUseCount) * 0.008;
|
| 683 |
|
| 684 |
|
| 685 | this.movementInput.moveStrafe *= slow;
|
| 686 | this.movementInput.moveForward *= slow;
|
| 687 | this.sprintToggleTimer = 0;
|
| 688 | }else{
|
| 689 | this.movementInput.moveStrafe *= 0.5f;
|
| 690 | this.movementInput.moveForward *= 0.5f;
|
| 691 | this.sprintToggleTimer = 0;
|
| 692 | }
|
| 693 | }
|
| 694 | }
|
| 695 | }
|
| 696 |
|
| 697 | }
|
| 698 | this.pushOutOfBlocks(this.posX - (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D,
|
| 699 | this.posZ + (double) this.width * 0.35D);
|
| 700 | this.pushOutOfBlocks(this.posX - (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D,
|
| 701 | this.posZ - (double) this.width * 0.35D);
|
| 702 | this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D,
|
| 703 | this.posZ - (double) this.width * 0.35D);
|
| 704 | this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D,
|
| 705 | this.posZ + (double) this.width * 0.35D);
|
| 706 | boolean var5 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying;
|
| 707 |
|
| 708 | if (this.onGround && !var2 && !var4 && this.movementInput.moveForward >= var3 && !this.isSprinting() && var5
|
| 709 | && !this.isUsingItem() && !this.isPotionActive(Potion.blindness)) {
|
| 710 | if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.getIsKeyPressed()) {
|
| 711 | this.sprintToggleTimer = 7;
|
| 712 | } else {
|
| 713 | this.setSprinting(true);
|
| 714 | }
|
| 715 | }
|
| 716 |
|
| 717 | if (!this.isSprinting() && this.movementInput.moveForward >= var3 && var5 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.getIsKeyPressed()) {
|
| 718 | this.setSprinting(true);
|
| 719 | }
|
| 720 |
|
| 721 | if (this.isSprinting() && (this.movementInput.moveForward < var3 || this.isCollidedHorizontally || !var5)) {
|
| 722 | this.setSprinting(false);
|
| 723 | }
|
| 724 |
|
| 725 | if (this.capabilities.allowFlying) {
|
| 726 | if (this.mc.playerController.isSpectatorMode()) {
|
| 727 | if (!this.capabilities.isFlying) {
|
| 728 | this.capabilities.isFlying = true;
|
| 729 | this.sendPlayerAbilities();
|
| 730 | }
|
| 731 | } else if (!var1 && this.movementInput.jump) {
|
| 732 | if (this.flyToggleTimer == 0) {
|
| 733 | this.flyToggleTimer = 7;
|
| 734 | } else {
|
| 735 | this.capabilities.isFlying = !this.capabilities.isFlying;
|
| 736 | this.sendPlayerAbilities();
|
| 737 | this.flyToggleTimer = 0;
|
| 738 | }
|
| 739 | }
|
| 740 | }
|
| 741 |
|
| 742 | if (this.capabilities.isFlying && this.func_175160_A()) {
|
| 743 | if (this.movementInput.sneak) {
|
| 744 | this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F);
|
| 745 | }
|
| 746 |
|
| 747 | if (this.movementInput.jump) {
|
| 748 | this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F);
|
| 749 | }
|
| 750 | }
|
| 751 |
|
| 752 | if (this.isRidingHorse()) {
|
| 753 | if (this.horseJumpPowerCounter < 0) {
|
| 754 | ++this.horseJumpPowerCounter;
|
| 755 |
|
| 756 | if (this.horseJumpPowerCounter == 0) {
|
| 757 | this.horseJumpPower = 0.0F;
|
| 758 | }
|
| 759 | }
|
| 760 |
|
| 761 | if (var1 && !this.movementInput.jump) {
|
| 762 | this.horseJumpPowerCounter = -10;
|
| 763 | this.sendHorseJump();
|
| 764 | } else if (!var1 && this.movementInput.jump) {
|
| 765 | this.horseJumpPowerCounter = 0;
|
| 766 | this.horseJumpPower = 0.0F;
|
| 767 | } else if (var1) {
|
| 768 | ++this.horseJumpPowerCounter;
|
| 769 |
|
| 770 | if (this.horseJumpPowerCounter < 10) {
|
| 771 | this.horseJumpPower = (float) this.horseJumpPowerCounter * 0.1F;
|
| 772 | } else {
|
| 773 | this.horseJumpPower = 0.8F + 2.0F / (float) (this.horseJumpPowerCounter - 9) * 0.1F;
|
| 774 | }
|
| 775 | }
|
| 776 | } else {
|
| 777 | this.horseJumpPower = 0.0F;
|
| 778 | }
|
| 779 |
|
| 780 | super.onLivingUpdate();
|
| 781 |
|
| 782 | if (this.onGround && this.capabilities.isFlying && !this.mc.playerController.isSpectatorMode()) {
|
| 783 | this.capabilities.isFlying = false;
|
| 784 | this.sendPlayerAbilities();
|
| 785 | }
|
| 786 | }
|
| 787 |
|
| 788 | public float getDirection() {
|
| 789 | float var1 = this.rotationYaw;
|
| 790 |
|
| 791 | if (this.moveForward < 0.0F) {
|
| 792 | var1 += 180;
|
| 793 | }
|
| 794 |
|
| 795 | float forward = 1;
|
| 796 |
|
| 797 | if (this.moveForward < 0) {
|
| 798 | forward = -0.5f;
|
| 799 | } else if (this.moveForward > 0) {
|
| 800 | forward = 0.5f;
|
| 801 | } else {
|
| 802 | forward = 1;
|
| 803 | }
|
| 804 |
|
| 805 | if (this.moveStrafing > 0.0F) {
|
| 806 | var1 -= 90.0F * forward;
|
| 807 | }
|
| 808 |
|
| 809 | if (this.moveStrafing < 0.0F) {
|
| 810 | var1 += 90.0F * forward;
|
| 811 | }
|
| 812 |
|
| 813 | var1 *= 0.017453292F;
|
| 814 |
|
| 815 | return var1;
|
| 816 | }
|
| 817 | }
|