Testing the creation of hell

This commit is contained in:
WayofTime 2014-10-31 17:35:30 -04:00
parent 796e75b1f9
commit a2b006105e
2587 changed files with 0 additions and 129617 deletions

View file

@ -0,0 +1,57 @@
package WayofTime.alchemicalWizardry.client;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.client.renderer.RenderHelper;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.client.event.sound.SoundEvent;
import org.lwjgl.opengl.GL11;
public class ClientEventHandler
{
private Minecraft mcClient = FMLClientHandler.instance().getClient();
@SubscribeEvent
public void onPlayerSoundEvent(SoundEvent event)
{
if (Minecraft.getMinecraft() != null)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null && player.isPotionActive(AlchemicalWizardry.customPotionDeaf))
{
event.setResult(Result.DENY);
}
}
}
@SubscribeEvent
public void onTick(RenderTickEvent event)
{
if (event.phase.equals(Phase.START))
return;
if (!RenderHelper.onTickInGame(mcClient))
{
}
}
@SubscribeEvent
public void onRenderLivingPlayerPre(RenderPlayerEvent.Pre event)
{
GL11.glDisable(2929);
}
@SubscribeEvent
public void onRenderLivingPlayerPost(RenderPlayerEvent.Post event)
{
GL11.glEnable(2929);
}
}

View file

@ -0,0 +1,97 @@
package WayofTime.alchemicalWizardry.client;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.common.CommonProxy;
import WayofTime.alchemicalWizardry.common.EntityAirElemental;
import WayofTime.alchemicalWizardry.common.entity.mob.*;
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityEnergyBazookaMainProjectile;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityMeteor;
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityParticleBeam;
import WayofTime.alchemicalWizardry.common.renderer.block.*;
import WayofTime.alchemicalWizardry.common.renderer.block.itemRender.*;
import WayofTime.alchemicalWizardry.common.renderer.mob.*;
import WayofTime.alchemicalWizardry.common.renderer.model.*;
import WayofTime.alchemicalWizardry.common.renderer.projectile.RenderEnergyBazookaMainProjectile;
import WayofTime.alchemicalWizardry.common.renderer.projectile.RenderEnergyBlastProjectile;
import WayofTime.alchemicalWizardry.common.renderer.projectile.RenderMeteor;
import WayofTime.alchemicalWizardry.common.spell.complex.EntitySpellProjectile;
import WayofTime.alchemicalWizardry.common.tileEntity.*;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.item.ItemBlock;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxy extends CommonProxy
{
public static int renderPass;
public static int altarRenderType;
@Override
public void registerRenderers()
{
RenderingRegistry.registerEntityRenderingHandler(EnergyBlastProjectile.class, new RenderEnergyBlastProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntityEnergyBazookaMainProjectile.class, new RenderEnergyBazookaMainProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntitySpellProjectile.class, new RenderEnergyBlastProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntityParticleBeam.class, new RenderEnergyBlastProjectile());
RenderingRegistry.registerEntityRenderingHandler(EntityMeteor.class, new RenderMeteor());
RenderingRegistry.registerEntityRenderingHandler(EntityFallenAngel.class, new RenderFallenAngel(new ModelFallenAngel(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityLowerGuardian.class, new RenderLowerGuardian(new ModelLowerGuardian(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityBileDemon.class, new RenderBileDemon(new ModelBileDemon(), 1.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityWingedFireDemon.class, new RenderWingedFireDemon(new ModelWingedFireDemon(), 1.0F));
RenderingRegistry.registerEntityRenderingHandler(EntitySmallEarthGolem.class, new RenderSmallEarthGolem(new ModelSmallEarthGolem(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityIceDemon.class, new RenderIceDemon(new ModelIceDemon(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityBoulderFist.class, new RenderBoulderFist(new ModelBoulderFist(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityShade.class, new RenderShade(new ModelShade(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityAirElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityWaterElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityEarthElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityFireElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityShadeElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityHolyElemental.class, new RenderElemental(new ModelElemental(), 0.5F));
ClientRegistry.bindTileEntitySpecialRenderer(TEAltar.class, new TEAltarRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TEPedestal.class, new RenderPedestal());
ClientRegistry.bindTileEntitySpecialRenderer(TEPlinth.class, new RenderPlinth());
ClientRegistry.bindTileEntitySpecialRenderer(TEWritingTable.class, new RenderWritingTable());
ClientRegistry.bindTileEntitySpecialRenderer(TEConduit.class, new RenderConduit());
ClientRegistry.bindTileEntitySpecialRenderer(TESpellEffectBlock.class, new RenderSpellEffectBlock());
ClientRegistry.bindTileEntitySpecialRenderer(TESpellEnhancementBlock.class, new RenderSpellEnhancementBlock());
ClientRegistry.bindTileEntitySpecialRenderer(TESpellParadigmBlock.class, new RenderSpellParadigmBlock());
ClientRegistry.bindTileEntitySpecialRenderer(TESpellModifierBlock.class, new RenderSpellModifierBlock());
ClientRegistry.bindTileEntitySpecialRenderer(TEReagentConduit.class, new RenderReagentConduit());
ClientRegistry.bindTileEntitySpecialRenderer(TEMasterStone.class, new RenderMasterStone());
ClientRegistry.bindTileEntitySpecialRenderer(TEAlchemicCalcinator.class, new RenderAlchemicCalcinator());
ClientRegistry.bindTileEntitySpecialRenderer(TEBellJar.class, new RenderCrystalBelljar());
//Item Renderer stuff
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockConduit), new TEConduitItemRenderer());
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockSpellEffect), new TESpellEffectBlockItemRenderer());
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockSpellEnhancement), new TESpellEnhancementBlockItemRenderer());
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockSpellParadigm), new TESpellParadigmBlockItemRenderer());
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockSpellModifier), new TESpellModifierBlockItemRenderer());
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockAlchemicCalcinator), new TEAlchemicalCalcinatorItemRenderer());
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockCrystalBelljar), new TEBellJarItemRenderer());
ShaderHelper.initShaders();
}
@Override
public World getClientWorld()
{
return FMLClientHandler.instance().getClient().theWorld;
}
@Override
public void InitRendering()
{
MinecraftForgeClient.registerItemRenderer(ItemBlock.getItemFromBlock(ModBlocks.blockAltar), new TEAltarItemRenderer());
}
@Override
public void registerEvents()
{
FMLCommonHandler.instance().bus().register(new ClientEventHandler());
}
}

