mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 04:09:40 +00:00
Added Mana Pool Overlays.
This commit is contained in:
1 parent
fb9c1c40d8
commit
9c2d9e9803
12 files changed
+110
-25
No files matched your search
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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 @ [Jul 2, 2014, 6:36:54 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* A block that implements this can provide an IIcon (block icons only)
|
||||
* to be used as an overlay for the mana pool, similarly to the mana void
|
||||
* and catalysts.
|
||||
*/
|
||||
public interface IPoolOverlayProvider {
|
||||
|
||||
public IIcon getIcon(World world, int x, int y, int z);
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
@@ -25,6 +26,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.api.mana.IPoolOverlayProvider;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.model.ModelPool;
|
||||
@@ -69,11 +71,36 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
waterLevel = 0.4F;
|
||||
forceAllMana = false;
|
||||
}
|
||||
|
||||
float s = 1F / 16F;
|
||||
float v = 1F / 8F;
|
||||
float w = -v * 3.5F;
|
||||
|
||||
if(pool.getWorldObj() != null) {
|
||||
Block below = pool.getWorldObj().getBlock(pool.xCoord, pool.yCoord - 1, pool.zCoord);
|
||||
if(below instanceof IPoolOverlayProvider) {
|
||||
IIcon overlay = ((IPoolOverlayProvider) below).getIcon(pool.getWorldObj(), pool.xCoord, pool.yCoord - 1, pool.zCoord);
|
||||
if(overlay != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glColor4f(1F, 1F, 1F, (float) ((Math.sin((double) pool.getWorldObj().getTotalWorldTime() / 20.0) + 1) * 0.3 + 0.2));
|
||||
GL11.glTranslatef(-0.5F, -1F - 0.43F, -0.5F);
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glScalef(s, s, s);
|
||||
|
||||
renderIcon(0, 0, overlay, 16, 16, 240);
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(waterLevel > 0) {
|
||||
float s = 1F / 256F * 14F;
|
||||
float v = 1F / 8F;
|
||||
float w = -v * 3.5F;
|
||||
|
||||
s = 1F / 256F * 14F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -82,28 +109,29 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
|
||||
GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w);
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glScalef(s, s, s);
|
||||
float par1 = 0;
|
||||
float par2 = 0;
|
||||
IIcon par3Icon = Blocks.water.getIcon(0, 0);
|
||||
float par4 = 16;
|
||||
float par5 = 16;
|
||||
float zLevel = 0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setBrightness(240);
|
||||
tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, par3Icon.getMinU(), par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, par3Icon.getMaxU(), par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, par3Icon.getMaxU(), par3Icon.getMinV());
|
||||
tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, par3Icon.getMinU(), par3Icon.getMinV());
|
||||
|
||||
|
||||
IIcon waterIcon = Blocks.water.getIcon(0, 0);
|
||||
|
||||
ShaderHelper.useShader(ShaderHelper.manaPool);
|
||||
tessellator.draw();
|
||||
renderIcon(0, 0, waterIcon, 16, 16, 240);
|
||||
ShaderHelper.releaseShader();
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setBrightness(brightness);
|
||||
tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV());
|
||||
tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV());
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,11 +20,12 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.IPoolOverlayProvider;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockAlchemyCatalyst extends BlockMod implements ILexiconable {
|
||||
public class BlockAlchemyCatalyst extends BlockMod implements ILexiconable, IPoolOverlayProvider {
|
||||
|
||||
IIcon[] icons;
|
||||
|
||||
@@ -42,7 +43,7 @@ public class BlockAlchemyCatalyst extends BlockMod implements ILexiconable {
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
icons = new IIcon[3];
|
||||
icons = new IIcon[4];
|
||||
for(int i = 0; i < icons.length; i++)
|
||||
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
|
||||
}
|
||||
@@ -57,4 +58,9 @@ public class BlockAlchemyCatalyst extends BlockMod implements ILexiconable {
|
||||
return LexiconData.alchemy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(World world, int x, int y, int z) {
|
||||
return icons[3];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,18 +13,24 @@ package vazkii.botania.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.IPoolOverlayProvider;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.tile.mana.TileManaVoid;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockManaVoid extends BlockModContainer implements ILexiconable {
|
||||
public class BlockManaVoid extends BlockModContainer implements ILexiconable, IPoolOverlayProvider {
|
||||
|
||||
IIcon overlay;
|
||||
|
||||
protected BlockManaVoid() {
|
||||
super(Material.rock);
|
||||
setHardness(2.0F);
|
||||
@@ -32,6 +38,12 @@ public class BlockManaVoid extends BlockModContainer implements ILexiconable {
|
||||
setStepSound(Block.soundTypeStone);
|
||||
setBlockName(LibBlockNames.MANA_VOID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
blockIcon = IconHelper.forBlock(par1IconRegister, this, 0);
|
||||
overlay = IconHelper.forBlock(par1IconRegister, this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int id) {
|
||||
@@ -43,4 +55,9 @@ public class BlockManaVoid extends BlockModContainer implements ILexiconable {
|
||||
return LexiconData.manaVoid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(World world, int x, int y, int z) {
|
||||
return overlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class BlockPool extends BlockModContainer implements IWandHUD, IWandable,
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int par1, int par2) {
|
||||
return ModBlocks.livingrock.getIcon(par1, par2);
|
||||
return ModBlocks.livingrock.getIcon(par1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,7 @@ package vazkii.botania.common.block.tile.mana;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.IManaCollisionGhost;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TileManaDetector extends TileMod implements IManaCollisionGhost {
|
||||
@@ -25,6 +26,10 @@ public class TileManaDetector extends TileMod implements IManaCollisionGhost {
|
||||
int expectedMeta = worldObj.getEntitiesWithinAABB(IManaBurst.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1)).size() != 0 ? 1 : 0;
|
||||
if(meta != expectedMeta)
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, expectedMeta, 1 | 2);
|
||||
|
||||
if(expectedMeta == 1)
|
||||
for(int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(getWorldObj(), xCoord + Math.random(), yCoord + Math.random(), zCoord + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.mana.IClientManaHandler;
|
||||
import vazkii.botania.api.mana.IPoolOverlayProvider;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
double particleChance = 1F - (double) getCurrentMana() / (double) MAX_MANA * 0.1;
|
||||
Color color = new Color(0x00C6FF);
|
||||
if(Math.random() > particleChance)
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F);
|
||||
Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F, 2F);
|
||||
}
|
||||
|
||||
alchemy = worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.alchemyCatalyst;
|
||||
@@ -198,7 +198,7 @@ public class TilePool extends TileMod implements IManaPool {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
if(worldObj.isRemote) {
|
||||
Color color = new Color(0x00C6FF);
|
||||
Botania.proxy.wispFX(worldObj, item.posX + Math.random() * 0.5 - 0.25, item.posY + Math.random() * 0.5 - (outputting ? 0.65 : 0.25), item.posZ + Math.random() * 0.5 - 0.25, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 15F, (outputting ? -1F : 1) * (float) Math.random() / 25F);
|
||||
Botania.proxy.wispFX(worldObj, item.posX + Math.random() * 0.5 - 0.25, item.posY + Math.random() * 0.5 - (outputting ? 0.65 : 0.25), item.posZ + Math.random() * 0.5 - 0.25, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 15F, (outputting ? -1F : 1) * (float) Math.random() / 25F, 0.1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
File renamed without changes.
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Reference in new issue
Block a user