use of blusunrize.immersiveengineering.common.util.network.MessageChemthrowerSwitch in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onMouseEvent.
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
if (event.getDwheel() != 0) {
EntityPlayer player = ClientUtils.mc().player;
if (!player.getHeldItem(EnumHand.MAIN_HAND).isEmpty() && player.isSneaking()) {
ItemStack equipped = player.getHeldItem(EnumHand.MAIN_HAND);
if (equipped.getItem() instanceof IZoomTool) {
IZoomTool tool = (IZoomTool) equipped.getItem();
if (tool.canZoom(equipped, player)) {
float[] steps = tool.getZoomSteps(equipped, player);
if (steps != null && steps.length > 0) {
int curStep = -1;
float dist = 0;
for (int i = 0; i < steps.length; i++) if (curStep == -1 || Math.abs(steps[i] - ZoomHandler.fovZoom) < dist) {
curStep = i;
dist = Math.abs(steps[i] - ZoomHandler.fovZoom);
}
if (curStep != -1) {
int newStep = curStep + (event.getDwheel() > 0 ? -1 : 1);
if (newStep >= 0 && newStep < steps.length)
ZoomHandler.fovZoom = steps[newStep];
event.setCanceled(true);
}
}
}
}
if (Config.IEConfig.Tools.chemthrower_scroll && equipped.getItem() instanceof ItemChemthrower && ((ItemChemthrower) equipped.getItem()).getUpgrades(equipped).getBoolean("multitank")) {
ImmersiveEngineering.packetHandler.sendToServer(new MessageChemthrowerSwitch(event.getDwheel() < 0));
event.setCanceled(true);
}
if (equipped.getItem() instanceof ItemRevolver) {
ImmersiveEngineering.packetHandler.sendToServer(new MessageRevolverRotate(event.getDwheel() < 0));
event.setCanceled(true);
}
}
}
}
Aggregations