mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Model cleanup
This commit is contained in:
1 parent
b6d607b553
commit
f5b435bf24
7 files changed
+4
-158
No files matched your search
@@ -27,7 +27,6 @@ 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;
|
||||
import vazkii.botania.common.item.ItemSparkUpgrade;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
@@ -87,16 +86,12 @@ public class MiscellaneousIcons {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBake(ModelBakeEvent evt) {
|
||||
FMLLog.info("The baked model for botania:jadedAmaranthus#normal is: " + evt.getModelRegistry().getObject(new ModelResourceLocation("botania:jadedAmaranthus", "normal")));
|
||||
// Floating flowers todo 1.9
|
||||
// Floating flowers
|
||||
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:miniIsland", "normal"), FloatingFlowerModel.INSTANCE);
|
||||
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:miniIsland", "inventory"), FloatingFlowerModel.INSTANCE);
|
||||
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:floatingSpecialFlower", "normal"), FloatingFlowerModel.INSTANCE);
|
||||
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:floatingSpecialFlower", "inventory"), FloatingFlowerModel.INSTANCE);
|
||||
|
||||
// Pylon item model
|
||||
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:pylon", "inventory"), new PylonItemModel());
|
||||
|
||||
// Platforms
|
||||
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:platform", "normal"), new PlatformModel());
|
||||
|
||||
|
||||
@@ -334,7 +334,6 @@ public final class ModelHandler {
|
||||
|
||||
// Register all metas to variant inventory, so the smartmodel can take over from there. See MiscellaneousIcons
|
||||
registerItemModelAllMeta(Item.getItemFromBlock(ModBlocks.floatingFlower), EnumDyeColor.values().length);
|
||||
registerItemModelAllMeta(Item.getItemFromBlock(ModBlocks.pylon), PylonVariant.values().length);
|
||||
|
||||
// Item models which all use the same base model and recolored by render layer
|
||||
registerItemModelAllMeta(Item.getItemFromBlock(ModBlocks.manaBeacon), EnumDyeColor.values().length);
|
||||
@@ -342,6 +341,7 @@ public final class ModelHandler {
|
||||
registerItemModelAllMeta(Item.getItemFromBlock(ModBlocks.unstableBlock), EnumDyeColor.values().length);
|
||||
|
||||
// Blocks which share models with their item, and have only one variant to switch over
|
||||
registerVariantsDefaulted(ModBlocks.pylon, PylonVariant.class, "variant");
|
||||
registerVariantsDefaulted(ModBlocks.altGrass, AltGrassVariant.class, "variant");
|
||||
registerVariantsDefaulted(ModFluffBlocks.biomeStoneA, BiomeStoneVariant.class, "variant");
|
||||
registerVariantsDefaulted(ModFluffBlocks.biomeStoneB, BiomeBrickVariant.class, "variant");
|
||||
|
||||
@@ -44,7 +44,6 @@ public final class RedStringRenderer {
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.color(1F, 0F, 0F, sizeAlpha);
|
||||
|
||||
// todo 1.8 Tessellator.renderingVertexBuffer = false;
|
||||
TileRedString tile;
|
||||
while((tile = redStringTiles.poll()) != null)
|
||||
renderTile(tile);
|
||||
|
||||
@@ -70,7 +70,6 @@ public final class SubTileRadiusRenderHandler {
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// todo 1.8 Tessellator.renderingVertexBuffer = false;
|
||||
|
||||
if(descriptor.isCircle())
|
||||
renderCircle(descriptor.getSubtileCoords(), descriptor.getCircleRadius());
|
||||
|
||||
@@ -25,8 +25,8 @@ public class LexiconModel implements IPerspectiveAwareModel {
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
IBakedModel original = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(path);
|
||||
if(cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND && ConfigHandler.lexicon3dModel) // todo 1.9 handedness
|
||||
return Pair.of(this, null);
|
||||
/*if(cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND && ConfigHandler.lexicon3dModel)
|
||||
return Pair.of(this, null); todo 1.9 */
|
||||
return ((IPerspectiveAwareModel) original).handlePerspective(cameraTransformType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
/**
|
||||
* This class was created by <williewillus>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
* <p>
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.client.model;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.Attributes;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class PylonItemModel implements IBakedModel {
|
||||
|
||||
private IBakedModel mana;
|
||||
private IBakedModel natura;
|
||||
private IBakedModel gaia;
|
||||
private boolean cached = false;
|
||||
private final ItemOverrideList itemHandler = new ItemOverrideList(ImmutableList.of()) {
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel original, ItemStack stack, World world, EntityLivingBase living) {
|
||||
if(!cached) {
|
||||
cacheModels();
|
||||
}
|
||||
|
||||
switch(stack.getItemDamage()) {
|
||||
case 2:
|
||||
return gaia;
|
||||
case 1:
|
||||
return natura;
|
||||
case 0:
|
||||
return mana;
|
||||
default:
|
||||
return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void cacheModels() {
|
||||
// Load the OBJ
|
||||
OBJModel model = null;
|
||||
try {
|
||||
model = ((OBJModel) OBJLoader.INSTANCE.loadModel(new ResourceLocation("botania:models/block/pylon.obj")));
|
||||
} catch(Exception e) {
|
||||
FMLLog.log(Level.ERROR, "[Botania]: Error loading pylon item model, substituting missing model");
|
||||
mana = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
|
||||
natura = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
|
||||
gaia = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
|
||||
cached = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the texture and flip the v's of the model
|
||||
IModel manaModel = ((OBJModel) model.retexture(ImmutableMap.of("#pylon", "botania:model/pylon"))).process(ImmutableMap.of("flip-v", "true"));
|
||||
IModel naturaModel = ((OBJModel) model.retexture(ImmutableMap.of("#pylon", "botania:model/pylon1"))).process(ImmutableMap.of("flip-v", "true"));
|
||||
IModel gaiaModel = ((OBJModel) model.retexture(ImmutableMap.of("#pylon", "botania:model/pylon2"))).process(ImmutableMap.of("flip-v", "true"));
|
||||
|
||||
// All groups are off by default
|
||||
// OBJState constructor is derp, so the boolean condition is inverted - pass false to turn on a group
|
||||
|
||||
final Function<ResourceLocation, TextureAtlasSprite> textureGetter = input -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(input.toString());
|
||||
|
||||
ImmutableList<String> standardGroups = ImmutableList.of("Crystal", "Crystal_Ring",
|
||||
"Ring_Panel01", "Ring_Panel02", "Ring_Panel03", "Ring_Panel04",
|
||||
"Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04");
|
||||
|
||||
mana = new PerspectiveWrapper(manaModel.bake(new OBJModel.OBJState(standardGroups, false), Attributes.DEFAULT_BAKED_FORMAT, textureGetter));
|
||||
// Natura model is just the crystal
|
||||
natura = new PerspectiveWrapper(naturaModel.bake(new OBJModel.OBJState(ImmutableList.of("Crystal"), false), Attributes.DEFAULT_BAKED_FORMAT, textureGetter));
|
||||
gaia = new PerspectiveWrapper(gaiaModel.bake(new OBJModel.OBJState(standardGroups, false), Attributes.DEFAULT_BAKED_FORMAT, textureGetter));
|
||||
cached = true;
|
||||
}
|
||||
|
||||
@Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing face, long rand) { return ImmutableList.of(); }
|
||||
@Override public boolean isAmbientOcclusion() { return false; }
|
||||
@Override public boolean isGui3d() { return true; }
|
||||
@Override public boolean isBuiltInRenderer() { return false; }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return null; }
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return itemHandler;
|
||||
}
|
||||
|
||||
// Wrapper to transform the model before rendering it, so it looks right in the inventory
|
||||
private class PerspectiveWrapper implements IPerspectiveAwareModel {
|
||||
|
||||
private final IBakedModel parent;
|
||||
|
||||
public PerspectiveWrapper(IBakedModel pylonModel) {
|
||||
this.parent = pylonModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
switch(cameraTransformType) {
|
||||
// todo 1.9 case FIRST_PERSON:
|
||||
// return ImmutablePair.of(parent, new TRSRTransformation(new Vector3f(0, 0, 0.4F), null, new Vector3f(0.75F, 0.75F, 0.75F), null).getMatrix());
|
||||
case GUI:
|
||||
return ImmutablePair.of(parent, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0.5F, 0.1F, 0), null, null, null)).getMatrix());
|
||||
// case THIRD_PERSON:
|
||||
// return ImmutablePair.of(parent, new TRSRTransformation(new Vector3f(0, -0.2F, 0.5F), null, null, null).getMatrix());
|
||||
default:
|
||||
return ImmutablePair.of(parent, TRSRTransformation.identity().getMatrix());
|
||||
}
|
||||
}
|
||||
|
||||
@Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing face, long rand) { return parent.getQuads(state, face, rand); }
|
||||
@Override public boolean isAmbientOcclusion() { return parent.isAmbientOcclusion(); }
|
||||
@Override public boolean isGui3d() { return parent.isGui3d(); }
|
||||
@Override public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
|
||||
@Override public ItemOverrideList getOverrides() { return ItemOverrideList.NONE; }
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,6 @@ public class SpecialFlowerModel implements IModelCustomData {
|
||||
// Force island models to be loaded and baked. See FloatingFlowerModel.
|
||||
builder.addAll(BotaniaAPIClient.getRegisteredIslandTypeModels().values());
|
||||
|
||||
FMLLog.info("Collected special flower dependencies: %s", builder.build());
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user