Search in sources :

Example 1 with ClientPlayerEntity

use of net.minecraft.client.entity.player.ClientPlayerEntity in project Overloaded by CJ-MC-Mods.

the class ItemRailGun method onMouseEvent.

@SubscribeEvent
public void onMouseEvent(InputEvent.MouseScrollEvent event) {
    ClientPlayerEntity player = Minecraft.getInstance().player;
    if (event.getScrollDelta() != 0 && player != null && player.isShiftKeyDown()) {
        ItemStack stack = player.getMainHandItem();
        if (player.isShiftKeyDown() && !stack.isEmpty() && stack.getItem() == this) {
            int powerDelta = Long.signum(Math.round(event.getScrollDelta())) * OverloadedConfig.INSTANCE.railGun.stepEnergy;
            if (InputMappings.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), ((ClientProxy) Overloaded.proxy).railGun100x.getKey().getValue())) {
                powerDelta *= 100;
            }
            Overloaded.proxy.networkWrapper.sendToServer(new RailGunSettingsMessage(powerDelta));
            event.setCanceled(true);
        }
    }
}
Also used : RailGunSettingsMessage(com.cjm721.overloaded.network.packets.RailGunSettingsMessage) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ClientPlayerEntity

use of net.minecraft.client.entity.player.ClientPlayerEntity in project Overloaded by CJ-MC-Mods.

the class RenderMultiToolAssist method onMouseEvent.

@SubscribeEvent
public static void onMouseEvent(InputEvent.MouseScrollEvent event) {
    ClientPlayerEntity player = Minecraft.getInstance().player;
    if (event.getScrollDelta() != 0 && player != null && player.isShiftKeyDown()) {
        ItemStack stack = player.getMainHandItem();
        if (player.isShiftKeyDown() && !stack.isEmpty() && stack.getItem() == ModItems.multiTool) {
            changeHelpMode((int) Math.round(event.getScrollDelta()));
            player.displayClientMessage(new StringTextComponent("Assist Mode: " + getAssistMode().getName()), true);
            event.setCanceled(true);
        }
    }
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)2 ItemStack (net.minecraft.item.ItemStack)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 RailGunSettingsMessage (com.cjm721.overloaded.network.packets.RailGunSettingsMessage)1 StringTextComponent (net.minecraft.util.text.StringTextComponent)1