View file

@ -0,0 +1,179 @@
package WayofTime.alchemicalWizardry.client.nei;
import static WayofTime.alchemicalWizardry.client.nei.NEIConfig.bloodOrbs;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipe;
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import WayofTime.alchemicalWizardry.common.tileEntity.gui.GuiWritingTable;
import codechicken.nei.ItemList;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
/**
* NEI Alchemy Recipe Handler by joshie *
*/
public class NEIAlchemyRecipeHandler extends TemplateRecipeHandler {
public class CachedAlchemyRecipe extends CachedRecipe {
public class BloodOrbs {
public PositionedStack stack;
public BloodOrbs(ItemStack orb) {
this.stack = new PositionedStack(orb, 136, 47, false);
}
}
ArrayList<BloodOrbs> orbs;
PositionedStack output;
List<PositionedStack> inputs;
int lp;
public CachedAlchemyRecipe(AlchemyRecipe recipe, ItemStack orb) {
this(recipe);
this.orbs = new ArrayList<BloodOrbs>();
orbs.add(new BloodOrbs(orb));
}
public CachedAlchemyRecipe(AlchemyRecipe recipe) {
List<PositionedStack> inputs = new ArrayList<PositionedStack>();
ItemStack[] stacks = recipe.getRecipe();
if (stacks.length > 0) inputs.add(new PositionedStack(stacks[0], 76, 3));
if (stacks.length > 1) inputs.add(new PositionedStack(stacks[1], 51, 19));
if (stacks.length > 2) inputs.add(new PositionedStack(stacks[2], 101, 19));
if (stacks.length > 3) inputs.add(new PositionedStack(stacks[3], 64, 47));
if (stacks.length > 4) inputs.add(new PositionedStack(stacks[4], 88, 47));
this.inputs = inputs;
this.output = new PositionedStack(recipe.getResult(), 76, 25);
this.lp = recipe.getAmountNeeded() * 100;
this.orbs = new ArrayList<BloodOrbs>();
for (Item orb : bloodOrbs) {
if (((IBloodOrb) orb).getOrbLevel() >= recipe.getOrbLevel()) {
orbs.add(new BloodOrbs(new ItemStack(orb)));
}
}
}
@Override
public List<PositionedStack> getIngredients() {
return inputs;
}
@Override
public PositionedStack getResult() {
return output;
}
@Override
public PositionedStack getOtherStack() {
if (orbs == null || orbs.size() <= 0) return null;
return orbs.get((cycleticks / 48) % orbs.size()).stack;
}
}
@Override
public TemplateRecipeHandler newInstance() {
for (ItemStack item : ItemList.items) {
if (item != null && item.getItem() instanceof IBloodOrb) {
bloodOrbs.add(item.getItem());
}
}
return super.newInstance();
}
@Override
public String getOverlayIdentifier() {
return "alchemicalwizardry.alchemy";
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(134, 22, 16, 24), "alchemicalwizardry.alchemy"));
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiWritingTable.class;
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("alchemicalwizardry.alchemy") && getClass() == NEIAlchemyRecipeHandler.class) {
for (AlchemyRecipe recipe : AlchemyRecipeRegistry.recipes) {
if (recipe.getResult() != null) arecipes.add(new CachedAlchemyRecipe(recipe));
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (AlchemyRecipe recipe : AlchemyRecipeRegistry.recipes) {
if (recipe == null) continue;
ItemStack output = recipe.getResult();
if (NEIServerUtils.areStacksSameTypeCrafting(result, recipe.getResult())) {
arecipes.add(new CachedAlchemyRecipe(recipe));
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
if (ingredient.getItem() instanceof IBloodOrb) {
for (AlchemyRecipe recipe : AlchemyRecipeRegistry.recipes) {
if (recipe == null) continue;
if (((IBloodOrb) ingredient.getItem()).getOrbLevel() >= recipe.getOrbLevel()) {
arecipes.add(new CachedAlchemyRecipe(recipe, ingredient));
}
}
} else {
for (AlchemyRecipe recipe : AlchemyRecipeRegistry.recipes) {
if (recipe == null) continue;
ItemStack[] stacks = recipe.getRecipe();
for (ItemStack stack : stacks) {
if (NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
arecipes.add(new CachedAlchemyRecipe(recipe));
break;
}
}
}
}
}
@Override
public void drawExtras(int id) {
CachedAlchemyRecipe cache = (CachedAlchemyRecipe) arecipes.get(id);
Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + cache.lp + "LP", getLPX(cache.lp), 34, 0);
}
public int getLPX(int lp) {
if (lp < 10) return 122;
else if (lp < 100) return 122;
else if (lp < 1000) return 130;
else if (lp < 10000) return 127;
else if (lp < 100000) return 124;
return 122;
}
@Override
public String getRecipeName() {
return StatCollector.translateToLocal("tile.blockWritingTable.name");
}
@Override
public String getGuiTexture() {
return new ResourceLocation("alchemicalwizardry", "gui/nei/alchemy.png").toString();
}
}

View file

@ -0,0 +1,185 @@
package WayofTime.alchemicalWizardry.client.nei;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.lang.reflect.Field;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipe;
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler;
/**
* NEI Altar Recipe Handler by joshie *
*/
public class NEIAltarRecipeHandler extends TemplateRecipeHandler {
public class CachedAltarRecipe extends CachedRecipe {
PositionedStack input;
PositionedStack output;
int tier, lp_amount, consumption, drain;
public CachedAltarRecipe(AltarRecipe recipe) {
input = new PositionedStack(recipe.requiredItem, 38, 2, false);
output = new PositionedStack(recipe.result, 132, 32, false);
tier = recipe.minTier;
lp_amount = recipe.liquidRequired;
consumption = recipe.consumptionRate;
drain = recipe.drainRate;
}
@Override
public PositionedStack getIngredient() {
return input;
}
@Override
public PositionedStack getResult() {
return output;
}
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("alchemicalwizardry.altar") && getClass() == NEIAltarRecipeHandler.class) {
for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) {
if(recipe != null && recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe));
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) {
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.result, result)) {
if(recipe != null && recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe));
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) {
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.requiredItem, ingredient)) {
if(recipe != null && recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe));
}
}
}
//Mouse Position helper
public Point getMouse(int width, int height) {
Point mousepos = this.getMousePosition();
int guiLeft = (width - 176) / 2;
int guiTop = (height - 166) / 2;
Point relMouse = new Point(mousepos.x - guiLeft, mousepos.y - guiTop);
return relMouse;
}
//width helper, getting width normal way hates me on compile
public int getGuiWidth(GuiRecipe gui) {
try {
Field f = gui.getClass().getField("width");
return (Integer) f.get(gui);
} catch (NoSuchFieldException e) {
try {
Field f = gui.getClass().getField("field_146294_l");
return (Integer) f.get(gui);
} catch (Exception e2) {
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
//height helper, getting height normal way hates me on compile
public int getGuiHeight(GuiRecipe gui) {
try {
Field f = gui.getClass().getField("height");
return (Integer) f.get(gui);
} catch (NoSuchFieldException e) {
try {
Field f = gui.getClass().getField("field_146295_m");
return (Integer) f.get(gui);
} catch (Exception e2) {
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
@Override
public void drawExtras(int id) {
CachedAltarRecipe recipe = (CachedAltarRecipe) arecipes.get(id);
Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + StatCollector.translateToLocal("bm.string.tier") + ": " + recipe.tier, 78, 5, 0);
Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + "LP: " + recipe.lp_amount, 78, 15, 0);
}
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int id) {
currenttip = super.handleTooltip(gui, currenttip, id);
Point mouse = getMouse(getGuiWidth(gui), getGuiHeight(gui));
CachedAltarRecipe recipe = (CachedAltarRecipe) arecipes.get(id);
int yLow = id % 2 == 0 ? 38 : 102;
int yHigh = id % 2 == 0 ? 72 : 136;
if(mouse.x >= 19 && mouse.x <= 80 && mouse.y >= yLow && mouse.y <= yHigh) {
currenttip.add(StatCollector.translateToLocal("bm.string.consume") + ": " + recipe.consumption + "LP/t");
currenttip.add(StatCollector.translateToLocal("bm.string.drain") + ": " + recipe.drain + "LP/t");
}
return currenttip;
}
@Override
public String getOverlayIdentifier() {
return "altarrecipes";
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(90, 32, 22, 16), "alchemicalwizardry.altar"));
}
@Override
public String getRecipeName() {
return " " + StatCollector.translateToLocal("tile.bloodAltar.name");
}
@Override
public String getGuiTexture() {
return new ResourceLocation("alchemicalwizardry", "gui/nei/altar.png").toString();
}
public static Point getMousePosition() {
Dimension size = displaySize();
Dimension res = displayRes();
return new Point(Mouse.getX() * size.width / res.width, size.height - Mouse.getY() * size.height / res.height - 1);
}
public static Dimension displaySize() {
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
}
public static Dimension displayRes() {
Minecraft mc = Minecraft.getMinecraft();
return new Dimension(mc.displayWidth, mc.displayHeight);
}
}

