Java Code Examples for net.minecraft.server.network.ServerPlayerEntity#updateLastActionTime()
The following examples show how to use
net.minecraft.server.network.ServerPlayerEntity#updateLastActionTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityPlayerActionPack.java From fabric-carpet with MIT License | 5 votes |
@Override boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); player.dropSelectedItem(false); return false; }
Example 2
Source File: EntityPlayerActionPack.java From fabric-carpet with MIT License | 5 votes |
@Override boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); player.dropSelectedItem(true); return false; }
Example 3
Source File: EntityPlayerActionPack.java From fabric-carpet with MIT License | 5 votes |
@Override boolean execute(ServerPlayerEntity player, Action action) { player.updateLastActionTime(); ItemStack itemStack_1 = player.getStackInHand(Hand.OFF_HAND); player.setStackInHand(Hand.OFF_HAND, player.getStackInHand(Hand.MAIN_HAND)); player.setStackInHand(Hand.MAIN_HAND, itemStack_1); return false; }
Example 4
Source File: EntityPlayerActionPack.java From fabric-carpet with MIT License | 4 votes |
@Override boolean execute(ServerPlayerEntity player, Action action) { HitResult hit = getTarget(player); switch (hit.getType()) { case ENTITY: { EntityHitResult entityHit = (EntityHitResult) hit; player.attack(entityHit.getEntity()); player.resetLastAttackedTicks(); player.updateLastActionTime(); player.swingHand(Hand.MAIN_HAND); return true; } case BLOCK: { EntityPlayerActionPack ap = ((ServerPlayerEntityInterface) player).getActionPack(); if (ap.blockHitDelay > 0) { ap.blockHitDelay--; return false; } BlockHitResult blockHit = (BlockHitResult) hit; BlockPos pos = blockHit.getBlockPos(); Direction side = blockHit.getSide(); // rather should be canNotMine if (player.canMine(player.world, pos, player.interactionManager.getGameMode())) return false; if (ap.currentBlock != null && player.world.getBlockState(ap.currentBlock).isAir()) { ap.currentBlock = null; return false; } BlockState state = player.world.getBlockState(pos); boolean blockBroken = false; if (player.interactionManager.getGameMode().isCreative()) { player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.server.getWorldHeight()); ap.blockHitDelay = 5; blockBroken = true; } else if (ap.currentBlock == null || !ap.currentBlock.equals(pos)) { if (ap.currentBlock != null) { player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.server.getWorldHeight()); } player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.server.getWorldHeight()); boolean notAir = !state.isAir(); if (notAir && ap.curBlockDamageMP == 0) { state.onBlockBreakStart(player.world, pos, player); } if (notAir && state.calcBlockBreakingDelta(player, player.world, pos) >= 1) { ap.currentBlock = null; //instamine?? blockBroken = true; } else { ap.currentBlock = pos; ap.curBlockDamageMP = 0; } } else { ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.world, pos); if (ap.curBlockDamageMP >= 1) { player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.server.getWorldHeight()); ap.currentBlock = null; ap.blockHitDelay = 5; blockBroken = true; } player.world.setBlockBreakingInfo(-1, pos, (int) (ap.curBlockDamageMP * 10)); } player.updateLastActionTime(); player.swingHand(Hand.MAIN_HAND); return blockBroken; } } return false; }