0% found this document useful (0 votes)
23 views10 pages

Client Player Interaction Manager Code

minecraft
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

Client Player Interaction Manager Code

minecraft
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//

// Source code recreated from a .class file by IntelliJ IDEA


// (powered by Fernflower decompiler)
//

package [Link];

import [Link];
import [Link];
import [Link].Int2ObjectMap;
import [Link].Int2ObjectOpenHashMap;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].ButtonClickC2SPacket;
import [Link].ClickSlotC2SPacket;
import [Link].CraftRequestC2SPacket;
import [Link].CreativeInventoryActionC2SPacket;
import [Link].PickFromInventoryC2SPacket;
import [Link].PlayerActionC2SPacket;
import [Link].PlayerInteractBlockC2SPacket;
import [Link].PlayerInteractEntityC2SPacket;
import [Link].PlayerInteractItemC2SPacket;
import [Link].PlayerMoveC2SPacket;
import [Link].UpdateSelectedSlotC2SPacket;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].Vec3d;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

@Environment([Link])
public class ClientPlayerInteractionManager {
private static final Logger LOGGER = [Link]();
private final MinecraftClient client;
private final ClientPlayNetworkHandler networkHandler;
private BlockPos currentBreakingPos = new BlockPos(-1, -1, -1);
private ItemStack selectedStack;
private float currentBreakingProgress;
private float blockBreakingSoundCooldown;
private int blockBreakingCooldown;
private boolean breakingBlock;
private GameMode gameMode;
@Nullable
private GameMode previousGameMode;
private int lastSelectedSlot;

public ClientPlayerInteractionManager(MinecraftClient client,


ClientPlayNetworkHandler networkHandler) {
[Link] = [Link];
[Link] = [Link];
[Link] = client;
[Link] = networkHandler;
}

public void copyAbilities(PlayerEntity player) {


[Link]([Link]());
}

public void setGameModes(GameMode gameMode, @Nullable GameMode


previousGameMode) {
[Link] = gameMode;
[Link] = previousGameMode;
[Link]([Link]());
}

public void setGameMode(GameMode gameMode) {


if (gameMode != [Link]) {
[Link] = [Link];
}

[Link] = gameMode;
[Link]([Link]());
}

public boolean hasStatusBars() {


return [Link]();
}

public boolean breakBlock(BlockPos pos) {


if ([Link]([Link], pos,
[Link])) {
return false;
} else {
World world = [Link];
BlockState blockState = [Link](pos);
if (!
[Link]().getItem().canMine(blockState, world, pos,
[Link])) {
return false;
} else {
Block block = [Link]();
if (block instanceof OperatorBlock && !
[Link]()) {
return false;
} else if ([Link]()) {
return false;
} else {
[Link](world, pos, blockState, [Link]);
FluidState fluidState = [Link](pos);
boolean bl = [Link](pos,
[Link](), 11);
if (bl) {
[Link](world, pos, blockState);
}

return bl;
}
}
}
}

public boolean attackBlock(BlockPos pos, Direction direction) {


if ([Link]([Link], pos,
[Link])) {
return false;
} else if (![Link]().contains(pos)) {
return false;
} else {
if ([Link]()) {
BlockState blockState = [Link](pos);
[Link]().onBlockBreaking([Link],
pos, blockState, 1.0F);
[Link]([Link], (sequence) -> {
[Link](pos);
return new PlayerActionC2SPacket(Action.START_DESTROY_BLOCK,
pos, direction, sequence);
});
[Link] = 5;
} else if (![Link] || ![Link](pos)) {
if ([Link]) {
[Link](new
PlayerActionC2SPacket(Action.ABORT_DESTROY_BLOCK, [Link],
direction));
}

BlockState blockState = [Link](pos);


[Link]().onBlockBreaking([Link],
pos, blockState, 0.0F);
[Link]([Link], (sequence) -> {
boolean bl = ![Link]();
if (bl && [Link] == 0.0F) {
[Link]([Link], pos,
[Link]);
}

if (bl && [Link]([Link],


[Link](), pos) >= 1.0F) {
[Link](pos);
} else {
[Link] = true;
[Link] = pos;
[Link] = [Link]();
[Link] = 0.0F;
[Link] = 0.0F;

[Link]([Link](),
[Link], [Link]());
}

return new PlayerActionC2SPacket(Action.START_DESTROY_BLOCK,


pos, direction, sequence);
});
}

return true;
}
}

public void cancelBlockBreaking() {


if ([Link]) {
BlockState blockState =
[Link]([Link]);
[Link]().onBlockBreaking([Link],
[Link], blockState, -1.0F);
[Link](new
PlayerActionC2SPacket(Action.ABORT_DESTROY_BLOCK, [Link],
[Link]));
[Link] = false;
[Link] = 0.0F;
[Link]([Link](),
[Link], -1);
[Link]();
}

public boolean updateBlockBreakingProgress(BlockPos pos, Direction direction) {


[Link]();
if ([Link] > 0) {
--[Link];
return true;
} else if ([Link]() &&
[Link]().contains(pos)) {
[Link] = 5;
BlockState blockState = [Link](pos);
[Link]().onBlockBreaking([Link],
pos, blockState, 1.0F);
[Link]([Link], (sequence) -> {
[Link](pos);
return new PlayerActionC2SPacket(Action.START_DESTROY_BLOCK, pos,
direction, sequence);
});
return true;
} else if ([Link](pos)) {
BlockState blockState = [Link](pos);
if ([Link]()) {
[Link] = false;
return false;
} else {
[Link] +=
[Link]([Link],
[Link](), pos);
if ([Link] % 4.0F == 0.0F) {
BlockSoundGroup blockSoundGroup = [Link]();
[Link]().play(new
PositionedSoundInstance([Link](), [Link],
([Link]() + 1.0F) / 8.0F, [Link]() * 0.5F,
[Link](), pos));
}

++[Link];
[Link]().onBlockBreaking([Link],
pos, blockState, [Link]([Link], 0.0F, 1.0F));
if ([Link] >= 1.0F) {
[Link] = false;
[Link]([Link], (sequence) -> {
[Link](pos);
return new PlayerActionC2SPacket(Action.STOP_DESTROY_BLOCK,
pos, direction, sequence);
});
[Link] = 0.0F;
[Link] = 0.0F;
[Link] = 5;
}

[Link]([Link](),
[Link], [Link]());
return true;
}
} else {
return [Link](pos, direction);
}
}

private void sendSequencedPacket(ClientWorld world, SequencedPacketCreator


packetCreator) {
try (PendingUpdateManager pendingUpdateManager =
[Link]().incrementSequence()) {
int i = [Link]();
Packet<ServerPlayPacketListener> packet = [Link](i);
[Link](packet);
}

public float getReachDistance() {


return [Link]() ? 5.0F : 4.5F;
}

public void tick() {


[Link]();
if ([Link]().isOpen()) {
[Link]().tick();
} else {
[Link]().handleDisconnection();
}

private boolean isCurrentlyBreaking(BlockPos pos) {


ItemStack itemStack = [Link]();
return [Link]([Link]) &&
[Link](itemStack, [Link]);
}

private void syncSelectedSlot() {


int i = [Link]().selectedSlot;
if (i != [Link]) {
[Link] = i;
[Link](new
UpdateSelectedSlotC2SPacket([Link]));
}

public ActionResult interactBlock(ClientPlayerEntity player, Hand hand,


BlockHitResult hitResult) {
[Link]();
if (![Link]().contains([Link]()))
{
return [Link];
} else {
MutableObject<ActionResult> mutableObject = new MutableObject();
[Link]([Link], (sequence) -> {
[Link]([Link](player, hand,
hitResult));
return new PlayerInteractBlockC2SPacket(hand, hitResult, sequence);
});
return (ActionResult)[Link]();
}
}

private ActionResult interactBlockInternal(ClientPlayerEntity player, Hand


hand, BlockHitResult hitResult) {
BlockPos blockPos = [Link]();
ItemStack itemStack = [Link](hand);
if ([Link] == [Link]) {
return [Link];
} else {
boolean bl = ![Link]().isEmpty() || !
[Link]().isEmpty();
boolean bl2 = [Link]() && bl;
if (!bl2) {
BlockState blockState = [Link](blockPos);
if (!
[Link]([Link]().getRequiredFeatures())) {
return [Link];
}
ActionResult actionResult = [Link]([Link],
player, hand, hitResult);
if ([Link]()) {
return actionResult;
}
}

if (![Link]() && !
[Link]().isCoolingDown([Link]())) {
ItemUsageContext itemUsageContext = new ItemUsageContext(player,
hand, hitResult);
ActionResult actionResult2;
if ([Link]()) {
int i = [Link]();
actionResult2 = [Link](itemUsageContext);
[Link](i);
} else {
actionResult2 = [Link](itemUsageContext);
}

return actionResult2;
} else {
return [Link];
}
}
}

public ActionResult interactItem(PlayerEntity player, Hand hand) {


if ([Link] == [Link]) {
return [Link];
} else {
[Link]();
[Link](new
[Link]([Link](), [Link](), [Link](),
[Link](), [Link](), [Link]()));
MutableObject<ActionResult> mutableObject = new MutableObject();
[Link]([Link], (sequence) -> {
PlayerInteractItemC2SPacket playerInteractItemC2SPacket = new
PlayerInteractItemC2SPacket(hand, sequence);
ItemStack itemStack = [Link](hand);
if
([Link]().isCoolingDown([Link]())) {
[Link]([Link]);
return playerInteractItemC2SPacket;
} else {
TypedActionResult<ItemStack> typedActionResult =
[Link]([Link], player, hand);
ItemStack itemStack2 = (ItemStack)[Link]();
if (itemStack2 != itemStack) {
[Link](hand, itemStack2);
}

[Link]([Link]());
return playerInteractItemC2SPacket;
}
});
return (ActionResult)[Link]();
}
}
public ClientPlayerEntity createPlayer(ClientWorld world, StatHandler
statHandler, ClientRecipeBook recipeBook) {
return [Link](world, statHandler, recipeBook, false, false);
}

public ClientPlayerEntity createPlayer(ClientWorld world, StatHandler


statHandler, ClientRecipeBook recipeBook, boolean lastSneaking, boolean
lastSprinting) {
return new ClientPlayerEntity([Link], world, [Link],
statHandler, recipeBook, lastSneaking, lastSprinting);
}

public void attackEntity(PlayerEntity player, Entity target) {


[Link]();
[Link]([Link](target,
[Link]()));
if ([Link] != [Link]) {
[Link](target);
[Link]();
}

public ActionResult interactEntity(PlayerEntity player, Entity entity, Hand


hand) {
[Link]();

[Link]([Link](entity,
[Link](), hand));
return [Link] == [Link] ? [Link] :
[Link](entity, hand);
}

public ActionResult interactEntityAtLocation(PlayerEntity player, Entity


entity, EntityHitResult hitResult, Hand hand) {
[Link]();
Vec3d vec3d = [Link]().subtract([Link](), [Link](),
[Link]());

[Link]([Link](entity,
[Link](), hand, vec3d));
return [Link] == [Link] ? [Link] :
[Link](player, vec3d, hand);
}

public void clickSlot(int syncId, int slotId, int button, SlotActionType


actionType, PlayerEntity player) {
ScreenHandler screenHandler = [Link];
if (syncId != [Link]) {
[Link]("Ignoring click in mismatching container. Click in {},
player has {}.", syncId, [Link]);
} else {
DefaultedList<Slot> defaultedList = [Link];
int i = [Link]();
List<ItemStack> list = [Link](i);

for(Slot slot : defaultedList) {


[Link]([Link]().copy());
}

[Link](slotId, button, actionType, player);


Int2ObjectMap<ItemStack> int2ObjectMap = new Int2ObjectOpenHashMap();

for(int j = 0; j < i; ++j) {


ItemStack itemStack = (ItemStack)[Link](j);
ItemStack itemStack2 = ((Slot)[Link](j)).getStack();
if (![Link](itemStack, itemStack2)) {
[Link](j, [Link]());
}
}

[Link](new ClickSlotC2SPacket(syncId,
[Link](), slotId, button, actionType,
[Link]().copy(), int2ObjectMap));
}
}

public void clickRecipe(int syncId, Recipe<?> recipe, boolean craftAll) {


[Link](new CraftRequestC2SPacket(syncId, recipe,
craftAll));
}

public void clickButton(int syncId, int buttonId) {


[Link](new ButtonClickC2SPacket(syncId, buttonId));
}

public void clickCreativeStack(ItemStack stack, int slotId) {


if ([Link]() &&
[Link]([Link]().getRequiredFeatures())) {
[Link](new
CreativeInventoryActionC2SPacket(slotId, stack));
}

public void dropCreativeStack(ItemStack stack) {


if ([Link]() && ![Link]() &&
[Link]([Link]().getRequiredFeatures())) {
[Link](new CreativeInventoryActionC2SPacket(-1,
stack));
}

public void stopUsingItem(PlayerEntity player) {


[Link]();
[Link](new
PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, [Link], [Link]));
[Link]();
}

public boolean hasExperienceBar() {


return [Link]();
}

public boolean hasLimitedAttackSpeed() {


return ![Link]();
}

public boolean hasCreativeInventory() {


return [Link]();
}

public boolean hasExtendedReach() {


return [Link]();
}

public boolean hasRidingInventory() {


return [Link]() && [Link]()
instanceof RideableInventory;
}

public boolean isFlyingLocked() {


return [Link] == [Link];
}

@Nullable
public GameMode getPreviousGameMode() {
return [Link];
}

public GameMode getCurrentGameMode() {


return [Link];
}

public boolean isBreakingBlock() {


return [Link];
}

public int getBlockBreakingProgress() {


return [Link] > 0.0F ? (int)
([Link] * 10.0F) : -1;
}

public void pickFromInventory(int slot) {


[Link](new PickFromInventoryC2SPacket(slot));
}
}

You might also like