View file

@ -0,0 +1,141 @@
package WayofTime.alchemicalWizardry.client.nei;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.StatCollector;
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.ShapedRecipeHandler;
/**
* NEI Blood Orb Shaped Recipe Handler by joshie *
*/
public class NEIBloodOrbShapedHandler extends ShapedRecipeHandler {
public class CachedBloodOrbRecipe extends CachedShapedRecipe {
public CachedBloodOrbRecipe(int width, int height, Object[] items, ItemStack out) {
super(width, height, items, out);
}
@Override
public void setIngredients(int width, int height, Object[] items) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
if (items[y * width + x] == null)
continue;
Object o = items[y * width + x];
if (o instanceof ItemStack) {
PositionedStack stack = new PositionedStack(items[y * width + x], 25 + x * 18, 6 + y * 18, false);
stack.setMaxSize(1);
ingredients.add(stack);
} else if (o instanceof Integer) {
ArrayList<ItemStack> orbs = new ArrayList();
for (Item item : NEIConfig.bloodOrbs) {
if (((IBloodOrb) item).getOrbLevel() >= (Integer) o) {
orbs.add(new ItemStack(item));
}
}
PositionedStack stack = new PositionedStack(orbs, 25 + x * 18, 6 + y * 18, false);
stack.setMaxSize(1);
ingredients.add(stack);
}
}
}
}
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("crafting") && getClass() == NEIBloodOrbShapedHandler.class) {
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
if (irecipe instanceof ShapedBloodOrbRecipe) {
CachedBloodOrbRecipe recipe = forgeShapedRecipe((ShapedBloodOrbRecipe) irecipe);
if (recipe == null)
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
if (irecipe instanceof ShapedBloodOrbRecipe) {
CachedBloodOrbRecipe recipe = forgeShapedRecipe((ShapedBloodOrbRecipe) irecipe);
if (recipe == null || !NEIServerUtils.areStacksSameTypeCrafting(recipe.result.item, result))
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedBloodOrbRecipe)
recipe = forgeShapedRecipe((ShapedBloodOrbRecipe) irecipe);
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
continue;
recipe.computeVisuals();
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
private CachedBloodOrbRecipe forgeShapedRecipe(ShapedBloodOrbRecipe recipe) {
int width;
int height;
try {
width = recipe.width;
height = recipe.height;
} catch (Exception e) {
e.printStackTrace();
return null;
}
Object[] items = recipe.getInput();
for (Object item : items)
if (item instanceof List && ((List<?>) item).isEmpty())// ore
// handler,
// no ores
return null;
return new CachedBloodOrbRecipe(width, height, items, recipe.getRecipeOutput());
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "crafting"));
}
@Override
public String getOverlayIdentifier() {
return "crafting";
}
@Override
public String getRecipeName() {
return StatCollector.translateToLocal("bm.string.crafting.orb.shaped");
}
}

