PlayerControllerMP .java

net.minecraft.client.multiplayer.PlayerControllerMP (class, 638 lines): members: isPlayerRightClickingOnEntity, interactWithEntitySendPacket, flipPlayer.

net.minecraft.client.multiplayerclass638 linesclient21.7 KB

API Surface (31)

void clickBlockCreative(Minecraft mcIn, PlayerControllerMP playerController, BlockPos pos, EnumFacing facing)
void setPlayerCapabilities(EntityPlayer player)
boolean isSpectator()
void setGameType(WorldSettings.GameType type)
void flipPlayer(EntityPlayer playerIn)
boolean shouldDrawHUD()
boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side)
boolean clickBlock(BlockPos loc, EnumFacing face)
void resetBlockRemoving()
boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
float getBlockReachDistance()
void updateController()
boolean onPlayerRightClick(EntityPlayerSP player, WorldClient worldIn, ItemStack heldStack, BlockPos hitPos, EnumFacing side, Vec3 hitVec)
boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn)
EntityPlayerSP func_178892_a(World worldIn, StatFileWriter statWriter)
void attackEntity(EntityPlayer playerIn, Entity targetEntity)
boolean interactWithEntitySendPacket(EntityPlayer playerIn, Entity targetEntity)
boolean isPlayerRightClickingOnEntity(EntityPlayer player, Entity entityIn, MovingObjectPosition movingObject)
ItemStack windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityPlayer playerIn)
void sendEnchantPacket(int windowID, int button)
void sendSlotPacket(ItemStack itemStackIn, int slotId)
void sendPacketDropItem(ItemStack itemStackIn)
void onStoppedUsingItem(EntityPlayer playerIn)
boolean gameIsSurvivalOrAdventure()
boolean isNotCreative()
boolean isInCreativeMode()
boolean extendedReach()
boolean isRidingHorse()
boolean isSpectatorMode()
WorldSettings.GameType getCurrentGameType()
boolean getIsHittingBlock()

Fields & Constants (10)

mc
netClientHandler
currentBlock
currentItemHittingBlock
curBlockDamageMP
stepSoundTickCounter
blockHitDelay
isHittingBlock
currentGameType
currentPlayerItem

Full Source

