Added a 3D model renderer for the lexica botania.

This commit is contained in:
Vasco Lavos committed 2014-03-25 21:53:44 +00:00
1 parent 33bb7649dc
commit 3a8fd56e8a
9 files changed
+111 -5

No files matched your search

@@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import vazkii.botania.api.mana.IManaCollector;
import vazkii.botania.client.core.handler.LightningHandler.LightningBolt;
import vazkii.botania.client.gui.GuiLexicon;
import vazkii.botania.common.core.handler.ManaNetworkHandler;
import vazkii.botania.common.item.ItemTwigWand;
import vazkii.botania.common.lib.LibMisc;
@@ -30,6 +31,9 @@ import cpw.mods.fml.common.TickType;
public class ClientTickHandler implements ITickHandler {
public static int ticksWithLexicaOpen = 0;
public static int pageFlipTicks = 0;
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
// NO-OP
@@ -56,6 +60,28 @@ public class ClientTickHandler implements ITickHandler {
}
}
}
int ticksToOpen = 10;
if(gui instanceof GuiLexicon) {
if(ticksWithLexicaOpen < 0)
ticksWithLexicaOpen = 0;
if(ticksWithLexicaOpen < ticksToOpen)
ticksWithLexicaOpen++;
if(pageFlipTicks > 0)
pageFlipTicks--;
} else {
pageFlipTicks = 0;
if(ticksWithLexicaOpen > 0) {
if(ticksWithLexicaOpen > ticksToOpen)
ticksWithLexicaOpen = ticksToOpen;
ticksWithLexicaOpen--;
}
}
}
public static void notifyPageChange() {
if(pageFlipTicks == 0)
pageFlipTicks = 5;
}
@Override
@@ -33,6 +33,7 @@ import vazkii.botania.client.render.block.RenderPylon;
import vazkii.botania.client.render.block.RenderSpecialFlower;
import vazkii.botania.client.render.block.RenderSpreader;
import vazkii.botania.client.render.item.RenderLens;
import vazkii.botania.client.render.item.RenderLexicon;
import vazkii.botania.client.render.tile.RenderTileAltar;
import vazkii.botania.client.render.tile.RenderTileEnchanter;
import vazkii.botania.client.render.tile.RenderTilePool;
@@ -85,9 +86,10 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new RenderPool());
RenderingRegistry.registerBlockHandler(new RenderPylon());
RenderLens lensRender = new RenderLens();
MinecraftForgeClient.registerItemRenderer(ModItems.lens.itemID, lensRender);
MinecraftForgeClient.registerItemRenderer(ModItems.lens.itemID, new RenderLens());
if(ConfigHandler.lexicon3dModel)
MinecraftForgeClient.registerItemRenderer(ModItems.lexicon.itemID, new RenderLexicon());
ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar());
ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader());
ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool());
@@ -22,6 +22,7 @@ import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.button.GuiButtonInvisible;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.item.ModItems;
@@ -83,8 +84,10 @@ public class GuiLexicon extends GuiScreen {
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
LexiconCategory category = i >= categoryList.size() ? null : categoryList.get(i);
if(category != null)
if(category != null) {
mc.displayGuiScreen(new GuiLexiconIndex(category));
ClientTickHandler.notifyPageChange();
}
}
@Override
@@ -17,6 +17,7 @@ import net.minecraft.util.StatCollector;
import vazkii.botania.api.internal.IGuiLexiconEntry;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.button.GuiButtonBackWithShift;
import vazkii.botania.client.gui.button.GuiButtonPage;
@@ -77,12 +78,15 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry {
switch(par1GuiButton.id) {
case 0 :
mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent);
ClientTickHandler.notifyPageChange();
break;
case 1 :
page--;
ClientTickHandler.notifyPageChange();
break;
case 2 :
page++;
ClientTickHandler.notifyPageChange();
break;
}
updatePageButtons();
@@ -20,6 +20,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.button.GuiButtonBack;
import vazkii.botania.client.gui.button.GuiButtonInvisible;
import vazkii.botania.client.gui.button.GuiButtonPage;
@@ -80,16 +81,19 @@ public class GuiLexiconIndex extends GuiLexicon {
switch(par1GuiButton.id) {
case 12 :
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
break;
case 13 :
page--;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
break;
case 14 :
page++;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
break;
default :
int index = par1GuiButton.id + page * 12;
@@ -98,6 +102,7 @@ public class GuiLexiconIndex extends GuiLexicon {
LexiconEntry entry = entriesToDisplay.get(index);
mc.displayGuiScreen(new GuiLexiconEntry(entry, this));
ClientTickHandler.notifyPageChange();
}
}
@@ -45,6 +45,7 @@ public final class LibResources {
public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png";
public static final String MODEL_POOL = PREFIX_MODEL + "pool.png";
public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png";
public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png";
public static final String MODEL_CAPE = "/assets/botania/textures/model/cape.png";
public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png";
@@ -0,0 +1,60 @@
/**
* 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 @ [Mar 25, 2014, 8:49:01 PM (GMT)]
*/
package vazkii.botania.client.render.item;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.lib.LibResources;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBook;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
public class RenderLexicon implements IItemRenderer {
ModelBook model = new ModelBook();
ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA);
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
Minecraft mc = Minecraft.getMinecraft();
mc.renderEngine.bindTexture(texture);
float opening = 0F;
float pageFlip = 0F;
int ticks = ClientTickHandler.ticksWithLexicaOpen;
GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks);
GL11.glRotatef(95F + ticks * 5, 0F, 1F, 0F);
GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F);
GL11.glScalef(0.9F, 0.9F, 0.9F);
opening = (float) ticks / 12F;
pageFlip = (float) ClientTickHandler.pageFlipTicks / 5F;
model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F);
GL11.glPopMatrix();
}
}
@@ -29,7 +29,8 @@ public final class ConfigHandler {
public static boolean staticWandBeam = false;
public static boolean overrideVanillaBlocks = true;
public static boolean boundBlockWireframe = true;
public static boolean lexicon3dModel = true;
public static int flowerQuantity = 3;
public static int flowerDensity = 32;
@@ -58,6 +59,10 @@ public final class ConfigHandler {
boundBlockWireframeProp.comment = "Set to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc).";
boundBlockWireframe = boundBlockWireframeProp.getBoolean(true);
Property lexicon3dModelProp = config.get(Configuration.CATEGORY_GENERAL, "lexicon.render.3D", true);
lexicon3dModelProp.comment = "Set to false to disabled the animated 3D render for the lexica botania";
lexicon3dModel = lexicon3dModelProp.getBoolean(true);
Property propFlowerQuantity = config.get(Configuration.CATEGORY_GENERAL, "worldgen.flower.quantity", 3);
flowerQuantity = propFlowerQuantity.getInt(3);
Property propFlowerDensity = config.get(Configuration.CATEGORY_GENERAL, "worldgen.flower.density", 32);
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB