cleanup player controller method names

This commit is contained in:
Sen 2025-05-25 15:41:41 +02:00
parent 2bc84f0c66
commit 10fdaf0b1a
2 changed files with 28 additions and 28 deletions

View file

@ -698,7 +698,7 @@ public class Client implements IThreadListener {
this.entityRenderer.getMouseOver(1.0F); this.entityRenderer.getMouseOver(1.0F);
if (/* !this.paused && */ this.world != null) if (/* !this.paused && */ this.world != null)
{ {
this.controller.updateController(); this.controller.update();
} }
this.textureMap.updateAnimations(); this.textureMap.updateAnimations();
if (this.open != null) if (this.open != null)
@ -728,7 +728,7 @@ public class Client implements IThreadListener {
{ {
if (!Bind.SECONDARY.isDown()) if (!Bind.SECONDARY.isDown())
{ {
this.controller.onStoppedUsingItem(this.player); this.controller.stopUsing(this.player);
} }
} }
else else
@ -1267,7 +1267,7 @@ public class Client implements IThreadListener {
{ {
BlockPos blockpos = this.pointed.block; BlockPos blockpos = this.pointed.block;
if (this.world.getState(blockpos).getBlock() != Blocks.air && this.controller.onPlayerDamageBlock(blockpos, this.pointed.side)) if (this.world.getState(blockpos).getBlock() != Blocks.air && this.controller.damageBlock(blockpos, this.pointed.side))
{ {
this.effectRenderer.addBlockHitEffects(blockpos, this.pointed.side); this.effectRenderer.addBlockHitEffects(blockpos, this.pointed.side);
this.player.swingItem(); this.player.swingItem();
@ -1275,7 +1275,7 @@ public class Client implements IThreadListener {
} }
else else
{ {
this.controller.resetBlockRemoving(); this.controller.resetProgress();
} }
} }
} }
@ -1328,7 +1328,7 @@ public class Client implements IThreadListener {
private void secondary() private void secondary()
{ {
if (!this.controller.getIsHittingBlock()) if (!this.controller.isHittingBlock())
{ {
this.rightClickTimer = 4; this.rightClickTimer = 4;
boolean flag = true; boolean flag = true;
@ -1360,7 +1360,7 @@ public class Client implements IThreadListener {
// flag = false; // flag = false;
// } // }
// else // else
if (this.controller.interactWithEntitySendPacket(this.player, this.pointed.entity)) if (this.controller.interact(this.player, this.pointed.entity))
{ {
flag = false; flag = false;
} }
@ -1374,7 +1374,7 @@ public class Client implements IThreadListener {
{ {
int i = itemstack != null ? itemstack.stackSize : 0; int i = itemstack != null ? itemstack.stackSize : 0;
if (this.controller.onPlayerRightClick(this.player, this.world, itemstack, blockpos, this.pointed.side, this.pointed.vec)) if (this.controller.clickRight(this.player, this.world, itemstack, blockpos, this.pointed.side, this.pointed.vec))
{ {
flag = false; flag = false;
this.player.swingItem(); this.player.swingItem();

View file

@ -41,7 +41,7 @@ public class PlayerController {
this.handler = handler; this.handler = handler;
} }
public boolean onPlayerDestroyBlock(BlockPos pos, Facing side) { public boolean destroyBlock(BlockPos pos, Facing side) {
World world = this.gm.world; World world = this.gm.world;
State state = world.getState(pos); State state = world.getState(pos);
Block block = state.getBlock(); Block block = state.getBlock();
@ -84,7 +84,7 @@ public class PlayerController {
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face)); this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face));
return true; return true;
} }
if(!this.hitting || !this.isHittingPosition(pos)) { if(!this.hitting || !this.isHitting(pos)) {
if(this.hitting) { if(this.hitting) {
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, face)); this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, face));
} }
@ -98,7 +98,7 @@ public class PlayerController {
} }
if(flag && block.getPlayerRelativeBlockHardness(this.gm.player, this.gm.player.worldObj, pos) >= 1.0F) { if(flag && block.getPlayerRelativeBlockHardness(this.gm.player, this.gm.player.worldObj, pos) >= 1.0F) {
this.onPlayerDestroyBlock(pos, face); this.destroyBlock(pos, face);
this.delay = 3; this.delay = 3;
} }
else { else {
@ -115,7 +115,7 @@ public class PlayerController {
} }
} }
public void resetBlockRemoving() { public void resetProgress() {
if(this.hitting) { if(this.hitting) {
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN)); this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN));
this.hitting = false; this.hitting = false;
@ -128,16 +128,16 @@ public class PlayerController {
this.interacting = false; this.interacting = false;
} }
public boolean onPlayerDamageBlock(BlockPos pos, Facing face) { public boolean damageBlock(BlockPos pos, Facing face) {
if(this.interacting) if(this.interacting)
return false; return false;
this.syncCurrentPlayItem(); this.syncItem();
if(this.delay > 0) { if(this.delay > 0) {
--this.delay; --this.delay;
return true; return true;
} }
else if(this.isHittingPosition(pos)) { else if(this.isHitting(pos)) {
Block block = this.gm.world.getState(pos).getBlock(); Block block = this.gm.world.getState(pos).getBlock();
if(block == Blocks.air) { if(block == Blocks.air) {
@ -157,7 +157,7 @@ public class PlayerController {
if(this.damage >= 1.0F) { if(this.damage >= 1.0F) {
this.hitting = false; this.hitting = false;
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.STOP_DESTROY_BLOCK, pos, face)); this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.STOP_DESTROY_BLOCK, pos, face));
this.onPlayerDestroyBlock(pos, face); this.destroyBlock(pos, face);
this.damage = 0.0F; this.damage = 0.0F;
this.stepCounter = 0.0F; this.stepCounter = 0.0F;
this.delay = 5; this.delay = 5;
@ -172,8 +172,8 @@ public class PlayerController {
} }
} }
public void updateController() { public void update() {
this.syncCurrentPlayItem(); this.syncItem();
if(this.handler.getNetworkManager().isChannelOpen()) { if(this.handler.getNetworkManager().isChannelOpen()) {
this.handler.getNetworkManager().processReceivedPackets(); this.handler.getNetworkManager().processReceivedPackets();
@ -183,7 +183,7 @@ public class PlayerController {
} }
} }
private boolean isHittingPosition(BlockPos pos) { private boolean isHitting(BlockPos pos) {
ItemStack stack = this.gm.player.getHeldItem(); ItemStack stack = this.gm.player.getHeldItem();
boolean flag = this.stack == null && stack == null; boolean flag = this.stack == null && stack == null;
@ -196,7 +196,7 @@ public class PlayerController {
return pos.equals(this.position) && flag; return pos.equals(this.position) && flag;
} }
private void syncCurrentPlayItem() { private void syncItem() {
int slot = this.gm.player.inventory.currentItem; int slot = this.gm.player.inventory.currentItem;
if(slot != this.lastSelected) { if(slot != this.lastSelected) {
@ -205,8 +205,8 @@ public class PlayerController {
} }
} }
public boolean onPlayerRightClick(EntityNPC player, WorldClient world, ItemStack stack, BlockPos pos, Facing side, Vec3 hit) { public boolean clickRight(EntityNPC player, WorldClient world, ItemStack stack, BlockPos pos, Facing side, Vec3 hit) {
this.syncCurrentPlayItem(); this.syncItem();
float f = (float)(hit.xCoord - (double)pos.getX()); float f = (float)(hit.xCoord - (double)pos.getX());
float f1 = (float)(hit.yCoord - (double)pos.getY()); float f1 = (float)(hit.yCoord - (double)pos.getY());
float f2 = (float)(hit.zCoord - (double)pos.getZ()); float f2 = (float)(hit.zCoord - (double)pos.getZ());
@ -254,7 +254,7 @@ public class PlayerController {
} }
public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) { public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) {
this.syncCurrentPlayItem(); this.syncItem();
this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem())); this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem()));
int size = stack.stackSize; int size = stack.stackSize;
ItemStack changed = stack.useItemRightClick(world, player); ItemStack changed = stack.useItemRightClick(world, player);
@ -280,13 +280,13 @@ public class PlayerController {
} }
public void attackEntity(EntityNPC player, Entity target) { public void attackEntity(EntityNPC player, Entity target) {
this.syncCurrentPlayItem(); this.syncItem();
this.handler.addToSendQueue(new CPacketAction(CPacketAction.Action.ATTACK, target.getId())); this.handler.addToSendQueue(new CPacketAction(CPacketAction.Action.ATTACK, target.getId()));
player.attackTargetEntityWithCurrentItem(target); player.attackTargetEntityWithCurrentItem(target);
} }
public boolean interactWithEntitySendPacket(EntityNPC player, Entity target) { public boolean interact(EntityNPC player, Entity target) {
this.syncCurrentPlayItem(); this.syncItem();
this.handler.addToSendQueue(new CPacketAction(CPacketAction.Action.INTERACT, target.getId())); this.handler.addToSendQueue(new CPacketAction(CPacketAction.Action.INTERACT, target.getId()));
return player.interactWith(target); return player.interactWith(target);
} }
@ -302,13 +302,13 @@ public class PlayerController {
this.handler.addToSendQueue(new CPacketAction(CPacketAction.Action.ENCHANT_ITEM, window | (button << 8))); this.handler.addToSendQueue(new CPacketAction(CPacketAction.Action.ENCHANT_ITEM, window | (button << 8)));
} }
public void onStoppedUsingItem(EntityNPC player) { public void stopUsing(EntityNPC player) {
this.syncCurrentPlayItem(); this.syncItem();
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Facing.DOWN)); this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Facing.DOWN));
player.stopUsingItem(); player.stopUsingItem();
} }
public boolean getIsHittingBlock() { public boolean isHittingBlock() {
return this.hitting; return this.hitting;
} }
} }