Made the old model not render in 1p

This commit is contained in:
Vincent Lee committed 2016-03-12 00:51:34 -06:00
1 parent e031b3b52c
commit 949fdde057
7 files changed
+64 -91

No files matched your search

@@ -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
@@ -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);
@@ -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
@@ -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;
}
@@ -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<? extends IFlexibleBakedModel, Matrix4f> 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<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) { return ImmutableList.of(); }
@Override public List<BakedQuad> 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; }
}