use of net.minecraft.client.renderer.RenderGlobal 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();
}
}
use of net.minecraft.client.renderer.RenderGlobal in project GregTech by GregTechCE.
the class DebugRenderer method onRenderWorldLast.
@SubscribeEvent
public static void onRenderWorldLast(RenderWorldLastEvent event) {
RenderGlobal context = event.getContext();
float partialTicks = event.getPartialTicks();
EntityPlayer player = Minecraft.getMinecraft().player;
WorldClient world = Minecraft.getMinecraft().world;
if (blockPosSet.size() == 0) {
return;
}
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
GlStateManager.translate(-playerX, -playerY, -playerZ);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.disableTexture2D();
GlStateManager.disableDepth();
GlStateManager.glLineWidth(2.5F);
{
blockPosSet.forEach(blockPos -> {
double distance = MathHelper.sqrt(player.getDistanceSqToCenter(blockPos));
if (distance > 64F) {
return;
}
AxisAlignedBB box = new AxisAlignedBB(blockPos.getX() + 0.25, blockPos.getY() + 0.25, blockPos.getZ() + 0.25, blockPos.getX() + 0.75, blockPos.getY() + 0.75, blockPos.getZ() + 0.75);
RenderGlobal.drawSelectionBoundingBox(box, 0.0F, 1F, 0.0F, 0.5F);
TileEntity tileEntity = world.getTileEntity(blockPos);
if (tileEntity != null) {
AxisAlignedBB axisAlignedBB = new AxisAlignedBB(blockPos.getX() + 0.25, blockPos.getY() + 0.25, blockPos.getZ() + 0.25, blockPos.getX() + 0.75, blockPos.getY() + 0.75, blockPos.getZ() + 0.75);
RenderGlobal.drawSelectionBoundingBox(axisAlignedBB, 0.0F, 0.0F, 1F, 0.5F);
// ((TileEntityCableEmitter) tileEntity).outgoingConnections.forEach(connectionInfo -> {
// RenderGlobal.drawSelectionBoundingBox(new AxisAlignedBB(connectionInfo.receiverContainer.getPos()), 0.0F, 1F, 1F, 0.5F);
//
// });
}
});
}
GlStateManager.enableDepth();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.RenderGlobal in project ForestryMC by ForestryMC.
the class TickHandlerCoreClient method onClientTick.
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
if (event.phase == Phase.END) {
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft != null) {
EntityPlayer player = minecraft.player;
if (player != null) {
boolean hasNaturalistEye = GeneticsUtil.hasNaturalistEye(player);
if (this.hasNaturalistEye != hasNaturalistEye) {
this.hasNaturalistEye = hasNaturalistEye;
RenderGlobal renderGlobal = minecraft.renderGlobal;
if (renderGlobal != null) {
renderGlobal.markBlockRangeForRenderUpdate((int) player.posX - 32, (int) player.posY - 32, (int) player.posZ - 32, (int) player.posX + 32, (int) player.posY + 32, (int) player.posZ + 32);
}
}
}
}
}
}
Aggregations