use of net.minecraft.client.network.ClientPlayerInteractionManager in project EdenClient by HahaOO7.
the class AutoSheer method onTick.
private void onTick(ClientPlayerEntity player) {
if (!enabled)
return;
ClientPlayerInteractionManager interactionManager = MinecraftClient.getInstance().interactionManager;
if (interactionManager == null)
return;
Vec3d pos = player.getPos();
PlayerInventory inv = player.getInventory();
Hand shearHand;
if (inv.getMainHandStack().getItem() == Items.SHEARS)
shearHand = Hand.MAIN_HAND;
else if (inv.offHand.get(0).getItem() == Items.SHEARS)
shearHand = Hand.OFF_HAND;
else
return;
if (shearHand == Hand.MAIN_HAND) {
player.clientWorld.getEntitiesByClass(SheepEntity.class, player.getBoundingBox().expand(5), SheepEntity::isShearable).forEach(sheep -> {
if (!sheep.isShearable())
return;
if (sheep.getPos().squaredDistanceTo(pos) < 25) {
interactionManager.interactEntity(player, sheep, Hand.MAIN_HAND);
}
});
} else {
player.clientWorld.getEntitiesByClass(SheepEntity.class, player.getBoundingBox().expand(5), SheepEntity::isShearable).forEach(sheep -> {
if (!sheep.isShearable())
return;
if (sheep.getPos().squaredDistanceTo(pos) < 25) {
interactionManager.interactEntity(player, sheep, Hand.MAIN_HAND);
interactionManager.interactEntity(player, sheep, Hand.OFF_HAND);
}
});
}
}
use of net.minecraft.client.network.ClientPlayerInteractionManager in project KiwiClient by TangyKiwi.
the class AutoTool method onTick.
@Subscribe
public void onTick(TickEvent event) {
ClientPlayerInteractionManager interactionManager = mc.interactionManager;
if (prevState == true && !interactionManager.isBreakingBlock()) {
mc.player.getInventory().selectedSlot = slot;
} else if (prevState != interactionManager.isBreakingBlock()) {
slot = mc.player.getInventory().selectedSlot;
}
if (interactionManager.isBreakingBlock()) {
BlockPos blockPos = ((ClientPlayerInteractionManagerAccessor) interactionManager).getCurrentBreakingPos();
BlockState blockState = mc.world.getBlockState(blockPos);
swap(blockState);
}
prevState = interactionManager.isBreakingBlock();
}
use of net.minecraft.client.network.ClientPlayerInteractionManager in project KiwiClient by TangyKiwi.
the class KiwiClient method onInitialize.
@Override
public void onInitialize() {
mc = MinecraftClient.getInstance();
Utils.mc = mc;
CustomMatrix.begin(new MatrixStack());
moduleManager = new ModuleManager();
moduleManager.init();
commandManager = new CommandManager();
commandManager.init();
discordRPC = new DiscordRP();
discordRPC.start();
EChestMemory eChestMemory = new EChestMemory();
TickRate tickRate = new TickRate();
eventBus.register(eChestMemory);
eventBus.register(tickRate);
eventBus.register(moduleManager);
ClickGui.clickGui.initWindows();
FabricLoader.getInstance().getModContainer("kiwiclient").ifPresent(modContainer -> {
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("kiwiclient:kiwitweaks"), "resourcepacks/kiwitweaks", modContainer, true);
});
UseItemCallback.EVENT.register((player, world, hand) -> {
MinecraftClient mc = MinecraftClient.getInstance();
ClientPlayerInteractionManager interactionManager = mc.interactionManager;
if (mc.mouse.wasRightButtonClicked() && moduleManager.getModule(ArmorSwap.class).isEnabled()) {
ItemStack stack = player.getMainHandStack();
int currentItemIndex = player.getInventory().main.indexOf(stack);
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
int armorIndexSlot = determineIndex(equipmentSlot);
if (hand == Hand.MAIN_HAND && armorIndexSlot != -1) {
SoundEvent sound = determineSound(stack.getItem());
player.playSound(sound, 1.0F, 1.0F);
interactionManager.clickSlot(player.playerScreenHandler.syncId, armorIndexSlot, currentItemIndex, SlotActionType.SWAP, player);
return TypedActionResult.success(stack);
}
}
return TypedActionResult.pass(ItemStack.EMPTY);
});
KeyBindingHelper.registerKeyBinding(zoomKey);
}
use of net.minecraft.client.network.ClientPlayerInteractionManager in project EdenClient by HahaOO7.
the class Nuker method onTick.
private void onTick(ClientPlayerEntity player) {
if (!enabled)
return;
ClientPlayNetworkHandler nh = MinecraftClient.getInstance().getNetworkHandler();
BlockState air = Blocks.AIR.getDefaultState();
ClientPlayerInteractionManager im = MinecraftClient.getInstance().interactionManager;
if (im == null)
return;
if (nh == null)
return;
if (limit > 1) {
List<BlockPos> minableBlocks = getInstantMinableBlocksInRange(player);
if (!minableBlocks.isEmpty()) {
target = null;
minableBlocks.forEach(p -> {
nh.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, p, getHitDirectionForBlock(player, p)));
nh.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, p, getHitDirectionForBlock(player, p)));
player.clientWorld.setBlockState(p, air);
});
nh.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
return;
}
}
if (target == null || Vec3d.ofCenter(target).distanceTo(player.getEyePos()) > distance)
findTarget(player);
if (target == null)
return;
Direction dir = getHitDirectionForBlock(player, target);
if (im.updateBlockBreakingProgress(target, dir))
nh.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
else
target = null;
}
Aggregations