PlayerControllerMP.java638 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.multiplayer;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.material.Material;
5
import net.minecraft.block.state.IBlockState;
6
import net.minecraft.client.Minecraft;
7
import net.minecraft.client.audio.PositionedSoundRecord;
8
import net.minecraft.client.entity.EntityPlayerSP;
9
import net.minecraft.client.network.NetHandlerPlayClient;
10
import net.minecraft.entity.Entity;
11
import net.minecraft.entity.passive.EntityHorse;
12
import net.minecraft.entity.player.EntityPlayer;
13
import net.minecraft.item.ItemBlock;
14
import net.minecraft.item.ItemStack;
15
import net.minecraft.item.ItemSword;
16
import net.minecraft.network.play.client.C02PacketUseEntity;
17
import net.minecraft.network.play.client.C07PacketPlayerDigging;
18
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
19
import net.minecraft.network.play.client.C09PacketHeldItemChange;
20
import net.minecraft.network.play.client.C0EPacketClickWindow;
21
import net.minecraft.network.play.client.C10PacketCreativeInventoryAction;
22
import net.minecraft.network.play.client.C11PacketEnchantItem;
23
import net.minecraft.stats.StatFileWriter;
24
import net.minecraft.util.BlockPos;
25
import net.minecraft.util.EnumFacing;
26
import net.minecraft.util.MovingObjectPosition;
27
import net.minecraft.util.ResourceLocation;
28
import net.minecraft.util.Vec3;
29
import net.minecraft.world.World;
30
import net.minecraft.world.WorldSettings;
31
32
public class PlayerControllerMP
33
{
34
    /** The Minecraft instance. */
35
    private final Minecraft mc;
36
    private final NetHandlerPlayClient netClientHandler;
37
    private BlockPos currentBlock = new BlockPos(-1, -1, -1);
38
39
    /** The Item currently being used to destroy a block */
40
    private ItemStack currentItemHittingBlock;
41
42
    /** Current block damage (MP) */
43
    private float curBlockDamageMP;
44
45
    /**
46
     * Tick counter, when it hits 4 it resets back to 0 and plays the step sound
47
     */
48
    private float stepSoundTickCounter;
49
50
    /**
51
     * Delays the first damage on the block after the first click on the block
52
     */
53
    private int blockHitDelay;
54
55
    /** Tells if the player is hitting a block */
56
    private boolean isHittingBlock;
57
58
    /** Current game type for the player */
59
    private WorldSettings.GameType currentGameType = WorldSettings.GameType.SURVIVAL;
60
61
    /** Index of the current item held by the player in the inventory hotbar */
62
    private int currentPlayerItem;
63
64
    public PlayerControllerMP(Minecraft mcIn, NetHandlerPlayClient netHandler)
65
    {
66
        this.mc = mcIn;
67
        this.netClientHandler = netHandler;
68
    }
69
70
    public static void clickBlockCreative(Minecraft mcIn, PlayerControllerMP playerController, BlockPos pos, EnumFacing facing)
71
    {
72
        if (!mcIn.theWorld.extinguishFire(mcIn.thePlayer, pos, facing))
73
        {
74
            playerController.onPlayerDestroyBlock(pos, facing);
75
        }
76
    }
77
78
    /**
79
     * Sets player capabilities depending on current gametype. params: player
80
     *  
81
     * @param player The player's instance
82
     */
83
    public void setPlayerCapabilities(EntityPlayer player)
84
    {
85
        this.currentGameType.configurePlayerCapabilities(player.capabilities);
86
    }
87
88
    /**
89
     * None
90
     */
91
    public boolean isSpectator()
92
    {
93
        return this.currentGameType == WorldSettings.GameType.SPECTATOR;
94
    }
95
96
    /**
97
     * Sets the game type for the player.
98
     *  
99
     * @param type The GameType to set
100
     */
101
    public void setGameType(WorldSettings.GameType type)
102
    {
103
        this.currentGameType = type;
104
        this.currentGameType.configurePlayerCapabilities(this.mc.thePlayer.capabilities);
105
    }
106
107
    /**
108
     * Flips the player around.
109
     */
110
    public void flipPlayer(EntityPlayer playerIn)
111
    {
112
        playerIn.rotationYaw = -180.0F;
113
    }
114
115
    public boolean shouldDrawHUD()
116
    {
117
        return this.currentGameType.isSurvivalOrAdventure();
118
    }
119
120
    /**
121
     * Called when a player completes the destruction of a block
122
     */
123
    public boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side)
124
    {
125
        if (this.currentGameType.isAdventure())
126
        {
127
            if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
128
            {
129
                return false;
130
            }
131
132
            if (!this.mc.thePlayer.isAllowEdit())
133
            {
134
                Block block = this.mc.theWorld.getBlockState(pos).getBlock();
135
                ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();
136
137
                if (itemstack == null)
138
                {
139
                    return false;
140
                }
141
142
                if (!itemstack.canDestroy(block))
143
                {
144
                    return false;
145
                }
146
            }
147
        }
148
149
        if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword)
150
        {
151
            return false;
152
        }
153
        else
