More work on Red Water - lots still to do

This commit is contained in:
pahimar 2012-07-20 16:07:50 -04:00
parent fc83d9dd16
commit 764737a1c4
15 changed files with 361 additions and 25 deletions

View file

@ -8,9 +8,12 @@ import cpw.mods.fml.common.ReflectionHelper;
import ee3.mod_EE3;
import ee3.client.core.KeyBindingHandler;
import ee3.client.core.SoundHandler;
import ee3.client.core.TextureRedWaterFX;
import ee3.client.core.TextureRedWaterFlowFX;
import ee3.client.gui.GuiPortableCrafting;
import ee3.core.interfaces.IProxy;
import ee3.lib.GuiIds;
import ee3.lib.Reference;
import static ee3.lib.CustomItemRarity.*;
import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityPlayer;
@ -44,12 +47,6 @@ public class EEProxy implements IProxy {
}
@Override
public void registerTranslations() {
// TODO Auto-generated method stub
}
@Override
public File getMinecraftDir() {
return Minecraft.getMinecraftDir();
@ -124,5 +121,17 @@ public class EEProxy implements IProxy {
public boolean isPortableCraftingGUIOpen() {
return (ModLoader.getMinecraftInstance().currentScreen instanceof GuiPortableCrafting);
}
@Override
public void preloadTextures() {
MinecraftForgeClient.preloadTexture(Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET);
}
@Override
public void initTextureFX() {
ModLoader.getMinecraftInstance().renderEngine.registerTextureFX(new TextureRedWaterFX());
ModLoader.getMinecraftInstance().renderEngine.registerTextureFX(new TextureRedWaterFlowFX());
}
}

View file

@ -0,0 +1,110 @@
package ee3.client.core;
import cpw.mods.fml.client.FMLTextureFX;
import ee3.block.ModBlocks;
/**
* TODO Class Description
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
* Based heavily off of TextureWaterFX (like, 99%)
*/
public class TextureRedWaterFX 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 TextureRedWaterFX() {
super(ModBlocks.redWaterStill.blockIndexInTexture);
setup();
}
@Override
public void setup() {
super.setup();
red = new float[tileSizeSquare];
green = new float[tileSizeSquare];
blue = new float[tileSizeSquare];
alpha = new float[tileSizeSquare];
tickCounter = 0;
}
public void onTick() {
++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 = var1 - 1; var4 <= var1 + 1; ++var4) {
var5 = var4 & tileSizeMask;
var6 = var2 & tileSizeMask;
var3 += this.red[var5 + var6 * tileSizeBase];
}
this.green[var1 + var2 * tileSizeBase] = var3 / 3.3F + this.blue[var1 + var2 * tileSizeBase] * 0.8F;
}
}
for (var1 = 0; var1 < tileSizeBase; ++var1) {
for (var2 = 0; var2 < tileSizeBase; ++var2) {
this.blue[var1 + var2 * tileSizeBase] += this.alpha[var1 + var2 * tileSizeBase] * 0.05F;
if (this.blue[var1 + var2 * tileSizeBase] < 0.0F) {
this.blue[var1 + var2 * tileSizeBase] = 0.0F;
}
this.alpha[var1 + var2 * tileSizeBase] -= 0.1F;
if (Math.random() < 0.05D) {
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];
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)var6;
this.imageData[var2 * 4 + 2] = (byte)var7;
this.imageData[var2 * 4 + 3] = (byte)var8;
}
}
}

View file

@ -0,0 +1,105 @@
package ee3.client.core;
import cpw.mods.fml.client.FMLTextureFX;
import ee3.block.ModBlocks;
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() {
super(ModBlocks.redWaterStill.blockIndexInTexture + 1);
tileSize = 2;
setup();
}
@Override
public void setup() {
super.setup();
red = new float[tileSizeSquare];
green = new float[tileSizeSquare];
blue = new float[tileSizeSquare];
alpha = new float[tileSizeSquare];
tickCounter = 0;
}
public void onTick() {
++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;
}
}
for (var1 = 0; var1 < tileSizeBase; ++var1) {
for (var2 = 0; var2 < tileSizeBase; ++var2) {
this.blue[var1 + var2 * tileSizeBase] += this.alpha[var1 + var2 * tileSizeBase] * 0.05F;
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];
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)var6;
this.imageData[var2 * 4 + 2] = (byte)var7;
this.imageData[var2 * 4 + 3] = (byte)var8;
}
}
}

View file