View file

@ -0,0 +1,130 @@
package WayofTime.alchemicalWizardry.client.nei;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.StatCollector;
import WayofTime.alchemicalWizardry.api.items.ShapelessBloodOrbRecipe;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.ShapelessRecipeHandler;
/**
* NEI Blood Orb Shapeless Recipe Handler by joshie *
*/
public class NEIBloodOrbShapelessHandler extends ShapelessRecipeHandler {
public class CachedBloodOrbRecipe extends CachedShapelessRecipe {
public CachedBloodOrbRecipe(ArrayList<Object> items, ItemStack recipeOutput) {
super(items, recipeOutput);
}
@Override
public void setIngredients(List<?> items) {
ingredients.clear();
for (int ingred = 0; ingred < items.size(); ingred++) {
Object o = items.get(ingred);
if (o instanceof ItemStack) {
PositionedStack stack = new PositionedStack(items.get(ingred), 25 + stackorder[ingred][0] * 18, 6 + stackorder[ingred][1] * 18);
stack.setMaxSize(1);
ingredients.add(stack);
} else if (o instanceof Integer) {
ArrayList<ItemStack> orbs = new ArrayList();
for (Item item : NEIConfig.bloodOrbs) {
if (((IBloodOrb) item).getOrbLevel() >= (Integer) o) {
orbs.add(new ItemStack(item));
}
}
PositionedStack stack = new PositionedStack(orbs, 25 + stackorder[ingred][0] * 18, 6 + stackorder[ingred][1] * 18);
stack.setMaxSize(1);
ingredients.add(stack);
}
}
}
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("crafting") && getClass() == NEIBloodOrbShapelessHandler.class) {
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedBloodOrbRecipe recipe = null;
if (irecipe instanceof ShapelessBloodOrbRecipe)
recipe = forgeShapelessRecipe((ShapelessBloodOrbRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) {
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
CachedBloodOrbRecipe recipe = null;
if (irecipe instanceof ShapelessBloodOrbRecipe)
recipe = forgeShapelessRecipe((ShapelessBloodOrbRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedBloodOrbRecipe recipe = null;
if (irecipe instanceof ShapelessBloodOrbRecipe)
recipe = forgeShapelessRecipe((ShapelessBloodOrbRecipe) irecipe);
if (recipe == null)
continue;
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
public CachedBloodOrbRecipe forgeShapelessRecipe(ShapelessBloodOrbRecipe recipe) {
ArrayList<Object> items = recipe.getInput();
for (Object item : items)
if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
return null;
return new CachedBloodOrbRecipe(items, recipe.getRecipeOutput());
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "crafting"));
}
@Override
public String getOverlayIdentifier() {
return "crafting";
}
@Override
public String getRecipeName() {
return StatCollector.translateToLocal("bm.string.crafting.orb.shapeless");
}
}

View file

@ -0,0 +1,33 @@
package WayofTime.alchemicalWizardry.client.nei;
import java.util.ArrayList;
import net.minecraft.item.Item;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
public class NEIConfig implements IConfigureNEI {
public static ArrayList<Item> bloodOrbs = new ArrayList<Item>();
@Override
public void loadConfig() {
API.registerRecipeHandler(new NEIAlchemyRecipeHandler());
API.registerUsageHandler(new NEIAlchemyRecipeHandler());
API.registerRecipeHandler(new NEIAltarRecipeHandler());
API.registerUsageHandler(new NEIAltarRecipeHandler());
API.registerRecipeHandler(new NEIBloodOrbShapedHandler());
API.registerUsageHandler(new NEIBloodOrbShapedHandler());
API.registerRecipeHandler(new NEIBloodOrbShapelessHandler());
API.registerUsageHandler(new NEIBloodOrbShapelessHandler());
}
@Override
public String getName() {
return "Blood Magic NEI";
}
@Override
public String getVersion() {
return "1.3";
}
}

View file

@ -0,0 +1,50 @@
package WayofTime.alchemicalWizardry.client.renderer;
import java.util.List;
/**
* This class is a utility class that was created by bspkrs.
* https://github.com/bspkrs/bspkrsCore/blob/master/src/main/java/bspkrs/client/util/ColorThreshold.java
*/
public class ColourThreshold implements Comparable<ColourThreshold>
{
public int threshold;
public String colorCode;
public ColourThreshold(int t, String c)
{
threshold = t;
colorCode = c;
}
@Override
public String toString()
{
return String.valueOf(threshold) + ", " + colorCode;
}
@Override
public int compareTo(ColourThreshold o)
{
if (this.threshold > o.threshold)
return 1;
else if (this.threshold < o.threshold)
return -1;
else
return 0;
}
/**
* Returns the colorCode attached to the first threshold in the list that is
* >= value. Expects that the list has been sorted by threshold ascending.
*/
public static String getColorCode(List<ColourThreshold> colorList, int value)
{
for (ColourThreshold ct : colorList)
if (value <= ct.threshold)
return ct.colorCode;
return "f";
}
}

View file

@ -0,0 +1,142 @@
package WayofTime.alchemicalWizardry.client.renderer;
import WayofTime.alchemicalWizardry.BloodMagicConfiguration;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
public class HUDElement
{
public final ItemStack itemStack;
public final int iconW;
public final int iconH;
public final int padW;
public final int value;
private int elementW;
private int elementH;
private String itemName = "";
private int itemNameW;
private String itemDamage = "";
private int itemDamageW;
private Minecraft mc = Minecraft.getMinecraft();
private static final int offset = 5;
public boolean enableItemName = false;
public boolean showValue = true;
public boolean showDamageOverlay = false;
public boolean showItemCount = false;
static RenderItem itemRenderer = new RenderItem();
public HUDElement(ItemStack itemStack, int iconW, int iconH, int padW, int value)
{
this.itemStack = itemStack;
this.iconW = iconW;
this.iconH = iconH;
this.padW = padW;
this.value = value;
initSize();
}
public int width()
{
return elementW;
}
public int height()
{
return elementH;
}
private void initSize()
{
elementH = enableItemName ? Math.max(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT * 2, iconH) :
Math.max(mc.fontRenderer.FONT_HEIGHT, iconH);
if (itemStack != null)
{
int damage = 1;
int maxDamage = 1;
if (showValue)
{
maxDamage = itemStack.getMaxDamage() + 1;
damage = maxDamage - itemStack.getItemDamageForDisplay();
boolean showSpecialValue = true;
boolean showValue = false;
boolean showPercent = false;
boolean showMaxDamage = true;
boolean thresholdPercent = true;
if (showSpecialValue)
{
itemDamage = "\247" + ColourThreshold.getColorCode(BloodMagicConfiguration.colorList,
(thresholdPercent ? damage * 100 / maxDamage : damage)) + this.value;
} else if (showValue)
itemDamage = "\247" + ColourThreshold.getColorCode(BloodMagicConfiguration.colorList,
(thresholdPercent ? damage * 100 / maxDamage : damage)) + damage +
(showMaxDamage ? "/" + maxDamage : "");
else if (showPercent)
itemDamage = "\247" + ColourThreshold.getColorCode(BloodMagicConfiguration.colorList,
(thresholdPercent ? damage * 100 / maxDamage : damage)) +
(damage * 100 / maxDamage) + "%";
}
itemDamageW = mc.fontRenderer.getStringWidth(HUDUtils.stripCtrl(itemDamage));
elementW = padW + iconW + padW + itemDamageW + offset;
if (enableItemName)
{
itemName = itemStack.getDisplayName();
elementW = padW + iconW + padW +
Math.max(mc.fontRenderer.getStringWidth(HUDUtils.stripCtrl(itemName)), itemDamageW);
}
itemNameW = mc.fontRenderer.getStringWidth(HUDUtils.stripCtrl(itemName));
}
}
public void renderToHud(int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
RenderHelper.enableStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();
itemRenderer.zLevel = 200.0F;
//if (ArmorStatusHUD.alignMode.toLowerCase().contains("right"))
boolean toRight = true;
if (toRight)
{
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemStack, x - (iconW + padW), y);
HUDUtils.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x - (iconW + padW), y, showDamageOverlay, showItemCount);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
GL11.glDisable(GL11.GL_BLEND);
mc.fontRenderer.drawStringWithShadow(itemName + "\247r", x - (padW + iconW + padW) - itemNameW, y, 0xffffff);
mc.fontRenderer.drawStringWithShadow(itemDamage + "\247r", x - (padW + iconW + padW) - itemDamageW,
y + (enableItemName ? elementH / 2 : elementH / 4), 0xffffff);
} else
{
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemStack, x, y);
HUDUtils.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, showDamageOverlay, showItemCount);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
GL11.glDisable(GL11.GL_BLEND);
mc.fontRenderer.drawStringWithShadow(itemName + "\247r", x + iconW + padW, y, 0xffffff);
mc.fontRenderer.drawStringWithShadow(itemDamage + "\247r", x + iconW + padW,
y + (enableItemName ? elementH / 2 : elementH / 4), 0xffffff);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
}

View file

@ -0,0 +1,271 @@
package WayofTime.alchemicalWizardry.client.renderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
/**
* This class is a utility class that was created by bspkrs.
* https://github.com/bspkrs/bspkrsCore/blob/master/src/main/java/bspkrs/client/util/HUDUtils.java
*/
public final class HUDUtils
{
private static int[] colorCodes = new int[]{0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215,
0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959};
public static int getColorCode(char c, boolean isLighter)
{
return colorCodes[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16];
}
/**
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
* and filler. It is assumed that the desired texture ResourceLocation object has been bound using
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
*
* @param x x axis offset
* @param y y axis offset
* @param u bound resource location image x offset
* @param v bound resource location image y offset
* @param width the desired box width
* @param height the desired box height
* @param textureWidth the width of the box texture in the resource location image
* @param textureHeight the height of the box texture in the resource location image
* @param borderSize the size of the box's borders
* @param zLevel the zLevel to draw at
*/
public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
int borderSize, float zLevel)
{
drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
}
/**
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
* and filler. The provided ResourceLocation object will be bound using
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
*
* @param res the ResourceLocation object that contains the desired image
* @param x x axis offset
* @param y y axis offset
* @param u bound resource location image x offset
* @param v bound resource location image y offset
* @param width the desired box width
* @param height the desired box height
* @param textureWidth the width of the box texture in the resource location image
* @param textureHeight the height of the box texture in the resource location image
* @param borderSize the size of the box's borders
* @param zLevel the zLevel to draw at
*/
public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
int borderSize, float zLevel)
{
drawContinuousTexturedBox(res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
}
/**
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
* and filler. The provided ResourceLocation object will be bound using
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
*
* @param res the ResourceLocation object that contains the desired image
* @param x x axis offset
* @param y y axis offset
* @param u bound resource location image x offset
* @param v bound resource location image y offset
* @param width the desired box width
* @param height the desired box height
* @param textureWidth the width of the box texture in the resource location image
* @param textureHeight the height of the box texture in the resource location image
* @param topBorder the size of the box's top border
* @param bottomBorder the size of the box's bottom border
* @param leftBorder the size of the box's left border
* @param rightBorder the size of the box's right border
* @param zLevel the zLevel to draw at
*/
public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
{
Minecraft.getMinecraft().getTextureManager().bindTexture(res);
drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
}
/**
* Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders
* and filler. It is assumed that the desired texture ResourceLocation object has been bound using
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
*
* @param x x axis offset
* @param y y axis offset
* @param u bound resource location image x offset
* @param v bound resource location image y offset
* @param width the desired box width
* @param height the desired box height
* @param textureWidth the width of the box texture in the resource location image
* @param textureHeight the height of the box texture in the resource location image
* @param topBorder the size of the box's top border
* @param bottomBorder the size of the box's bottom border
* @param leftBorder the size of the box's left border
* @param rightBorder the size of the box's right border
* @param zLevel the zLevel to draw at
*/
public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
int fillerWidth = textureWidth - leftBorder - rightBorder;
int fillerHeight = textureHeight - topBorder - bottomBorder;
int canvasWidth = width - leftBorder - rightBorder;
int canvasHeight = height - topBorder - bottomBorder;
int xPasses = canvasWidth / fillerWidth;
int remainderWidth = canvasWidth % fillerWidth;
int yPasses = canvasHeight / fillerHeight;
int remainderHeight = canvasHeight % fillerHeight;
// Draw Border
// Top Left
drawTexturedModalRect(x, y, u, v, leftBorder, topBorder, zLevel);
// Top Right
drawTexturedModalRect(x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder, topBorder, zLevel);
// Bottom Left
drawTexturedModalRect(x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, zLevel);
// Bottom Right
drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, zLevel);
for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++)
{
// Top Border
drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, zLevel);
// Bottom Border
drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, zLevel);
// Throw in some filler for good measure
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
drawTexturedModalRect(x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), zLevel);
}
// Side Borders
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
{
// Left Border
drawTexturedModalRect(x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
// Right Border
drawTexturedModalRect(x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
}
}
public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel)
{
float var7 = 0.00390625F;
float var8 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((x + 0), (y + height), zLevel, ((u + 0) * var7), ((v + height) * var8));
tessellator.addVertexWithUV((x + width), (y + height), zLevel, ((u + width) * var7), ((v + height) * var8));
tessellator.addVertexWithUV((x + width), (y + 0), zLevel, ((u + width) * var7), ((v + 0) * var8));
tessellator.addVertexWithUV((x + 0), (y + 0), zLevel, ((u + 0) * var7), ((v + 0) * var8));
tessellator.draw();
}
/**
* Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the specified position.
*/
public static void renderItemOverlayIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y)
{
renderItemOverlayIntoGUI(fontRenderer, itemStack, x, y, true, true);
}
/**
* Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the specified position.
*/
public static void renderItemOverlayIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, boolean showDamageBar, boolean showCount)
{
if (itemStack != null && (showDamageBar || showCount))
{
if (itemStack.isItemDamaged() && showDamageBar)
{
int var11 = (int) Math.round(13.0D - itemStack.getItemDamageForDisplay() * 13.0D / itemStack.getMaxDamage());
int var7 = (int) Math.round(255.0D - itemStack.getItemDamageForDisplay() * 255.0D / itemStack.getMaxDamage());
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
Tessellator var8 = Tessellator.instance;
int var9 = 255 - var7 << 16 | var7 << 8;
int var10 = (255 - var7) / 4 << 16 | 16128;
renderQuad(var8, x + 2, y + 13, 13, 2, 0);
renderQuad(var8, x + 2, y + 13, 12, 1, var10);
renderQuad(var8, x + 2, y + 13, var11, 1, var9);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
if (showCount)
{
int count = 0;
if (itemStack.getMaxStackSize() > 1)
count = HUDUtils.countInInventory(Minecraft.getMinecraft().thePlayer, itemStack.getItem(), itemStack.getItemDamage());
else if (itemStack.getItem().equals(Items.bow))
count = HUDUtils.countInInventory(Minecraft.getMinecraft().thePlayer, Items.arrow);
if (count > 1)
{
String var6 = "" + count;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
fontRenderer.drawStringWithShadow(var6, x + 19 - 2 - fontRenderer.getStringWidth(var6), y + 6 + 3, 16777215);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
}
}
/**
* Adds a quad to the tesselator at the specified position with the set width and height and color. Args: tessellator, x, y, width,
* height, color
*/
public static void renderQuad(Tessellator tessellator, int x, int y, int width, int height, int color)
{
tessellator.startDrawingQuads();
tessellator.setColorOpaque_I(color);
tessellator.addVertex((x + 0), (y + 0), 0.0D);
tessellator.addVertex((x + 0), (y + height), 0.0D);
tessellator.addVertex((x + width), (y + height), 0.0D);
tessellator.addVertex((x + width), (y + 0), 0.0D);
tessellator.draw();
}
public static int countInInventory(EntityPlayer player, Item item)
{
return countInInventory(player, item, -1);
}
public static int countInInventory(EntityPlayer player, Item item, int md)
{
int count = 0;
for (int i = 0; i < player.inventory.mainInventory.length; i++)
if (player.inventory.mainInventory[i] != null && item.equals(player.inventory.mainInventory[i].getItem()) && (md == -1 || player.inventory.mainInventory[i].getItemDamage() == md))
count += player.inventory.mainInventory[i].stackSize;
return count;
}
public static String stripCtrl(String s)
{
return s.replaceAll("(?i)\247[0-9a-fklmnor]", "");
}
}

View file

@ -0,0 +1,180 @@
package WayofTime.alchemicalWizardry.client.renderer;
import WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
public class RenderHelper
{
public static boolean showEquippedItem = true;
public static boolean enableItemName = false;
public static boolean enabled = true;
public static boolean showInChat = true;
private static int xOffsetDefault = +50;
public static int xOffset = xOffsetDefault;
private static int yOffsetDefault = 2;
public static int yOffset = yOffsetDefault;
private static int yOffsetBottomCenterDefault = 41;
public static int yOffsetBottomCenter = yOffsetBottomCenterDefault;
private static boolean applyXOffsetToCenterDefault = true;
public static boolean applyXOffsetToCenter = applyXOffsetToCenterDefault;
private static boolean applyYOffsetToMiddleDefault = false;
public static boolean applyYOffsetToMiddle = applyYOffsetToMiddleDefault;
public static String listMode = "horizontal";
public static String alignMode = "bottomcenter";
private static ScaledResolution scaledResolution;
public static boolean onTickInGame(Minecraft mc)
{
if (enabled && (mc.inGameHasFocus || mc.currentScreen == null || (mc.currentScreen instanceof GuiChat && showInChat))
&& !mc.gameSettings.showDebugInfo)
{
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
if (SpellHelper.canPlayerSeeAlchemy(player))
{
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
displayArmorStatus(mc);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
}
return true;
}
private static List<HUDElement> getHUDElements(Minecraft mc)
{
List<HUDElement> elements = new ArrayList();
MovingObjectPosition movingobjectposition = mc.objectMouseOver;
World world = mc.theWorld;
if (movingobjectposition == null)
{
return elements;
} else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof IReagentHandler))
{
return elements;
}
IReagentHandler relay = (IReagentHandler) tile;
ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.getOrientation(movingobjectposition.sideHit));
if (infos != null)
{
for (ReagentContainerInfo info : infos)
{
if (info == null || info.reagent == null || info.reagent.reagent == null)
{
continue;
}
ItemStack itemStack = ReagentRegistry.getItemForReagent(info.reagent.reagent);
if (itemStack != null)
elements.add(new HUDElement(itemStack, 16, 16, 2, info.reagent.amount));
}
}
}
}
return elements;
}
private static int getX(int width)
{
if (alignMode.toLowerCase().contains("center"))
return scaledResolution.getScaledWidth() / 2 - width / 2 + (applyXOffsetToCenter ? xOffset : 0);
else if (alignMode.toLowerCase().contains("right"))
return scaledResolution.getScaledWidth() - width - xOffset;
else
return xOffset;
}
private static int getY(int rowCount, int height)
{
if (alignMode.toLowerCase().contains("middle"))
return (scaledResolution.getScaledHeight() / 2) - ((rowCount * height) / 2) + (applyYOffsetToMiddle ? yOffset : 0);
else if (alignMode.equalsIgnoreCase("bottomleft") || alignMode.equalsIgnoreCase("bottomright"))
return scaledResolution.getScaledHeight() - (rowCount * height) - yOffset;
else if (alignMode.equalsIgnoreCase("bottomcenter"))
return scaledResolution.getScaledHeight() - (rowCount * height) - yOffsetBottomCenter;
else
return yOffset;
}
private static int getElementsWidth(List<HUDElement> elements)
{
int r = 0;
for (HUDElement he : elements)
r += he.width();
return r;
}
private static void displayArmorStatus(Minecraft mc)
{
List<HUDElement> elements = getHUDElements(mc);
if (elements.size() > 0)
{
int yOffset = enableItemName ? 18 : 16;
if (listMode.equalsIgnoreCase("vertical"))
{
int yBase = getY(elements.size(), yOffset);
for (HUDElement e : elements)
{
e.renderToHud((alignMode.toLowerCase().contains("right") ? getX(0) : getX(e.width())), yBase);
yBase += yOffset;
}
} else if (listMode.equalsIgnoreCase("horizontal"))
{
int totalWidth = getElementsWidth(elements);
int yBase = getY(1, yOffset);
int xBase = getX(totalWidth);
int prevX = 0;
for (HUDElement e : elements)
{
e.renderToHud(xBase + prevX + (alignMode.toLowerCase().contains("right") ? e.width() : 0), yBase);
prevX += (e.width());
}
} else if (listMode.equalsIgnoreCase("compound"))
{
//TODO
}
}
}
}