mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Yay, reusing renders.
This commit is contained in:
1 parent
10865a9bd3
commit
7d87c9ae97
3 files changed
+126
No files matched your search
@@ -32,9 +32,11 @@ import vazkii.botania.client.render.block.RenderSpreader;
|
||||
import vazkii.botania.client.render.item.RenderLens;
|
||||
import vazkii.botania.client.render.tile.RenderTileAltar;
|
||||
import vazkii.botania.client.render.tile.RenderTilePool;
|
||||
import vazkii.botania.client.render.tile.RenderTileRuneAltar;
|
||||
import vazkii.botania.client.render.tile.RenderTileSpreader;
|
||||
import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TilePool;
|
||||
import vazkii.botania.common.block.tile.TileRuneAltar;
|
||||
import vazkii.botania.common.block.tile.TileSpreader;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.proxy.CommonProxy;
|
||||
@@ -71,6 +73,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Feb 2, 2014, 6:37:00 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.model;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ModelSpinningCubes extends ModelBase {
|
||||
|
||||
ModelRenderer spinningCube;
|
||||
|
||||
public ModelSpinningCubes() {
|
||||
spinningCube = new ModelRenderer(this, 42, 0);
|
||||
spinningCube.addBox(0F, 0F, 0F, 1, 1, 1);
|
||||
spinningCube.setRotationPoint(0F, 0F, 0F);
|
||||
spinningCube.setTextureSize(64, 64);
|
||||
}
|
||||
|
||||
public void renderSpinningCubes(int cubes, int repeat, int origRepeat) {
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
final float modifier = 6F;
|
||||
final float rotationModifier = 0.2F;
|
||||
final float radiusBase = 0.35F;
|
||||
final float radiusMod = 0.05F;
|
||||
|
||||
double ticks = Minecraft.getMinecraft().thePlayer.ticksExisted - 1.3 * (origRepeat - repeat);
|
||||
float offsetPerCube = 360 / cubes;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.025F, 0.85F, -0.025F);
|
||||
for(int i = 0; i < cubes; i++) {
|
||||
float offset = offsetPerCube * i;
|
||||
float deg = (int) (ticks / rotationModifier % 360F + offset);
|
||||
float rad = deg * (float) Math.PI / 180F;
|
||||
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
|
||||
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
|
||||
float x = (float) (radiusX * Math.cos(rad));
|
||||
float z = (float) (radiusZ * Math.sin(rad));
|
||||
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(x, y, z);
|
||||
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
|
||||
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
|
||||
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
|
||||
|
||||
GL11.glRotatef(deg, xRotate, yRotate, zRotate);
|
||||
if(repeat < origRepeat) {
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.2F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
} else GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
int light = 15728880;
|
||||
int lightmapX = light % 65536;
|
||||
int lightmapY = light / 65536;
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
||||
spinningCube.render(1F / 16F);
|
||||
|
||||
if(repeat < origRepeat)
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
if(repeat != 0)
|
||||
renderSpinningCubes(cubes, repeat - 1, origRepeat);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Feb 2, 2014, 6:34:45 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.model.ModelSpinningCubes;
|
||||
|
||||
public class RenderTileRuneAltar extends TileEntitySpecialRenderer {
|
||||
|
||||
ModelSpinningCubes cubes = new ModelSpinningCubes();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glTranslated(x + 0.5, y + 1.8, z + 0.5);
|
||||
GL11.glRotatef(180F, 1F, 0F, 1F);
|
||||
int repeat = 15;
|
||||
cubes.renderSpinningCubes(2, repeat, repeat);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user