mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
Added the progress pie to the Brewery and Enchanter.
This commit is contained in:
1 parent
bbb4742070
commit
c0791acca1
6 files changed
+122
-64
No files matched your search
@@ -17,12 +17,16 @@ import java.util.Random;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
|
||||
public final class RenderHelper {
|
||||
|
||||
@@ -190,6 +194,51 @@ public final class RenderHelper {
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void renderProgressPie(int x, int y, float progress, ItemStack stack) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
|
||||
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
GL11.glColorMask(false, false, false, false);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
||||
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
GL11.glStencilMask(0xFF);
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
|
||||
|
||||
mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD));
|
||||
int r = 10;
|
||||
int centerX = x + 8;
|
||||
int centerY = y + 8;
|
||||
int degs = (int) (360 * progress);
|
||||
float a = 0.5F + 0.2F * ((float) Math.cos((double) ClientTickHandler.ticksInGame / 10) * 0.5F + 0.5F);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glStencilMask(0x00);
|
||||
GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
|
||||
GL11.glBegin(GL11.GL_TRIANGLE_FAN);
|
||||
GL11.glColor4f(0F, 0.5F, 0.5F, a);
|
||||
GL11.glVertex2i(centerX, centerY);
|
||||
GL11.glColor4f(0F, 1F, 0.5F, a);
|
||||
for(int i = degs; i > 0; i--) {
|
||||
double rad = (i - 90) / 180F * Math.PI;
|
||||
GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r);
|
||||
}
|
||||
GL11.glVertex2i(centerX, centerY);
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
public static String getKeyDisplayString(String keyName) {
|
||||
String key = null;
|
||||
|
||||
@@ -15,6 +15,8 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -26,17 +28,19 @@ 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.wand.IWandHUD;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.block.BlockModContainer;
|
||||
import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileRuneAltar;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockBrewery extends BlockModContainer implements ILexiconable {
|
||||
public class BlockBrewery extends BlockModContainer implements ILexiconable, IWandHUD {
|
||||
|
||||
Random random;
|
||||
|
||||
|
||||
public BlockBrewery() {
|
||||
super(Material.rock);
|
||||
float f = 6F / 16F;
|
||||
@@ -45,19 +49,19 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable {
|
||||
setHardness(2.0F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(soundTypeStone);
|
||||
|
||||
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return Blocks.cobblestone.getIcon(side, meta);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
|
||||
TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
|
||||
if(par5EntityPlayer.isSneaking()) {
|
||||
if(brew.recipe == null && par1World.getBlockMetadata(par2, par3, par4) == 0)
|
||||
for(int i = brew.getSizeInventory() - 1; i >= 0; i--) {
|
||||
@@ -116,7 +120,7 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable {
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
@@ -127,12 +131,12 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable {
|
||||
TileBrewery brew = (TileBrewery) par1World.getTileEntity(par2, par3, par4);
|
||||
return brew.signal;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return LibRenderIDs.idBrewery;
|
||||
@@ -142,12 +146,12 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable {
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileBrewery();
|
||||
@@ -156,6 +160,11 @@ public class BlockBrewery extends BlockModContainer implements ILexiconable {
|
||||
@Override
|
||||
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
|
||||
return LexiconData.brewery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
|
||||
((TileBrewery) world.getTileEntity(x, y, z)).renderHUD(mc, res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -28,15 +30,17 @@ 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.wand.IWandHUD;
|
||||
import vazkii.botania.api.wand.IWandable;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.BlockModContainer;
|
||||
import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockEnchanter extends BlockModContainer implements IWandable, ILexiconable {
|
||||
public class BlockEnchanter extends BlockModContainer implements IWandable, ILexiconable, IWandHUD {
|
||||
|
||||
Random random;
|
||||
public static IIcon overlay;
|
||||
@@ -143,4 +147,9 @@ public class BlockEnchanter extends BlockModContainer implements IWandable, ILex
|
||||
return LexiconData.manaEnchanting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
|
||||
((TileEnchanter) world.getTileEntity(x, y, z)).renderHUD(mc, res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ package vazkii.botania.common.block.tile;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -25,6 +27,8 @@ import vazkii.botania.api.brew.IBrewContainer;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
@@ -242,5 +246,18 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
|
||||
public boolean canRecieveManaFromBursts() {
|
||||
return !isFull();
|
||||
}
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
int manaToGet = getManaCost();
|
||||
if(manaToGet > 0) {
|
||||
int x = res.getScaledWidth() / 2 + 20;
|
||||
int y = res.getScaledHeight() / 2 - 8;
|
||||
|
||||
if(recipe == null)
|
||||
return;
|
||||
|
||||
RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput(getStackInSlot(0)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* 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
|
||||
*
|
||||
@@ -15,6 +15,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -27,10 +29,13 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
import vazkii.botania.api.mana.spark.SparkHelper;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
@@ -357,16 +362,6 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class EnchantmentData {
|
||||
|
||||
public int enchant, level;
|
||||
|
||||
public EnchantmentData(int enchant, int level) {
|
||||
this.enchant = enchant;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttachSpark(ItemStack stack) {
|
||||
return true;
|
||||
@@ -397,5 +392,24 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
public int getAvailableSpaceForMana() {
|
||||
return Math.max(0, manaRequired - getCurrentMana());
|
||||
}
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
if(manaRequired > 0 && itemToEnchant != null) {
|
||||
int x = res.getScaledWidth() / 2 + 20;
|
||||
int y = res.getScaledHeight() / 2 - 8;
|
||||
|
||||
RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaRequired, itemToEnchant);
|
||||
}
|
||||
}
|
||||
|
||||
private static class EnchantmentData {
|
||||
|
||||
public int enchant, level;
|
||||
|
||||
public EnchantmentData(int enchant, int level) {
|
||||
this.enchant = enchant;
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -296,47 +296,7 @@ public class TileRuneAltar extends TileSimpleInventory implements ISidedInventor
|
||||
if(recipe == null)
|
||||
return;
|
||||
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x, y);
|
||||
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
GL11.glColorMask(false, false, false, false);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
||||
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
GL11.glStencilMask(0xFF);
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe.getOutput(), x, y);
|
||||
|
||||
mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD));
|
||||
int r = 10;
|
||||
int centerX = x + 8;
|
||||
int centerY = y + 8;
|
||||
int degs = (int) (360 * ((double) mana / (double) manaToGet));
|
||||
float a = 0.5F + 0.2F * ((float) Math.cos((double) ClientTickHandler.ticksInGame / 10) * 0.5F + 0.5F);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glStencilMask(0x00);
|
||||
GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
|
||||
GL11.glBegin(GL11.GL_TRIANGLE_FAN);
|
||||
GL11.glColor4f(0F, 0.5F, 0.5F, a);
|
||||
GL11.glVertex2i(centerX, centerY);
|
||||
GL11.glColor4f(0F, 1F, 0.5F, a);
|
||||
for(int i = degs; i > 0; i--) {
|
||||
double rad = (i - 90) / 180F * Math.PI;
|
||||
GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r);
|
||||
}
|
||||
GL11.glVertex2i(centerX, centerY);
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_STENCIL_TEST);
|
||||
RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user