154
        {
155
            World world = this.mc.theWorld;
156
            IBlockState iblockstate = world.getBlockState(pos);
157
            Block block1 = iblockstate.getBlock();
158
159
            if (block1.getMaterial() == Material.air)
160
            {
161
                return false;
162
            }
163
            else
164
            {
165
                world.playAuxSFX(2001, pos, Block.getStateId(iblockstate));
166
                boolean flag = world.setBlockToAir(pos);
167
168
                if (flag)
169
                {
170
                    block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
171
                }
172
173
                this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());
174
175
                if (!this.currentGameType.isCreative())
176
                {
177
                    ItemStack itemstack1 = this.mc.thePlayer.getCurrentEquippedItem();
178
179
                    if (itemstack1 != null)
180
                    {
181
                        itemstack1.onBlockDestroyed(world, block1, pos, this.mc.thePlayer);
182
183
                        if (itemstack1.stackSize == 0)
184
                        {
185
                            this.mc.thePlayer.destroyCurrentEquippedItem();
186
                        }
187
                    }
188
                }
189
190
                return flag;
191
            }
192
        }
193
    }
194
195
    /**
196
     * Called when the player is hitting a block with an item.
197
     */
198
    public boolean clickBlock(BlockPos loc, EnumFacing face)
199
    {
200
        if (this.currentGameType.isAdventure())
201
        {
202
            if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
203
            {
204
                return false;
205
            }
206
207
            if (!this.mc.thePlayer.isAllowEdit())
208
            {
209
                Block block = this.mc.theWorld.getBlockState(loc).getBlock();
210
                ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();
211
212
                if (itemstack == null)
213
                {
214
                    return false;
215
                }
216
217
                if (!itemstack.canDestroy(block))
218
                {
219
                    return false;
220
                }
221
            }
222
        }
223
224
        if (!this.mc.theWorld.getWorldBorder().contains(loc))
225
        {
226
            return false;
227
        }
228
        else
229
        {
230
            if (this.currentGameType.isCreative())
231
            {
232
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
233
                clickBlockCreative(this.mc, this, loc, face);
234
                this.blockHitDelay = 5;
235
            }
236
            else if (!this.isHittingBlock || !this.isHittingPosition(loc))
237
            {
238
                if (this.isHittingBlock)
239
                {
240
                    this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, face));
241
                }
242
243
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
244
                Block block1 = this.mc.theWorld.getBlockState(loc).getBlock();
245
                boolean flag = block1.getMaterial() != Material.air;
246
247
                if (flag && this.curBlockDamageMP == 0.0F)
248
                {
249
                    block1.onBlockClicked(this.mc.theWorld, loc, this.mc.thePlayer);
250
                }
251
252
                if (flag && block1.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, loc) >= 1.0F)
253
                {
254
                    this.onPlayerDestroyBlock(loc, face);
255
                }
256
                else
257
                {
258
                    this.isHittingBlock = true;
259
                    this.currentBlock = loc;
260
                    this.currentItemHittingBlock = this.mc.thePlayer.getHeldItem();
261
                    this.curBlockDamageMP = 0.0F;
262
                    this.stepSoundTickCounter = 0.0F;
263
                    this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
264
                }
265
            }
266
267
            return true;
268
        }
269
    }
270
271
    /**
272
     * Resets current block damage and isHittingBlock
273
     */
274
    public void resetBlockRemoving()
275
    {
276
        if (this.isHittingBlock)
277
        {
278
            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, EnumFacing.DOWN));
279
            this.isHittingBlock = false;
280
            this.curBlockDamageMP = 0.0F;
281
            this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, -1);
282
        }
283
    }
284
285
    public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
286
    {
287
        this.syncCurrentPlayItem();
288
289
        if (this.blockHitDelay > 0)
290
        {
291
            --this.blockHitDelay;
292
            return true;
293
        }
294
        else if (this.currentGameType.isCreative() && this.mc.theWorld.getWorldBorder().contains(posBlock))
295
        {
296
            this.blockHitDelay = 5;
297
            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
298
            clickBlockCreative(this.mc, this, posBlock, directionFacing);
299
            return true;
300
        }
301
        else if (this.isHittingPosition(posBlock))
302
        {
303
            Block block = this.mc.theWorld.getBlockState(posBlock).getBlock();
304
305
            if (block.getMaterial() == Material.air)
306
            {
307
                this.isHittingBlock = false;
308
                return false;
309
            }
310
            else
311
            {
312
                this.curBlockDamageMP += block.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, posBlock);
313
314
                if (this.stepSoundTickCounter % 4.0F == 0.0F)
315
                {
316
                    this.mc.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(block.stepSound.getStepSound()), (block.stepSound.getVolume() + 1.0F) / 8.0F, block.stepSound.getFrequency() * 0.5F, (float)posBlock.getX() + 0.5F, (float)posBlock.getY() + 0.5F, (float)posBlock.getZ() + 0.5F));
317
                }
