Red Water work, lots to do still

This commit is contained in:
pahimar 2012-09-10 22:07:59 -04:00
parent 99359f3c32
commit 098a719bb4
13 changed files with 357 additions and 10 deletions

View file

@ -4,6 +4,7 @@ import net.minecraft.src.EnumRarity;
import net.minecraftforge.client.EnumHelperClient;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -11,6 +12,8 @@ import ee3.client.core.handlers.KeyBindingHandler;
import ee3.client.core.handlers.SoundHandler;
import ee3.client.lib.KeyBindings;
import ee3.client.render.RenderCalcinator;
import ee3.client.render.TextureRedWaterFX;
import ee3.client.render.TextureRedWaterFlowFX;
import ee3.common.core.CommonProxy;
import ee3.common.lib.Reference;
import ee3.common.lib.RenderIds;
@ -68,6 +71,9 @@ public class ClientProxy extends CommonProxy {
MinecraftForgeClient.preloadTexture(Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET);
MinecraftForgeClient.preloadTexture(Reference.SPRITE_SHEET_LOCATION + Reference.ITEM_SPRITE_SHEET);
FMLClientHandler.instance().getClient().renderEngine.registerTextureFX(new TextureRedWaterFX());
FMLClientHandler.instance().getClient().renderEngine.registerTextureFX(new TextureRedWaterFlowFX());
}
@Override

View file

@ -0,0 +1,116 @@
package ee3.client.render;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.RenderEngine;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.FMLTextureFX;
import ee3.common.block.ModBlocks;
import ee3.common.lib.Reference;
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;
}
@Override
public void bindImage(RenderEngine renderEngine) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, renderEngine.getTexture(Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET));
}
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) 0;
this.imageData[var2 * 4 + 2] = (byte) 0;
this.imageData[var2 * 4 + 3] = (byte) 192;
}
}
}

View file

@ -0,0 +1,118 @@
package ee3.client.render;
import net.minecraft.src.RenderEngine;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLTextureFX;
import ee3.common.block.ModBlocks;
import ee3.common.lib.Reference;
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;
}
@Override
public void bindImage(RenderEngine renderEngine) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, renderEngine.getTexture(Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET));
}
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) 0;
this.imageData[var2 * 4 + 2] = (byte) 0;
this.imageData[var2 * 4 + 3] = (byte) 192;
}
}
}

View file

