use of com.builtbroken.mc.core.network.packet.user.PacketMouseClick in project Engine by VoltzEngine-Project.
the class PlayerKeyHandler method mouseHandler.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void mouseHandler(MouseEvent e) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null) {
final Item item = stack.getItem();
if (item instanceof IModeItem.IModeScrollItem) {
if (player.isSneaking() && e.dwheel != 0) {
int newMode = ((IModeItem.IModeScrollItem) stack.getItem()).cycleMode(stack, player, e.dwheel / 120);
if (newMode != ((IModeItem.IModeScrollItem) stack.getItem()).getMode(stack)) {
Engine.instance.packetHandler.sendToServer(new PacketPlayerItemMode(player.inventory.currentItem, newMode));
}
e.setCanceled(true);
}
} else if (item instanceof IMouseButtonHandler && e.button != -1) {
Engine.instance.packetHandler.sendToServer(new PacketMouseClick(player.inventory.currentItem, e.button, e.buttonstate));
((IMouseButtonHandler) item).mouseClick(stack, player, e.button, e.buttonstate);
if (((IMouseButtonHandler) item).shouldCancelMouseEvent(stack, player, e.button, e.buttonstate)) {
e.setCanceled(true);
}
}
}
}
Aggregations