cleanup player controller comments

This commit is contained in:
Sen 2025-05-25 15:25:38 +02:00
parent d41ad4db01
commit 2cf7f0036d

View file

@ -43,77 +43,8 @@ public class PlayerController
this.netClientHandler = netHandler;
}
// public static void clickBlockCreative(Game gmIn, PlayerController playerController, BlockPos pos, Facing facing)
// {
// if (!gmIn.theWorld.extinguishFire(gmIn.thePlayer, pos, facing))
// {
// playerController.onPlayerDestroyBlock(pos, facing);
// }
// }
// public void setPlayerCapabilities()
// {
// this.gm.thePlayer.flying &= this.gm.thePlayer.hasEffect(Potion.flying) || this.gm.thePlayer.noclip;
// }
// public boolean isNoclip()
// {
// return this.gm.thePlayer.capabilities.noClip;
// }
// public void setNoclip(boolean noclip)
// {
// this.noclip = noclip;
// }
// public void setCheat(boolean cheat)
// {
// this.cheat = cheat;
// this.setPlayerCapabilities();
// }
// public boolean shouldDrawHUD()
// {
// return !this.creative;
// }
/**
* Called when a player completes the destruction of a block
*/
public boolean onPlayerDestroyBlock(BlockPos pos, Facing side)
{
// if (this.gamemode.isAdventure())
// {
// if (this.gamemode == Gamemode.SPECTATOR)
// {
// return false;
// }
// if (!this.gm.thePlayer.isAllowEdit())
// {
// Block block = this.gm.theWorld.getBlockState(pos).getBlock();
// ItemStack itemstack = this.gm.thePlayer.getCurrentEquippedItem();
//
// if (itemstack == null)
// {
// return false;
// }
//
// if (!itemstack.canDestroy(block))
// {
// return false;
// }
// }
// }
// if (this.gm.thePlayer.getHeldItem() != null && !this.gm.thePlayer.getHeldItem().getItem().canBreakBlocks())
// {
// return false;
// }
// else
// {
World world = this.gm.world;
State iblockstate = world.getState(pos);
Block block1 = iblockstate.getBlock();
@ -134,8 +65,6 @@ public class PlayerController
this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());
// if (!this.creative)
// {
ItemStack itemstack1 = this.gm.player.getCurrentEquippedItem();
if (itemstack1 != null)
@ -147,42 +76,13 @@ public class PlayerController
this.gm.player.destroyCurrentEquippedItem();
}
}
// }
return flag;
}
// }
}
/**
* Called when the player is hitting a block with an item.
*/
public boolean clickBlock(BlockPos loc, Facing face)
{
// if (this.gamemode.isAdventure())
// {
// if (this.gamemode == Gamemode.SPECTATOR)
// {
// return false;
// }
// if (!this.gm.thePlayer.isAllowEdit())
// {
// Block block = this.gm.theWorld.getBlockState(loc).getBlock();
// ItemStack itemstack = this.gm.thePlayer.getCurrentEquippedItem();
//
// if (itemstack == null)
// {
// return false;
// }
//
// if (!itemstack.canDestroy(block))
// {
// return false;
// }
// }
// }
if (!World.isValidXZ(loc))
{
return false;
@ -195,13 +95,6 @@ public class PlayerController
this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, loc, face));
return true;
}
// if (this.creative)
// {
// this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, loc, face));
// clickBlockCreative(this.gm, this, loc, face);
// this.blockHitDelay = 5;
// }
// else
if (!this.isHittingBlock || !this.isHittingPosition(loc))
{
if (this.isHittingBlock)
@ -221,7 +114,6 @@ public class PlayerController
if (flag && block1.getPlayerRelativeBlockHardness(this.gm.player, this.gm.player.worldObj, loc) >= 1.0F)
{
this.onPlayerDestroyBlock(loc, face);
// if(this.cheat && block1.getPlayerRelativeBlockHardness(this.gm.thePlayer, this.gm.thePlayer.worldObj, loc) < 1.0F)
this.blockHitDelay = 3;
}
else
@ -239,9 +131,6 @@ public class PlayerController
}
}
/**
* Resets current block damage and isHittingBlock
*/
public void resetBlockRemoving()
{
if (this.isHittingBlock)
@ -269,13 +158,6 @@ public class PlayerController
--this.blockHitDelay;
return true;
}
// else if (this.creative && World.isValidXZ(posBlock))
// {
// this.blockHitDelay = 5;
// this.netClientHandler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
// clickBlockCreative(this.gm, this, posBlock, directionFacing);
// return true;
// }
else if (this.isHittingPosition(posBlock))
{
Block block = this.gm.world.getState(posBlock).getBlock();
@ -316,14 +198,6 @@ public class PlayerController
}
}
// /**
// * player reach distance = 4F
// */
// public float getBlockReachDistance()
// {
// return ;
// }
public void updateController()
{
this.syncCurrentPlayItem();
@ -351,9 +225,6 @@ public class PlayerController
return pos.equals(this.currentBlock) && flag;
}
/**
* Syncs the current player item with the server
*/
private void syncCurrentPlayItem()
{
int i = this.gm.player.inventory.currentItem;
@ -380,11 +251,9 @@ public class PlayerController
else
{
if(heldStack == null || !heldStack.getItem().onAction(heldStack, player, worldIn, ItemControl.SECONDARY, hitPos)) {
// if (this.gamemode != Gamemode.SPECTATOR)
// {
State iblockstate = worldIn.getState(hitPos);
if ((!player.isSneaking() || player.getHeldItem() == null) // && (player.getHeldItem() == null || !player.getHeldItem().getItem().ignoresBlocks())
if ((!player.isSneaking() || player.getHeldItem() == null)
&& iblockstate.getBlock().onBlockActivated(worldIn, hitPos, iblockstate, player, side, f, f1, f2))
{
flag = true;
@ -399,7 +268,6 @@ public class PlayerController
return false;
}
}
// }
}
else {
heldStack.getItem().onItemUse(heldStack, player, worldIn, hitPos, side, f, f1, f2);
@ -408,21 +276,12 @@ public class PlayerController
this.netClientHandler.addToSendQueue(new CPacketPlace(hitPos, side.getIndex(), player.inventory.getCurrentItem(), f, f1, f2));
if (!flag) // && this.gamemode != Gamemode.SPECTATOR)
if (!flag)
{
if (heldStack == null)
{
return false;
}
// else if (this.creative)
// {
// int i = heldStack.getMetadata();
// int j = heldStack.stackSize;
// boolean flag1 = heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
// heldStack.setItemDamage(i);
// heldStack.stackSize = j;
// return flag1;
// }
else
{
return heldStack.onItemUse(player, worldIn, hitPos, side, f, f1, f2);
@ -435,17 +294,8 @@ public class PlayerController
}
}
/**
* Notifies the server of things like consuming food, etc...
*/
public boolean sendUseItem(EntityNPC playerIn, World worldIn, ItemStack itemStackIn)
{
// if (this.gamemode == Gamemode.SPECTATOR)
// {
// return false;
// }
// else
// {
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketPlace(playerIn.inventory.getCurrentItem()));
int i = itemStackIn.stackSize;
@ -466,7 +316,6 @@ public class PlayerController
{
return false;
}
// }
}
public EntityNPC createPlayerEntity(WorldClient worldIn, int type)
@ -476,48 +325,20 @@ public class PlayerController
return player;
}
/**
* Attacks an entity
*/
public void attackEntity(EntityNPC playerIn, Entity targetEntity)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.ATTACK, targetEntity.getId()));
// if (this.gamemode != Gamemode.SPECTATOR)
// {
playerIn.attackTargetEntityWithCurrentItem(targetEntity);
// }
}
/**
* Send packet to server - player is interacting with another entity (left click)
*/
public boolean interactWithEntitySendPacket(EntityNPC playerIn, Entity targetEntity)
{
this.syncCurrentPlayItem();
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.INTERACT, targetEntity.getId()));
return /* this.gamemode != Gamemode.SPECTATOR && */ playerIn.interactWith(targetEntity);
return playerIn.interactWith(targetEntity);
}
// /**
// * Return true when the player rightclick on an entity
// *
// * @param player The player's instance
// * @param entityIn The entity clicked
// * @param movingObject The object clicked
// */
// public boolean isPlayerRightClickingOnEntity(EntityNPC player, Entity entityIn, MovingObjectPosition movingObject)
// {
// this.syncCurrentPlayItem();
// Vec3 vec3 = new Vec3(movingObject.hitVec.xCoord - entityIn.posX, movingObject.hitVec.yCoord - entityIn.posY, movingObject.hitVec.zCoord - entityIn.posZ);
// this.netClientHandler.addToSendQueue(new C02PacketUseEntity(entityIn, vec3));
// return this.gamemode != Gamemode.SPECTATOR && entityIn.interactAt(player, vec3);
// }
/**
* Handles slot clicks sends a packet to the server.
*/
public ItemStack windowClick(int windowId, int slotId, int mouseButtonClicked, int mode, EntityNPC playerIn)
{
short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
@ -526,36 +347,11 @@ public class PlayerController
return itemstack;
}
/**
* GuiEnchantment uses this during multiplayer to tell PlayerControllerMP to send a packet indicating the
* enchantment action the player has taken.
*
* @param windowID The ID of the current window
* @param button The button id (enchantment selected)
*/
public void sendEnchantPacket(int windowID, int button)
{
this.netClientHandler.addToSendQueue(new CPacketAction(CPacketAction.Action.ENCHANT_ITEM, windowID | (button << 8)));
}
// /**
// * Used in PlayerControllerMP to update the server with an ItemStack in a slot.
// */
// public void sendCheatPacket(ItemStack itemStackIn, boolean full)
// {
// }
// /**
// * Sends a Packet107 to the server to drop the item on the ground
// */
// public void sendPacketDropItem(ItemStack itemStackIn)
// {
// if (this.creative && itemStackIn != null)
// {
// this.netClientHandler.addToSendQueue(new CPacketCreative(-1, itemStackIn));
// }
// }
public void onStoppedUsingItem(EntityNPC playerIn)
{
this.syncCurrentPlayItem();
@ -563,40 +359,6 @@ public class PlayerController
playerIn.stopUsingItem();
}
// /**
// * Checks if the player is not creative, used for checking if it should break a block instantly
// */
// public boolean isNotCreative()
// {
// return !this.creative;
// }
// /**
// * returns true if player is in creative mode
// */
// public boolean isCreative()
// {
// return this.creative;
// }
// /**
// * Checks if the player is riding a horse, used to chose the GUI to open
// */
// public boolean isRidingHorse()
// {
// return ;
// }
// public Gamemode getGamemode()
// {
// return this.gamemode;
// }
/**
* Return isHittingBlock
*/
public boolean getIsHittingBlock()
{
return this.isHittingBlock;