Some tweaks to the Red String renderer.

This commit is contained in:
Lizbeth Rika committed 2014-11-14 23:37:11 +00:00
1 parent 66a81d6401
commit c3a3b93da1
2 files changed
+20 -8

No files matched your search

@@ -15,33 +15,39 @@ import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import vazkii.botania.common.block.tile.string.TileRedString;
import vazkii.botania.common.item.ModItems;
import codechicken.lib.vec.Vector3;
public final class RedStringRenderer {
public static final Queue<TileRedString> redStringTiles = new ArrayDeque();
static float sizeAlpha = 0F;
public static void renderAll() {
TileRedString tile;
if(!redStringTiles.isEmpty()) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor3f(0.6F, 0F, 0F);
GL11.glColor4f(1F, 0F, 0F, sizeAlpha);
Tessellator.renderingWorldRenderer = false;
TileRedString tile;
while((tile = redStringTiles.poll()) != null)
renderTile(tile);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
@@ -49,6 +55,15 @@ public final class RedStringRenderer {
}
}
public static void tick() {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
boolean hasWand = player != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == ModItems.twigWand;
if(sizeAlpha > 0F && !hasWand)
sizeAlpha -= 0.1F;
else if(sizeAlpha < 1F &&hasWand)
sizeAlpha += 0.1F;
}
private static void renderTile(TileRedString tile) {
ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata());
ChunkCoordinates bind = tile.getBinding();
@@ -86,7 +101,7 @@ public final class RedStringRenderer {
private static void addVertexAtWithTranslation(Tessellator tess, ForgeDirection dir, double xpos, double ypos, double zpos, double rand, double l) {
double freq = 20;
double ampl = 0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1;
double ampl = (0.15 * (Math.sin(l * 2F) * 0.5 + 0.5) + 0.1) * sizeAlpha;
double randMul = 0.05;
double x = xpos + Math.sin(l * freq) * ampl * Math.abs(Math.abs(dir.offsetX) - 1) + rand * randMul;
double y = ypos + Math.cos(l * freq) * ampl * Math.abs(Math.abs(dir.offsetY) - 1) + rand * randMul;
@@ -89,7 +89,7 @@ import vazkii.botania.common.block.tile.TileTerraPlate;
import vazkii.botania.common.block.tile.TileTinyPotato;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.block.tile.mana.TileSpreader;
import vazkii.botania.common.block.tile.string.TileRedStringContainer;
import vazkii.botania.common.block.tile.string.TileRedString;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.core.proxy.CommonProxy;
@@ -105,7 +105,6 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class ClientProxy extends CommonProxy {
@@ -169,9 +168,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileStarfield.class, new RenderTileStarfield());
ClientRegistry.bindTileEntitySpecialRenderer(TileBrewery.class, new RenderTileBrewery());
ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate());
RenderTileRedString redStringRender = new RenderTileRedString();
ClientRegistry.bindTileEntitySpecialRenderer(TileRedStringContainer.class, redStringRender);
ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString());
if(Loader.instance().getMCVersionString().equals("Minecraft 1.7.10"))
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride());