ModCoderPack / MCPBot-Issues

Issue tracker for MCPBot (https://bitbucket.org/ProfMobius/mcpbot) and MCP mappings.
http://mcpbot.bspk.rs
80 stars 11 forks source link

func_72685_d: PlayerChunkMap.updateMountedMovingPlayer() misnamed and misdocumented #288

Closed xcube16 closed 7 years ago

xcube16 commented 8 years ago

Minecraft version: 1.10.2 (It is also of note that the code presented has Forge patches applied)

PlayerChunkMap.updateMountedMovingPlayer() is not a special case for players riding other entities. A debugger shows that it is called when ever a player moves, weather or not they are riding an entity!

PlayerCubeMap.updateMountedMovingPlayer() is called form func_72358_d: PlayerList.serverUpdateMountedMovingPlayer() that is also misnamed.

PlayerList.serverUpdateMountedMovingPlayer() is called in 4 places

        Entity entity = this.getSpectatingEntity();

        if (entity != this)
        {
            if (entity.isEntityAlive())
            {
                this.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
                this.mcServer.getPlayerList().serverUpdateMountedMovingPlayer(this);

                if (this.isSneaking())
                {
                    this.setSpectatingEntity(this);
                }
            }
            else
            {
                this.setSpectatingEntity(this);
            }
        }

EntityPlayerMP.onUpdate() calls the method when they are spectating an another entity

                    if (this.playerEntity.isRiding())
                    {
                        this.playerEntity.setPositionAndRotation(this.playerEntity.posX, this.playerEntity.posY, this.playerEntity.posZ, packetIn.getYaw(this.playerEntity.rotationYaw), packetIn.getPitch(this.playerEntity.rotationPitch));
                        this.serverController.getPlayerList().serverUpdateMountedMovingPlayer(this.playerEntity);
                    }
// ...

NetHendlerPlayServer.processPlayer() calls the method in a special case for riding an entity This may be where the mistake was made

// ...
                        this.floating = d12 >= -0.03125D;
                        this.floating &= !this.serverController.isFlightAllowed() && !this.playerEntity.capabilities.allowFlying;
                        this.floating &= !this.playerEntity.isPotionActive(MobEffects.LEVITATION) && !this.playerEntity.isElytraFlying() && !worldserver.checkBlockCollision(this.playerEntity.getEntityBoundingBox().expandXyz(0.0625D).addCoord(0.0D, -0.55D, 0.0D));
                        this.playerEntity.onGround = packetIn.isOnGround();
                        this.serverController.getPlayerList().serverUpdateMountedMovingPlayer(this.playerEntity);
                        this.playerEntity.handleFalling(this.playerEntity.posY - d3, packetIn.isOnGround());
                        this.lastGoodX = this.playerEntity.posX;
                        this.lastGoodY = this.playerEntity.posY;
                        this.lastGoodZ = this.playerEntity.posZ;

In the other half of that if statement we find THE SAME CALL making this not a special case!

In conclusion:

func_72685_d: PlayerChunkMap.updateMountedMovingPlayer() should be changed to updateMovingPlayer() and the javadoc should read something like "update chunks around a player that moved"

func_72358_d: PlayerList.serverUpdateMountedMovingPlayer() should also be changed to serverUpdateMovingPlayer() and the javadoc should be something like "using player's dimension, update the chunks around them"

bspkrs commented 7 years ago

done.