equivalent-exchange-3/ee3_common/com/pahimar/ee3/client/renderer/texturefx/TextureRedWaterFlowFX.java

130 lines
3.7 KiB
Java
Raw Normal View History

package com.pahimar.ee3.client.renderer.texturefx;
2012-09-11 04:07:59 +02:00
import net.minecraft.client.renderer.RenderEngine;
2012-09-11 04:07:59 +02:00
import org.lwjgl.opengl.GL11;
import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.lib.Sprites;
2012-09-11 04:07:59 +02:00
import cpw.mods.fml.client.FMLTextureFX;
2012-10-27 23:41:02 +02:00
/**
* TextureRedWaterFlowFX
*
* TextureFX for flowing Red Water
*
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
2012-09-11 04:07:59 +02:00
public class TextureRedWaterFlowFX extends FMLTextureFX {
protected float[] red = new float[256];
protected float[] green = new float[256];
protected float[] blue = new float[256];
protected float[] alpha = new float[256];
private int tickCounter = 0;
public TextureRedWaterFlowFX() {
2012-09-11 04:07:59 +02:00
super(ModBlocks.redWaterStill.blockIndexInTexture + 1);
tileSize = 2;
setup();
}
@Override
public void setup() {
2012-09-11 04:07:59 +02:00
super.setup();
red = new float[tileSizeSquare];
green = new float[tileSizeSquare];
blue = new float[tileSizeSquare];
alpha = new float[tileSizeSquare];
tickCounter = 0;
}
@Override
public void bindImage(RenderEngine renderEngine) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, renderEngine.getTexture(Sprites.SPRITE_SHEET_LOCATION + Sprites.BLOCK_SPRITE_SHEET));
2012-09-11 04:07:59 +02:00
}
public void onTick() {
2012-09-11 04:07:59 +02:00
++this.tickCounter;
int var1;
int var2;
float var3;
int var5;
int var6;
for (var1 = 0; var1 < tileSizeBase; ++var1) {
for (var2 = 0; var2 < tileSizeBase; ++var2) {
var3 = 0.0F;
for (int var4 = var2 - 2; var4 <= var2; ++var4) {
var5 = var1 & tileSizeMask;
var6 = var4 & tileSizeMask;
var3 += this.red[var5 + var6 * tileSizeBase];
}
this.green[var1 + var2 * tileSizeBase] = var3 / 3.2F + this.blue[var1 + var2 * tileSizeBase] * 0.8F;
2012-09-11 04:07:59 +02:00
}
}
for (var1 = 0; var1 < tileSizeBase; ++var1) {
for (var2 = 0; var2 < tileSizeBase; ++var2) {
this.blue[var1 + var2 * tileSizeBase] += this.alpha[var1 + var2 * tileSizeBase] * 0.05F;
2012-09-11 04:07:59 +02:00
if (this.blue[var1 + var2 * tileSizeBase] < 0.0F) {
this.blue[var1 + var2 * tileSizeBase] = 0.0F;
}
this.alpha[var1 + var2 * tileSizeBase] -= 0.3F;
if (Math.random() < 0.2D) {
this.alpha[var1 + var2 * tileSizeBase] = 0.5F;
}
}
}
float[] var12 = this.green;
this.green = this.red;
this.red = var12;
for (var2 = 0; var2 < tileSizeSquare; ++var2) {
var3 = this.red[var2 - this.tickCounter * tileSizeBase & tileSizeSquareMask];
2012-09-11 04:07:59 +02:00
if (var3 > 1.0F) {
var3 = 1.0F;
}
if (var3 < 0.0F) {
var3 = 0.0F;
}
float var13 = var3 * var3;
var5 = (int) (32.0F + var13 * 32.0F);
var6 = (int) (50.0F + var13 * 64.0F);
int var7 = 255;
int var8 = (int) (146.0F + var13 * 50.0F);
if (this.anaglyphEnabled) {
int var9 = (var5 * 30 + var6 * 59 + var7 * 11) / 100;
int var10 = (var5 * 30 + var6 * 70) / 100;
int var11 = (var5 * 30 + var7 * 70) / 100;
var5 = var9;
var6 = var10;
var7 = var11;
}
this.imageData[var2 * 4 + 0] = (byte) var5;
this.imageData[var2 * 4 + 1] = (byte) 0;
this.imageData[var2 * 4 + 2] = (byte) 0;
this.imageData[var2 * 4 + 3] = (byte) 192;
}
}
}