mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fixed skybox chainloader
This commit is contained in:
parent
6954dcf993
commit
9f92785ec6
@ -41,7 +41,8 @@ import com.hbm.render.util.RenderAccessoryUtility;
|
||||
import com.hbm.render.util.RenderOverhead;
|
||||
import com.hbm.render.util.RenderScreenOverlay;
|
||||
import com.hbm.render.util.SoyuzPronter;
|
||||
import com.hbm.render.world.RenderNTMSkybox;
|
||||
import com.hbm.render.world.RenderNTMSkyboxChainloader;
|
||||
import com.hbm.render.world.RenderNTMSkyboxImpact;
|
||||
import com.hbm.sound.MovingSoundChopper;
|
||||
import com.hbm.sound.MovingSoundChopperMine;
|
||||
import com.hbm.sound.MovingSoundCrashing;
|
||||
@ -688,8 +689,17 @@ public class ModEventHandlerClient {
|
||||
if(world != null && world.provider instanceof WorldProviderSurface) {
|
||||
|
||||
IRenderHandler sky = world.provider.getSkyRenderer();
|
||||
if(!(sky instanceof RenderNTMSkybox)) {
|
||||
world.provider.setSkyRenderer(new RenderNTMSkybox());
|
||||
|
||||
if(ModEventHandler.dust > 0 || ModEventHandler.fire > 0) {
|
||||
|
||||
if(!(sky instanceof RenderNTMSkyboxImpact)) {
|
||||
world.provider.setSkyRenderer(new RenderNTMSkyboxImpact());
|
||||
}
|
||||
} else {
|
||||
|
||||
if(!(sky instanceof RenderNTMSkyboxChainloader)) {
|
||||
world.provider.setSkyRenderer(new RenderNTMSkyboxChainloader(sky));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
package com.hbm.render.world;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.extprop.HbmLivingProps;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
|
||||
public class RenderNTMSkyboxChainloader extends IRenderHandler { //why an abstract class uses the I-prefix is beyond me but ok, alright, whatever
|
||||
|
||||
/*
|
||||
* To get the terrain render order right, making a sky rendering handler is absolutely necessary. Turns out MC can only handle one of these, so what do we do?
|
||||
* We make out own renderer, grab any existing renderers that are already occupying the slot, doing what is effectively chainloading while adding our own garbage.
|
||||
* If somebody does the exact same thing as we do we might be screwed due to increasingly long recursive loops but we can fix that too, no worries.
|
||||
*/
|
||||
private IRenderHandler parent;
|
||||
|
||||
private static final ResourceLocation digammaStar = new ResourceLocation("hbm:textures/misc/star_digamma.png");
|
||||
private static final ResourceLocation bobmazonSat = new ResourceLocation("hbm:textures/misc/sat_bobmazon.png");
|
||||
|
||||
/*
|
||||
* If the skybox was rendered successfully in the last tick (even from other mods' skyboxes chainloading this one) then we don't need to add it again
|
||||
*/
|
||||
public static boolean didLastRender = false;
|
||||
|
||||
public RenderNTMSkyboxChainloader(IRenderHandler parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float partialTicks, WorldClient world, Minecraft mc) {
|
||||
|
||||
if(parent != null) {
|
||||
|
||||
//basically a recursion-brake to prevent endless rendering loops from other mods' chainloaders.
|
||||
//do other mods' skyboxes even employ chainloading?
|
||||
if(!didLastRender) {
|
||||
didLastRender = true;
|
||||
parent.render(partialTicks, world, mc);
|
||||
didLastRender = false;
|
||||
}
|
||||
|
||||
} else{
|
||||
RenderGlobal rg = Minecraft.getMinecraft().renderGlobal;
|
||||
world.provider.setSkyRenderer(null);
|
||||
rg.renderSky(partialTicks);
|
||||
world.provider.setSkyRenderer(this);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_FOG);
|
||||
OpenGlHelper.glBlendFunc(770, 1, 1, 0);
|
||||
|
||||
float brightness = (float) Math.sin(world.getCelestialAngle(partialTicks) * Math.PI);
|
||||
brightness *= brightness;
|
||||
|
||||
GL11.glColor4f(brightness, brightness, brightness, 1.0F);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(140.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-40.0F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(digammaStar);
|
||||
|
||||
float digamma = HbmLivingProps.getDigamma(Minecraft.getMinecraft().thePlayer);
|
||||
float var12 = 1F * (1 + digamma * 0.25F);
|
||||
double dist = 100D - digamma * 2.5;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(-var12, dist, -var12, 0.0D, 0.0D);
|
||||
tessellator.addVertexWithUV(var12, dist, -var12, 0.0D, 1.0D);
|
||||
tessellator.addVertexWithUV(var12, dist, var12, 1.0D, 1.0D);
|
||||
tessellator.addVertexWithUV(-var12, dist, var12, 1.0D, 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(-40.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef((System.currentTimeMillis() % (360 * 1000) / 1000F), 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef((System.currentTimeMillis() % (360 * 100) / 100F), 1.0F, 0.0F, 0.0F);
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(bobmazonSat);
|
||||
|
||||
var12 = 0.5F;
|
||||
dist = 100D;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(-var12, dist, -var12, 0.0D, 0.0D);
|
||||
tessellator.addVertexWithUV(var12, dist, -var12, 0.0D, 1.0D);
|
||||
tessellator.addVertexWithUV(var12, dist, var12, 1.0D, 1.0D);
|
||||
tessellator.addVertexWithUV(-var12, dist, var12, 1.0D, 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
|
||||
GL11.glEnable(GL11.GL_FOG);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,7 +24,7 @@ import com.hbm.main.ModEventHandler;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RenderNTMSkybox extends IRenderHandler {
|
||||
public class RenderNTMSkyboxImpact extends IRenderHandler {
|
||||
|
||||
private static final ResourceLocation sunTexture = new ResourceLocation("textures/environment/sun.png");
|
||||
private static final ResourceLocation moonTexture = new ResourceLocation("textures/environment/moon_phases.png");
|
||||
@ -42,7 +42,7 @@ public class RenderNTMSkybox extends IRenderHandler {
|
||||
/// I had to break your compat feature for other mods' skyboxes in order to
|
||||
/// make the skybox render correctly after Tom. Sorry about that. -Pu
|
||||
|
||||
public RenderNTMSkybox() {
|
||||
public RenderNTMSkyboxImpact() {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE);
|
||||
this.renderStars();
|
||||
@ -171,7 +171,7 @@ public class RenderNTMSkybox extends IRenderHandler {
|
||||
{
|
||||
GL11.glColor4d(1, 1, 1, rain);
|
||||
f10 = 20.0F;
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderNTMSkybox.moonTexture);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderNTMSkyboxImpact.moonTexture);
|
||||
float sinphi = FMLClientHandler.instance().getClient().theWorld.getMoonPhase();
|
||||
final int cosphi = (int) (sinphi % 4);
|
||||
final int var29 = (int) (sinphi / 4 % 2);
|
||||
Loading…
x
Reference in New Issue
Block a user