Search in sources :

Example 1 with EntityRenderer

use of net.minecraft.client.renderer.EntityRenderer in project DynamicSurroundings by OreCruncher.

the class KeyHandler method onKeyboard.

@SubscribeEvent(receiveCanceled = false)
public static void onKeyboard(@Nonnull InputEvent.KeyInputEvent event) {
    if (shouldHandle(SELECTIONBOX_KEY)) {
        final EntityRenderer renderer = Minecraft.getMinecraft().entityRenderer;
        final boolean result = !EntityRendererUtil.getDrawBlockOutline(renderer);
        EntityRendererUtil.setDrawBlockOutline(renderer, result);
        sendPlayerMessage("dsurround.cfg.keybind.msg.Fencing", getOnOff(result));
    }
    if (shouldHandle(VOLUME_KEY) && Minecraft.getMinecraft().currentScreen == null) {
        final VolumeControlGui gui = new VolumeControlGui();
        Minecraft.getMinecraft().displayGuiScreen(gui);
    }
    if (shouldHandle(CHUNKBORDER_KEY)) {
        final boolean result = Minecraft.getMinecraft().debugRenderer.toggleChunkBorders();
        sendPlayerMessage("dsurround.cfg.keybind.msg.ChunkBorder", getOnOff(result));
    }
    if (shouldHandle(LIGHTLEVEL_KEY)) {
        if (GuiScreen.isCtrlKeyDown()) {
            // Only change mode when visible
            if (LightLevelHUD.showHUD) {
                ModOptions.lightlevel.llDisplayMode++;
                if (ModOptions.lightlevel.llDisplayMode >= Mode.values().length)
                    ModOptions.lightlevel.llDisplayMode = 0;
                sendPlayerMessage("dsurround.cfg.keybind.msg.LLDisplayMode", Mode.getMode(ModOptions.lightlevel.llDisplayMode).name());
            }
        } else if (GuiScreen.isShiftKeyDown()) {
            if (LightLevelHUD.showHUD) {
                ModOptions.lightlevel.llHideSafe = !ModOptions.lightlevel.llHideSafe;
                sendPlayerMessage("dsurround.cfg.keybind.msg.LLSafeBlocks", getOnOff(ModOptions.lightlevel.llHideSafe));
            }
        } else {
            LightLevelHUD.showHUD = !LightLevelHUD.showHUD;
            sendPlayerMessage("dsurround.cfg.keybind.msg.LLDisplay", getOnOff(LightLevelHUD.showHUD));
        }
    }
}
Also used : VolumeControlGui(org.blockartistry.DynSurround.client.gui.VolumeControlGui) EntityRenderer(net.minecraft.client.renderer.EntityRenderer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityRenderer

use of net.minecraft.client.renderer.EntityRenderer in project ArsMagica2 by Mithion.

the class AMGuiHelper method overrideMouseInput.

public static boolean overrideMouseInput(EntityRenderer renderer, float f, boolean b) {
    Minecraft mc = Minecraft.getMinecraft();
    if (!mc.inGameHasFocus || mc.thePlayer == null || mc.theWorld == null)
        return true;
    ExtendedProperties props = ExtendedProperties.For(mc.thePlayer);
    if (!(mc.thePlayer.isPotionActive(BuffList.scrambleSynapses) ^ props.getIsFlipped())) {
        return true;
    }
    mc.mouseHelper.mouseXYChange();
    float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
    float f2 = f1 * f1 * f1 * 8.0F;
    float f3 = (float) mc.mouseHelper.deltaX * f2;
    float f4 = (float) mc.mouseHelper.deltaY * f2;
    byte b0 = -1;
    if (mc.gameSettings.invertMouse) {
        b0 = 1;
    }
    if (mc.gameSettings.smoothCamera) {
        String[] scy = { "field_78496_H", "smoothCamYaw" };
        String[] scp = { "field_78521_m", "smoothCamPitch" };
        String[] scpt = { "field_78533_p", "smoothCamPartialTicks" };
        String[] scfx = { "field_78518_n", "smoothCamFilterX" };
        String[] scfy = { "field_78499_K", "smoothCamFilterY" };
        // renderer.smoothCamYaw += f3;
        ReflectionHelper.setPrivateValue(EntityRenderer.class, renderer, (Float) ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, scy) - f3, scy);
        // renderer.smoothCamPitch += f4;
        ReflectionHelper.setPrivateValue(EntityRenderer.class, renderer, (Float) ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, scp) - f4, scp);
        // float f5 = f - renderer.smoothCamPartialTicks;
        float f5 = f - (Float) ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, scpt);
        // renderer.smoothCamPartialTicks = f;
        ReflectionHelper.setPrivateValue(EntityRenderer.class, renderer, f, scpt);
        // f3 = renderer.smoothCamFilterX * f5;
        f3 = (Float) ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, scfx) * f5;
        // f4 = renderer.smoothCamFilterY * f5;
        f4 = (Float) ReflectionHelper.getPrivateValue(EntityRenderer.class, renderer, scfy) * f5;
        mc.thePlayer.setAngles(-f3, f4 * (float) b0);
    } else {
        mc.thePlayer.setAngles(-f3, f4 * (float) b0);
    }
    return false;
}
Also used : Minecraft(net.minecraft.client.Minecraft) EntityRenderer(net.minecraft.client.renderer.EntityRenderer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Aggregations

EntityRenderer (net.minecraft.client.renderer.EntityRenderer)2 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 Minecraft (net.minecraft.client.Minecraft)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 VolumeControlGui (org.blockartistry.DynSurround.client.gui.VolumeControlGui)1