@ -61,9 +61,6 @@ public class EquivalentExchange3 {
@Init
public void load(FMLInitializationEvent event) {
// Initialize custom rendering and pre-load textures (Client only)
proxy.initRenderingAndTextures();
// Initialize the custom item rarity types
proxy.initCustomRarityTypes();
@ -92,6 +89,9 @@ public class EquivalentExchange3 {
// Initialize mod tile entities
proxy.initTileEntities();
// Initialize custom rendering and pre-load textures (Client only)
proxy.initRenderingAndTextures();
// Load the Transmutation Stone recipes
RecipesTransmutationStone.init();

View file

@ -0,0 +1,23 @@
package ee3.common.block;
import ee3.common.lib.Reference;
import net.minecraft.src.BlockFlowing;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Material;
public class BlockRedWaterFlowing extends BlockFlowing {
protected BlockRedWaterFlowing(int id, Material material) {
super(id, material);
this.blockHardness = 100F;
this.setLightOpacity(3);
this.setBlockName("redWaterFlowing");
this.setCreativeTab(CreativeTabs.tabDeco);
}
@Override
public String getTextureFile() {
return Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET;
}
}

View file

@ -0,0 +1,25 @@
package ee3.common.block;
import ee3.common.lib.Reference;
import net.minecraft.src.BlockStationary;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Material;
public class BlockRedWaterStill extends BlockStationary {
protected BlockRedWaterStill(int id, Material material) {
super(id, material);
this.blockHardness = 100F;
this.setLightOpacity(3);
setBlockName("redWaterStill");
disableStats();
setRequiresSelfNotify();
setCreativeTab(CreativeTabs.tabDeco);
}
@Override
public String getTextureFile() {
return Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET;
}
}

View file

@ -4,22 +4,32 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import ee3.common.lib.BlockIds;
import net.minecraft.src.Block;
import net.minecraft.src.Material;
public class ModBlocks {
/* Block name constants */
public static final String CALCINATOR_NAME = "calcinator";
public static final String RED_WATER_STILL_NAME = "redWaterStill";
/* Mod block instances */
public static Block calcinator;
public static Block redWaterStill;
public static Block redWaterFlowing;
public static void init() {
calcinator = new BlockCalcinator(BlockIds.CALCINATOR).setBlockName(CALCINATOR_NAME);
redWaterStill = new BlockRedWaterStill(BlockIds.RED_WATER_STILL, Material.water);
redWaterFlowing = new BlockRedWaterFlowing(BlockIds.RED_WATER_STILL - 1, Material.water);
LanguageRegistry.addName(calcinator, "Calcinator");
LanguageRegistry.addName(redWaterStill, "Red Water (Still)");
LanguageRegistry.addName(redWaterFlowing, "Red Water (Flowing)");
GameRegistry.registerBlock(calcinator);
GameRegistry.registerBlock(redWaterStill);
GameRegistry.registerBlock(redWaterFlowing);
}

View file

@ -39,7 +39,7 @@ public class CommonProxy implements IGuiHandler {
public void initTileEntities() {
GameRegistry.registerTileEntity(TileCalcinator.class, "tileCalcinator");
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == GuiIds.PORTABLE_CRAFTING) {

View file

@ -41,6 +41,7 @@ public class ConfigurationHandler {
/* Block Configs */
ConfigurationSettings.AUTO_RESOLVE_BLOCK_IDS = configuration.getOrCreateBooleanProperty(Reference.AUTO_RESOLVE_BLOCK_IDS, CATEGORY_BLOCK, ConfigurationSettings.AUTO_RESOLVE_BLOCK_IDS_DEFAULT).getBoolean(ConfigurationSettings.AUTO_RESOLVE_BLOCK_IDS_DEFAULT);
BlockIds.CALCINATOR = configuration.getOrCreateIntProperty(ModBlocks.CALCINATOR_NAME, CATEGORY_BLOCK, BlockIds.CALCINATOR_DEFAULT).getInt(BlockIds.CALCINATOR_DEFAULT);
BlockIds.RED_WATER_STILL = configuration.getOrCreateIntProperty(ModBlocks.RED_WATER_STILL_NAME, CATEGORY_BLOCK, BlockIds.RED_WATER_STILL_DEFAULT).getInt(BlockIds.RED_WATER_STILL_DEFAULT);
/* Item Configs */
ItemIds.MINIUM_SHARD = configuration.getOrCreateIntProperty(ModItems.MINIUM_SHARD_NAME, CATEGORY_ITEM, ItemIds.MINIUM_SHARD_DEFAULT).getInt(ItemIds.MINIUM_SHARD_DEFAULT);

View file

@ -1,6 +1,10 @@
package ee3.common.core.handlers;
import ee3.common.core.helper.RedWaterHelper;
import ee3.common.lib.Reference;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.Potion;
import net.minecraft.src.PotionEffect;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
@ -11,20 +15,16 @@ public class EntityLivingHandler {
public void onEntityLivingUpdate(LivingUpdateEvent event) {
EntityLiving entity = event.entityLiving;
/*
* Commented out temporarily while we get mod blocks added back in
*
if (entity.worldObj.getWorldTime() % 4 == 0) {
System.out.println(entity.toString());
if (Helper.handleRedWaterDetection(entity)) {
if (RedWaterHelper.handleRedWaterDetection(entity)) {
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, Reference.BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER * Reference.BLOCK_RED_WATER_EFFECT_DURATION_BASE * Reference.SECOND_IN_TICKS, 0));
entity.addPotionEffect(new PotionEffect(Potion.poison.id, Reference.BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER * Reference.BLOCK_RED_WATER_EFFECT_DURATION_BASE * Reference.SECOND_IN_TICKS, 0));
entity.addPotionEffect(new PotionEffect(Potion.blindness.id, Reference.BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER * Reference.BLOCK_RED_WATER_EFFECT_DURATION_BASE * Reference.SECOND_IN_TICKS, 0));
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, Reference.BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER * Reference.BLOCK_RED_WATER_EFFECT_DURATION_BASE * Reference.SECOND_IN_TICKS, 0));
}
}
*/
}
@ForgeSubscribe

View file

@ -0,0 +1,37 @@
package ee3.common.core.helper;
import ee3.common.block.ModBlocks;
import ee3.common.lib.Reference;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Block;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.MathHelper;
import net.minecraft.src.World;
public class RedWaterHelper {
public static boolean handleRedWaterDetection(EntityLiving entity) {
return (isBlockInBB(entity.worldObj, entity.boundingBox, ModBlocks.redWaterFlowing) || isBlockInBB(entity.worldObj, entity.boundingBox, ModBlocks.redWaterStill));
}
public static boolean isBlockInBB(World world, AxisAlignedBB par1AxisAlignedBB, Block block) {
int minX = MathHelper.floor_double(par1AxisAlignedBB.minX - Reference.BLOCK_RED_WATER_RANGE_BASE * Reference.BLOCK_RED_WATER_RANGE_MODIFIER * 1.0D);
int maxX = MathHelper.floor_double(par1AxisAlignedBB.maxX + Reference.BLOCK_RED_WATER_RANGE_BASE * Reference.BLOCK_RED_WATER_RANGE_MODIFIER * 1.0D);
int minY = MathHelper.floor_double(par1AxisAlignedBB.minY - Reference.BLOCK_RED_WATER_RANGE_BASE * Reference.BLOCK_RED_WATER_RANGE_MODIFIER * 1.0D);
int maxY = MathHelper.floor_double(par1AxisAlignedBB.maxY + Reference.BLOCK_RED_WATER_RANGE_BASE * Reference.BLOCK_RED_WATER_RANGE_MODIFIER * 1.0D);
int minZ = MathHelper.floor_double(par1AxisAlignedBB.minZ - Reference.BLOCK_RED_WATER_RANGE_BASE * Reference.BLOCK_RED_WATER_RANGE_MODIFIER * 1.0D);
int maxZ = MathHelper.floor_double(par1AxisAlignedBB.maxZ + Reference.BLOCK_RED_WATER_RANGE_BASE * Reference.BLOCK_RED_WATER_RANGE_MODIFIER * 1.0D);
for (int i = minX; i < maxX; ++i) {
for (int j = minY; j < maxY; ++j) {
for (int k = minZ; k < maxZ; ++k) {
Block currentBlock = Block.blocksList[world.getBlockId(i, j, k)];
if (currentBlock != null && currentBlock.blockID == block.blockID) {
return true;
}
}
}
}
return false;
}
}

View file

@ -13,9 +13,10 @@ public class BlockIds {
/* Default block ids */
public static int CALCINATOR_DEFAULT = 600;
public static int RED_WATER_STILL_DEFAULT = 500;
/* Current block ids */
public static int RED_WATER_STILL;
public static int CALCINATOR;
public static int RED_WATER_STILL;
}

View file

@ -43,4 +43,14 @@ public class Reference {
public static final String GUI_SHEET_LOCATION = "/ee3/art/gui/";
public static final String ARMOR_SHEET_LOCATION = "/ee3/art/armor/";
public static final int SECOND_IN_TICKS = 20;
public static final int BLOCK_RED_WATER_EFFECT_DURATION_BASE = 5;
public static final int BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER = 2;
public static final int BLOCK_RED_WATER_RANGE_BASE = 1;
public static final int BLOCK_RED_WATER_RANGE_MODIFIER = 3;
}