318
319
                ++this.stepSoundTickCounter;
320
321
                if (this.curBlockDamageMP >= 1.0F)
322
                {
323
                    this.isHittingBlock = false;
324
                    this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
325
                    this.onPlayerDestroyBlock(posBlock, directionFacing);
326
                    this.curBlockDamageMP = 0.0F;
327
                    this.stepSoundTickCounter = 0.0F;
328
                    this.blockHitDelay = 5;
329
                }
330
331
                this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
332
                return true;
333
            }
334
        }
335
        else
336
        {
337
            return this.clickBlock(posBlock, directionFacing);
338
        }
339
    }
340
341
    /**
342
     * player reach distance = 4F
343
     */
344
    public float getBlockReachDistance()
345
    {
346
        return this.currentGameType.isCreative() ? 5.0F : 4.5F;
347
    }
348
349
    public void updateController()
350
    {
351
        this.syncCurrentPlayItem();
352
353
        if (this.netClientHandler.getNetworkManager().isChannelOpen())
354
        {
355
            this.netClientHandler.getNetworkManager().processReceivedPackets();
356
        }
357
        else
358
        {
359
            this.netClientHandler.getNetworkManager().checkDisconnected();
360
        }
361
    }
362
363
    private boolean isHittingPosition(BlockPos pos)
364
    {
365
        ItemStack itemstack = this.mc.thePlayer.getHeldItem();
366
        boolean flag = this.currentItemHittingBlock == null && itemstack == null;
367
368
        if (this.currentItemHittingBlock != null && itemstack != null)
369
        {
370
            flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
371
        }
372
373
        return pos.equals(this.currentBlock) && flag;
374
    }
375
376
    /**
377
     * Syncs the current player item with the server
378
     */
379
    private void syncCurrentPlayItem()
380
    {
381
        int i = this.mc.thePlayer.inventory.currentItem;
382
383
        if (i != this.currentPlayerItem)
384
        {
385
            this.currentPlayerItem = i;
386
            this.netClientHandler.addToSendQueue(new C09PacketHeldItemChange(this.currentPlayerItem));
387
        }
388
    }
389
390
    public boolean onPlayerRightClick(EntityPlayerSP player, WorldClient worldIn, ItemStack heldStack, BlockPos hitPos, EnumFacing side, Vec3 hitVec)
