Search in sources :

Example 51 with Minecraft

use of net.minecraft.client.Minecraft in project malmo by Microsoft.

the class VideoHook method forceResize.

/**
 * Force Minecraft to resize its GUI
 * @param width new width of window
 * @param height new height of window
 */
private void forceResize(int width, int height) {
    // Are we in the dev environment or deployed?
    boolean devEnv = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
    // We need to know, because the method name will either be obfuscated or not.
    String resizeMethodName = devEnv ? "resize" : "func_71370_a";
    Class[] cArgs = new Class[2];
    cArgs[0] = int.class;
    cArgs[1] = int.class;
    Method resize;
    try {
        resize = Minecraft.class.getDeclaredMethod(resizeMethodName, cArgs);
        resize.setAccessible(true);
        resize.invoke(Minecraft.getMinecraft(), width, height);
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Method(java.lang.reflect.Method) Minecraft(net.minecraft.client.Minecraft) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 52 with Minecraft

use of net.minecraft.client.Minecraft in project malmo by Microsoft.

the class TextureHelper method hookIntoRenderPipeline.

public static void hookIntoRenderPipeline() {
    // Subvert the render manager. This MUST be called at the right time (FMLInitializationEvent).
    // 1: Replace the MC entity renderer with our own:
    Minecraft.getMinecraft().entityRenderer = new MalmoEntityRenderer(Minecraft.getMinecraft(), Minecraft.getMinecraft().getResourceManager());
    // 2: Create a new RenderManager:
    RenderManager newRenderManager = new TextureHelper.MalmoRenderManager(Minecraft.getMinecraft().renderEngine, Minecraft.getMinecraft().getRenderItem());
    // 3: Use reflection to:
    // a) replace Minecraft's RenderManager with our new RenderManager
    // b) point Minecraft's RenderGlobal object to the new RenderManager
    // Are we in the dev environment or deployed?
    boolean devEnv = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
    // We need to know, because the names will either be obfuscated or not.
    String mcRenderManagerName = devEnv ? "renderManager" : "field_175616_W";
    String globalRenderManagerName = devEnv ? "renderManager" : "field_175010_j";
    // NOTE: obfuscated name may need updating if Forge changes - search in
    // ~\.gradle\caches\minecraft\de\oceanlabs\mcp\mcp_snapshot\20161220\1.11.2\srgs\mcp-srg.srg
    Field renderMan;
    Field globalRenderMan;
    try {
        renderMan = Minecraft.class.getDeclaredField(mcRenderManagerName);
        renderMan.setAccessible(true);
        renderMan.set(Minecraft.getMinecraft(), newRenderManager);
        globalRenderMan = RenderGlobal.class.getDeclaredField(globalRenderManagerName);
        globalRenderMan.setAccessible(true);
        globalRenderMan.set(Minecraft.getMinecraft().renderGlobal, newRenderManager);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
}
Also used : Minecraft(net.minecraft.client.Minecraft) RenderGlobal(net.minecraft.client.renderer.RenderGlobal) Field(java.lang.reflect.Field) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 53 with Minecraft

use of net.minecraft.client.Minecraft in project RFToolsDimensions by McJty.

the class SkyRenderer method registerSkybox.

public static void registerSkybox(GenericWorldProvider provider, final SkyType skyType) {
    provider.setSkyRenderer(new IRenderHandler() {

        @Override
        public void render(float partialTicks, WorldClient world, Minecraft mc) {
            SkyRenderer.renderSkyTexture(skyType.sky, skyType.sky2, skyType.skyboxType);
        }
    });
    provider.setCloudRenderer(doNothingRenderHandler);
}
Also used : IRenderHandler(net.minecraftforge.client.IRenderHandler) WorldClient(net.minecraft.client.multiplayer.WorldClient) Minecraft(net.minecraft.client.Minecraft)

Example 54 with Minecraft

use of net.minecraft.client.Minecraft in project RFToolsDimensions by McJty.

the class SkyRenderer method registerSky.

public static void registerSky(GenericWorldProvider provider, final DimensionInformation information) {
    provider.setSkyRenderer(new IRenderHandler() {

        @Override
        public void render(float partialTicks, WorldClient world, Minecraft mc) {
            SkyRenderer.renderSky(partialTicks, provider);
        }
    });
    provider.setCloudRenderer(null);
}
Also used : IRenderHandler(net.minecraftforge.client.IRenderHandler) WorldClient(net.minecraft.client.multiplayer.WorldClient) Minecraft(net.minecraft.client.Minecraft)

Example 55 with Minecraft

use of net.minecraft.client.Minecraft in project Almura by AlmuraDev.

the class RootContentLoader method insertResourcePack.

// TODO(kashike); find a better way to do this
@Listener
@SideOnly(Side.CLIENT)
public void insertResourcePack(final GamePreInitializationEvent event) {
    final Minecraft client = Minecraft.getMinecraft();
    for (final AbstractFileSystemSearchEntry qrp : this.entries(AbstractFileSystemSearchEntry.class)) {
        client.defaultResourcePacks.add(new DirectoryResourcePack(qrp));
    }
    client.refreshResources();
}
Also used : Minecraft(net.minecraft.client.Minecraft) Listener(org.spongepowered.api.event.Listener) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Minecraft (net.minecraft.client.Minecraft)100 ItemStack (net.minecraft.item.ItemStack)17 ScaledResolution (net.minecraft.client.gui.ScaledResolution)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 ArrayList (java.util.ArrayList)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 FontRenderer (net.minecraft.client.gui.FontRenderer)6 WorldClient (net.minecraft.client.multiplayer.WorldClient)6 World (net.minecraft.world.World)6 Tessellator (net.minecraft.client.renderer.Tessellator)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 Block (net.minecraft.block.Block)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 SimplePageView (com.almuradev.almura.feature.guide.client.gui.SimplePageView)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)3 GuiScreen (net.minecraft.client.gui.GuiScreen)3