diff --git a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java index 41be77176..07d39a81d 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java +++ b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java @@ -11,22 +11,32 @@ package vazkii.botania.client.core.handler; import com.google.common.collect.Maps; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.statemap.DefaultStateMapper; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.launchwrapper.Launch; +import net.minecraft.util.EnumFacing; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.model.IFlexibleBakedModel; +import net.minecraftforge.client.model.IPerspectiveAwareModel; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.apache.commons.lang3.text.WordUtils; +import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.model.FloatingFlowerModel; +import vazkii.botania.client.model.LexiconModel; import vazkii.botania.client.model.PlatformModel; import vazkii.botania.client.model.PylonItemModel; import vazkii.botania.common.integration.buildcraft.TriggerManaLevel; @@ -35,10 +45,12 @@ import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; import vazkii.botania.common.item.relic.ItemKingKey; import javax.imageio.ImageIO; +import javax.vecmath.Matrix4f; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.nio.IntBuffer; +import java.util.List; import java.util.Map; public class MiscellaneousIcons { @@ -97,6 +109,9 @@ public class MiscellaneousIcons { // Platforms evt.modelRegistry.putObject(new ModelResourceLocation("botania:platform", "normal"), new PlatformModel()); + + // Lexicon + evt.modelRegistry.putObject(new ModelResourceLocation("botania:lexicon", "inventory"), new LexiconModel()); } @SubscribeEvent diff --git a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java index cc5a57e97..412fdaca2 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -472,6 +472,7 @@ public final class ModelHandler { registerItemModel(pestleAndMortar); registerItemModel(blackLotus); registerItemModel(blackLotus, 1); + ModelLoader.registerItemVariants(lexicon, new ModelResourceLocation("botania:lexicon_default", "inventory")); registerItemModel(lexicon); registerItemModel(manasteelHelm); diff --git a/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java b/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java index 9e866eaf7..6d0d9256a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java +++ b/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java @@ -20,6 +20,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.util.glu.Project; import vazkii.botania.client.gui.lexicon.GuiLexicon; import vazkii.botania.client.lib.LibResources; +import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ItemLexicon; import vazkii.botania.common.item.ModItems; @@ -32,7 +33,7 @@ public class RenderLexicon { @SubscribeEvent public void renderItem(RenderHandEvent evt) { Minecraft mc = Minecraft.getMinecraft(); - if(mc.gameSettings.thirdPersonView != 0 || mc.thePlayer.getHeldItem() == null || mc.thePlayer.getHeldItem().getItem() != ModItems.lexicon) + if(!ConfigHandler.lexicon3dModel || mc.gameSettings.thirdPersonView != 0 || mc.thePlayer.getHeldItem() == null || mc.thePlayer.getHeldItem().getItem() != ModItems.lexicon) return; evt.setCanceled(true); @@ -94,8 +95,6 @@ public class RenderLexicon { FMLLog.warning("[Botania]: Failed to render lexicon"); throwable.printStackTrace(); } - - } private void renderItemInFirstPerson() throws Throwable { @@ -191,7 +190,7 @@ public class RenderLexicon { GlStateManager.popMatrix(); } - // ItemRenderer.func_178101_a + // Copy - ItemRenderer.func_178101_a private void func_178101_a(float angle, float p_178101_2_) { GlStateManager.pushMatrix(); GlStateManager.rotate(angle, 1.0F, 0.0F, 0.0F); @@ -226,7 +225,7 @@ public class RenderLexicon { // Copy with modification - ItemRenderer.transformFirstPersonItem private void transformFirstPersonItem(float equipProgress, float swingProgress) { - GlStateManager.translate(1F, -1F, -0.71999997F); // Botania - x(0.56) -> 1; y(-0.52) -> -1 + GlStateManager.translate(1.2F, -1F, -0.71999997F); // Botania - x(0.56) -> 1; y(-0.52) -> -1 GlStateManager.translate(0.0F, equipProgress * -0.6F, 0.0F); GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); // Botania - 45 -> 90 GlStateManager.rotate(-20, 0, 0, 1); // Botania - added diff --git a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java index b81582816..ed67e9528 100644 --- a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java +++ b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java @@ -137,7 +137,7 @@ public class FloatingFlowerModel implements ISmartItemModel, ISmartBlockModel, I // Enhance! CompositeBakedModel model = new CompositeBakedModel(flowerModel, islandModel); - FMLLog.info("[Botania]: Cached floating flower model for islandtpye %s and flowertype %s", islandType, identifier); + FMLLog.info("[Botania]: Cached floating flower model for islandtype %s and flowertype %s", islandType, identifier); CACHE.put(islandType, identifier, model); return model; } diff --git a/src/main/java/vazkii/botania/client/model/LexiconModel.java b/src/main/java/vazkii/botania/client/model/LexiconModel.java new file mode 100644 index 000000000..209966c61 --- /dev/null +++ b/src/main/java/vazkii/botania/client/model/LexiconModel.java @@ -0,0 +1,43 @@ +package vazkii.botania.client.model; + +import com.google.common.collect.ImmutableList; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.client.model.Attributes; +import net.minecraftforge.client.model.IFlexibleBakedModel; +import net.minecraftforge.client.model.IPerspectiveAwareModel; +import net.minecraftforge.client.model.TRSRTransformation; +import org.apache.commons.lang3.tuple.Pair; +import vazkii.botania.common.core.handler.ConfigHandler; + +import javax.vecmath.Matrix4f; +import java.util.List; + +public class LexiconModel implements IPerspectiveAwareModel { + @Override + public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { + ModelResourceLocation path = new ModelResourceLocation("botania:lexicon_default", "inventory"); + IBakedModel original = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(path); + if(cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON && ConfigHandler.lexicon3dModel) { + return Pair.of(this, null); + } + + return Pair.of(new IFlexibleBakedModel.Wrapper(original, Attributes.DEFAULT_BAKED_FORMAT), new TRSRTransformation(original.getItemCameraTransforms().getTransform(cameraTransformType)).getMatrix()); + } + + @Override public VertexFormat getFormat() { return DefaultVertexFormats.ITEM; } + @Override public List getFaceQuads(EnumFacing p_177551_1_) { return ImmutableList.of(); } + @Override public List getGeneralQuads() { return ImmutableList.of(); } + @Override public boolean isAmbientOcclusion() { return false; } + @Override public boolean isGui3d() { return false; } + @Override public boolean isBuiltInRenderer() { return false; } + @Override public TextureAtlasSprite getParticleTexture() { return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("botania:items/lexicon"); } + @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } +} diff --git a/src/main/resources/assets/botania/models/item/lexicon.json b/src/main/resources/assets/botania/models/item/lexicon_default.json similarity index 100% rename from src/main/resources/assets/botania/models/item/lexicon.json rename to src/main/resources/assets/botania/models/item/lexicon_default.json diff --git a/src/main/resources/assets/botania/models/item/lexicon_firstperson.json b/src/main/resources/assets/botania/models/item/lexicon_firstperson.json deleted file mode 100644 index b0cd2ab5b..000000000 --- a/src/main/resources/assets/botania/models/item/lexicon_firstperson.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "elements": [ - { - "name": "FrontCover", - "from": [ 5.0, 0.0, 9.0 ], - "to": [ 11.0, 10.0, 9.0 ], - "faces": { - "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 10.0 ] }, - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 10.0 ] }, - "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 10.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 10.0 ] } - } - }, - { - "name": "Spine", - "from": [ 5.0, 0.0, 7.0 ], - "to": [ 5.0, 10.0, 9.0 ], - "faces": { - "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 10.0 ] }, - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 10.0 ] }, - "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 10.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 2.0, 10.0 ] }, - "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 2.0 ] }, - "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 2.0 ] } - } - }, - { - "name": "BackCover", - "from": [ 5.0, 0.0, 7.0 ], - "to": [ 11.0, 10.0, 7.0 ], - "faces": { - "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 10.0 ] }, - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 10.0 ] }, - "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 10.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 10.0 ] } - } - }, - { - "name": "LeftPage", - "from": [ 5.0, 1.0, 8.0 ], - "to": [ 10.0, 9.0, 9.0 ], - "faces": { - "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 8.0 ] }, - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, - "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 1.0 ] }, - "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 1.0 ] } - } - }, - { - "name": "LeftPageInner", - "from": [ 5.0, 1.0, 8.0 ], - "to": [ 10.0, 9.0, 8.0 ], - "faces": { - "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 8.0 ] }, - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 8.0 ] }, - "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 8.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 8.0 ] } - } - }, - { - "name": "RightPageInner", - "from": [ 5.0, 1.0, 8.0 ], - "to": [ 10.0, 9.0, 8.0 ], - "faces": { - "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 8.0 ] }, - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 8.0 ] }, - "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 8.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 0.0, 8.0 ] } - } - }, - { - "name": "RightPage", - "from": [ 5.0, 1.0, 7.0 ], - "to": [ 10.0, 9.0, 8.0 ], - "faces": { - "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, - "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 8.0 ] }, - "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, - "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 1.0 ] }, - "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 1.0 ] } - } - } - ] -} \ No newline at end of file