391
    {
392
        this.syncCurrentPlayItem();
393
        float f = (float)(hitVec.xCoord - (double)hitPos.getX());
394
        float f1 = (float)(hitVec.yCoord - (double)hitPos.getY());
395
        float f2 = (float)(hitVec.zCoord - (double)hitPos.getZ());
396
        boolean flag = false;
397
398
        if (!this.mc.theWorld.getWorldBorder().contains(hitPos))
399
        {
400
            return false;
401
        }
402
        else
403
        {
404
            if (this.currentGameType != WorldSettings.GameType.SPECTATOR)
405
            {
406
                IBlockState iblockstate = worldIn.getBlockState(hitPos);
407
408
                if ((!player.isSneaking() || player.getHeldItem() == null) && iblockstate.getBlock().onBlockActivated(worldIn, hitPos, iblockstate, player, side, f, f1, f2))
409
                {
410
                    flag = true;
411
                }
412
413
                if (!flag && heldStack != null && heldStack.getItem() instanceof ItemBlock)
414
                {
415
                    ItemBlock itemblock = (ItemBlock)heldStack.getItem();
416
417
                    if (!itemblock.canPlaceBlockOnSide(worldIn, hitPos, side, player, heldStack))
418
                    {
419
                        return false;
420
                    }
421
                }
422
            }
423
424
            this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(hitPos, side.getIndex(), player.inventory.getCurrentItem(), f, f1, f2));
425
426
            if (!flag && this.currentGameType != WorldSettings.GameType.SPECTATOR)
427
            {
428
                if (heldStack == null)
429
                {
430
                    return false;
431
                }
432
                else if (this.currentGameType.isCreative())
433
                {
434
                    int i = heldStack.getMetadata();
435
                    int j = heldStack.stackSize;
436
                    boolean flag1 = heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
437
                    heldStack.setItemDamage(i);
438
                    heldStack.stackSize = j;
439
                    return flag1;
440
                }
441
                else
442
                {
443
                    return heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
444
                }
445
            }
446
            else
447
            {
448
                return true;
449
            }
450
        }
451
    }
452
453
    /**
454
     * Notifies the server of things like consuming food, etc...
455
     */
456
    public boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn)
457
    {
458
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
459
        {
460
            return false;
461
        }
462
        else
463
        {
464
            this.syncCurrentPlayItem();
465
            this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(playerIn.inventory.getCurrentItem()));
466
            int i = itemStackIn.stackSize;
467
            ItemStack itemstack = itemStackIn.useItemRightClick(worldIn, playerIn);
468
469
            if (itemstack != itemStackIn || itemstack != null && itemstack.stackSize != i)
470
            {
471
                playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = itemstack;
472
473
                if (itemstack.stackSize == 0)
474
                {
475
                    playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
476
                }
477
478
                return true;
479
            }
480
            else
481
            {
482
                return false;
483
            }
484
        }
485
    }
486
487
    public EntityPlayerSP func_178892_a(World worldIn, StatFileWriter statWriter)
488
    {
489
        return new EntityPlayerSP(this.mc, worldIn, this.netClientHandler, statWriter);
490
    }
491
492
    /**
493
     * Attacks an entity
494
     */
495
    public void attackEntity(EntityPlayer playerIn, Entity targetEntity)
496
    {
497
        this.syncCurrentPlayItem();
498
        this.netClientHandler.addToSendQueue(new C02PacketUseEntity(targetEntity, C02PacketUseEntity.Action.ATTACK));
499
500
        if (this.currentGameType != WorldSettings.GameType.SPECTATOR)
501
        {
502
            playerIn.attackTargetEntityWithCurrentItem(targetEntity);
503
        }
504
    }
505
506
    /**
507
     * Send packet to server - player is interacting with another entity (left click)
508
     */
509
    public boolean interactWithEntitySendPacket(EntityPlayer playerIn, Entity targetEntity)
510
    {
511
        this.syncCurrentPlayItem();
512
        this.netClientHandler.addToSendQueue(new C02PacketUseEntity(targetEntity, C02PacketUseEntity.Action.INTERACT));
513
        return this.currentGameType != WorldSettings.GameType.SPECTATOR && playerIn.interactWith(targetEntity);
514
    }
515
516
    /**
517
     * Return true when the player rightclick on an entity
518
     *  
519
     * @param player The player's instance
520
     * @param entityIn The entity clicked
521
     * @param movingObject The object clicked
522
     */
523
    public boolean isPlayerRightClickingOnEntity(EntityPlayer player, Entity entityIn, MovingObjectPosition movingObject)
524
    {
525
        this.syncCurrentPlayItem();
526
        Vec3 vec3 = new Vec3(movingObject.hitVec.xCoord - entityIn.posX, movingObject.hitVec.yCoord - entityIn.posY, movingObject.hitVec.zCoord - entityIn.posZ);
527
        this.netClientHandler.addToSendQueue(new C02PacketUseEntity(entityIn, vec3));
528
        return this.currentGameType != WorldSettings.GameType.SPECTATOR && entityIn.interactAt(player, vec3);
529
    }