@ -1,12 +1,21 @@
package ee3.block;
import ee3.lib.Reference;
import net.minecraft.src.BlockFluid;
import net.minecraft.src.Material;
public class BlockRedWaterFlowing extends BlockFluid {
protected BlockRedWaterFlowing(int par1, Material par2Material) {
super(par1, par2Material);
protected BlockRedWaterFlowing(int id, Material material) {
super(id, material);
this.blockHardness = 100F;
this.setLightOpacity(3);
this.setBlockName("redWaterFlowing");
}
@Override
public String getTextureFile() {
return Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET;
}
}

View file

@ -1,13 +1,32 @@
package ee3.block;
import ee3.core.helper.LocalizationHelper;
import ee3.lib.Reference;
import ee3.lib.RenderIds;
import net.minecraft.src.BlockStationary;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.World;
public class BlockRedWaterStill extends BlockStationary {
protected BlockRedWaterStill(int par1, Material par2Material) {
super(par1, par2Material);
// TODO Auto-generated constructor stub
protected BlockRedWaterStill(int id, Material material) {
super(id, material);
this.blockHardness = 100F;
this.setLightOpacity(3);
setBlockName("redWaterStill");
disableStats();
setRequiresSelfNotify();
}
@Override
public String getBlockName() {
return LocalizationHelper.instance.get("tile.redWaterStill");
}
@Override
public String getTextureFile() {
return Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET;
}
}

View file

@ -0,0 +1,35 @@
package ee3.block;
import net.minecraft.src.Block;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.ModLoader;
import ee3.lib.BlockIds;
/**
* TODO Class Description
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class ModBlocks {
public static BlockRedWaterStill redWaterStill;
public static BlockRedWaterFlowing redWaterFlowing;
public static void init() {
redWaterStill = new BlockRedWaterStill(BlockIds.RED_WATER_STILL, Material.water);
redWaterFlowing = new BlockRedWaterFlowing(BlockIds.RED_WATER_STILL + 1, Material.water);
ModLoader.addName(redWaterStill, "Red Water (Still)");
ModLoader.addName(redWaterFlowing, "Red Water (Flowing)");
ModLoader.registerBlock(redWaterStill);
ModLoader.registerBlock(redWaterFlowing);
ModLoader.addShapelessRecipe(new ItemStack(redWaterStill), Block.cobblestone);
ModLoader.addShapelessRecipe(new ItemStack(redWaterFlowing), Block.cobblestone, Block.cobblestone);
}
}

View file

@ -17,12 +17,14 @@ import net.minecraft.src.forge.IGuiHandler;
*/
public interface IProxy {
public abstract void preloadTextures();
public abstract void initTextureFX();
public abstract void registerRenderInformation();
public abstract void registerTileEntities();
public abstract void registerTranslations();
public abstract File getMinecraftDir();
public abstract boolean isRemote();

View file

@ -14,15 +14,11 @@ import net.minecraft.src.ModLoader;
*/
public class ModItems {
private static boolean initialized;
public static Item miniumShard;
public static Item miniumStone;
public static Item philStone;
public static void init() {
if (initialized)
initialized = true;
/* Initialise each mod item individually */
miniumShard = new ItemMiniumShard(ItemIds.MINIUM_SHARD).setIconCoord(0, 0).setItemName("miniumShard");

View file

@ -0,0 +1,14 @@
package ee3.lib;
/**
* TODO Class Description
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class BlockIds {
public static int RED_WATER_FLOWING = 250;
public static int RED_WATER_STILL = 251;
}

View file

@ -18,6 +18,7 @@ public class Reference {
public static final String SPRITE_SHEET_LOCATION = "/ee3/art/sprites/";
public static final String ITEM_SPRITE_SHEET = "ee3_items.png";
public static final String BLOCK_SPRITE_SHEET = "ee3_blocks.png";
public static final String GUI_SHEET_LOCATION = "/ee3/art/gui/";
public static final String ARMOR_SHEET_LOCATION = "/ee3/art/armor/";
public static final String SOUND_RESOURCE_LOCATION = "ee3/sound/";

View file

@ -0,0 +1,20 @@
package ee3.lib;
import ee3.mod_EE3;
import net.minecraft.src.ModLoader;
/**
* TODO Class Description
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class RenderIds {
public static int RED_WATER_MODEL;
public static void init() {
RED_WATER_MODEL = ModLoader.getUniqueBlockModelID(mod_EE3.instance(), false);
}
}

View file

@ -1,6 +1,7 @@
package ee3;
import cpw.mods.fml.common.FMLCommonHandler;
import ee3.block.ModBlocks;
import ee3.core.ConfigurationManager;
import ee3.core.CraftingHandler;
import ee3.core.EntityLivingHandler;
@ -12,6 +13,7 @@ import ee3.gui.GuiHandler;
import ee3.item.ModItems;
import ee3.lib.ItemIds;
import ee3.lib.Reference;
import ee3.lib.RenderIds;
import ee3.lib.Sounds;
import ee3.lib.Version;
import ee3.network.PacketHandler;
@ -72,9 +74,21 @@ public class mod_EE3 extends NetworkMod {
// Add in the custom Item rarity types
this.proxy.addCustomEnumRarityTypes();
// Pre-load Textures
this.proxy.preloadTextures();
// Initialise the render models
RenderIds.init();
// Initialise the mod blocks
ModBlocks.init();
// Initialise the mod items
ModItems.init();
// Init TextureFX
this.proxy.initTextureFX();
// Initialise the Philosopher Stone recipes
RecipesPhilStone.initRecipes();

View file

@ -37,12 +37,6 @@ public class EEProxy implements IProxy {
}
@Override
public void registerTranslations() {
// TODO Auto-generated method stub
}
@Override
public File getMinecraftDir() {
return new File(".");
@ -102,4 +96,10 @@ public class EEProxy implements IProxy {
return false;
}
@Override
public void preloadTextures() { }
@Override
public void initTextureFX() { }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,3 +1,5 @@
item.miniumShard=Minium Shard
item.miniumStone=Minium Stone
item.philosophersStone=Philosophers Stone
item.philosophersStone=Philosophers Stone
tile.redWaterStill=Red Water
tile.redWaterFlowing=Red Water