530
531
    /**
532
     * Handles slot clicks sends a packet to the server.
533
     */
534
    public ItemStack windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityPlayer playerIn)
535
    {
536
        short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
537
        ItemStack itemstack = playerIn.openContainer.slotClick(slotId, mouseButtonClicked, mode, playerIn);
538
        this.netClientHandler.addToSendQueue(new C0EPacketClickWindow(windowId, slotId, mouseButtonClicked, mode, itemstack, short1));
539
        return itemstack;
540
    }
541
542
    /**
543
     * GuiEnchantment uses this during multiplayer to tell PlayerControllerMP to send a packet indicating the
544
     * enchantment action the player has taken.
545
     *  
546
     * @param windowID The ID of the current window
547
     * @param button The button id (enchantment selected)
548
     */
549
    public void sendEnchantPacket(int windowID, int button)
550
    {
551
        this.netClientHandler.addToSendQueue(new C11PacketEnchantItem(windowID, button));
552
    }
553
554
    /**
555
     * Used in PlayerControllerMP to update the server with an ItemStack in a slot.
556
     */
557
    public void sendSlotPacket(ItemStack itemStackIn, int slotId)
558
    {
559
        if (this.currentGameType.isCreative())
560
        {
561
            this.netClientHandler.addToSendQueue(new C10PacketCreativeInventoryAction(slotId, itemStackIn));
562
        }
563
    }
564
565
    /**
566
     * Sends a Packet107 to the server to drop the item on the ground
567
     */
568
    public void sendPacketDropItem(ItemStack itemStackIn)
569
    {
570
        if (this.currentGameType.isCreative() && itemStackIn != null)
571
        {
572
            this.netClientHandler.addToSendQueue(new C10PacketCreativeInventoryAction(-1, itemStackIn));
573
        }
574
    }
575
576
    public void onStoppedUsingItem(EntityPlayer playerIn)
577
    {
578
        this.syncCurrentPlayItem();
579
        this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
580
        playerIn.stopUsingItem();
581
    }
582
583
    public boolean gameIsSurvivalOrAdventure()
584
    {
585
        return this.currentGameType.isSurvivalOrAdventure();
586
    }
587
588
    /**
589
     * Checks if the player is not creative, used for checking if it should break a block instantly
590
     */
591
    public boolean isNotCreative()
592
    {
593
        return !this.currentGameType.isCreative();
594
    }
595
596
    /**
597
     * returns true if player is in creative mode
598
     */
599
    public boolean isInCreativeMode()
600
    {
601
        return this.currentGameType.isCreative();
602
    }
603
604
    /**
605
     * true for hitting entities far away.
606
     */
607
    public boolean extendedReach()
608
    {
609
        return this.currentGameType.isCreative();
610
    }
611
612
    /**
613
     * Checks if the player is riding a horse, used to chose the GUI to open
614
     */
615
    public boolean isRidingHorse()
616
    {
617
        return this.mc.thePlayer.isRiding() && this.mc.thePlayer.ridingEntity instanceof EntityHorse;
618
    }
619
620
    public boolean isSpectatorMode()
621
    {
622
        return this.currentGameType == WorldSettings.GameType.SPECTATOR;
623
    }
624
625
    public WorldSettings.GameType getCurrentGameType()
626
    {
627
        return this.currentGameType;
628
    }
629
630
    /**
631
     * Return isHittingBlock
632
     */
633
    public boolean getIsHittingBlock()
634
    {
635
        return this.isHittingBlock;
636
    }
637
}
638

Deobfuscated MCP 1.8.9 source of PlayerControllerMP from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/multiplayer/PlayerControllerMP.java), stored verbatim.