mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-26 06:52:58 +00:00
Preliminary work on lexicon first person model
This commit is contained in:
1 parent
7e642cb03a
commit
b6f51f1ccf
8 files changed
+288
No files matched your search
@@ -26,6 +26,7 @@ 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.LexiconModelDispatcher;
|
||||
import vazkii.botania.client.model.PlatformModel;
|
||||
import vazkii.botania.client.model.PylonItemModel;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
@@ -106,6 +107,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 LexiconModelDispatcher());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -467,6 +467,10 @@ public final class ModelHandler {
|
||||
registerItemModel(pestleAndMortar);
|
||||
registerItemModel(blackLotus);
|
||||
registerItemModel(blackLotus, 1);
|
||||
|
||||
ModelLoader.registerItemVariants(lexicon,
|
||||
new ModelResourceLocation("botania:lexicon_default", "inventory"),
|
||||
new ModelResourceLocation("botania:lexicon_firstperson", "inventory"));
|
||||
registerItemModel(lexicon);
|
||||
|
||||
registerItemModel(manasteelHelm);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package vazkii.botania.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.resources.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelState;
|
||||
import net.minecraftforge.client.model.ISmartItemModel;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.client.model.animation.Event;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LexiconAnimatedModel implements ISmartItemModel {
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
private final Map<IModelState, IBakedModel> cache; // No need to free this, LexiconAnimatedModels are destroyed on resource reload
|
||||
private final IAnimationStateMachine asm;
|
||||
|
||||
protected LexiconAnimatedModel(IBakedModel baseModel) {
|
||||
this.baseModel = baseModel;
|
||||
this.cache = new HashMap<>();
|
||||
this.asm = Animation.INSTANCE.load(new ResourceLocation("botania", "asms/item/lexicon_firstperson.json"), ImmutableMap.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(ItemStack stack) {
|
||||
float time = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 20F;
|
||||
Pair<IModelState, Iterable<Event>> pair = asm.apply(time);
|
||||
// baseModel
|
||||
return baseModel; // todo
|
||||
}
|
||||
|
||||
@Override public List<BakedQuad> getFaceQuads(EnumFacing e) { return baseModel.getFaceQuads(e); }
|
||||
@Override public List<BakedQuad> getGeneralQuads() { return baseModel.getGeneralQuads(); }
|
||||
@Override public boolean isAmbientOcclusion() { return baseModel.isAmbientOcclusion(); }
|
||||
@Override public boolean isGui3d() { return baseModel.isGui3d(); }
|
||||
@Override public boolean isBuiltInRenderer() { return baseModel.isBuiltInRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return baseModel.getParticleTexture(); }
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return baseModel.getItemCameraTransforms(); }
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package vazkii.botania.client.model;
|
||||
|
||||
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.VertexFormat;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
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 javax.vecmath.Matrix4f;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class handles choosing between the lexicon's default model and the special first person one
|
||||
*/
|
||||
public class LexiconModelDispatcher implements IPerspectiveAwareModel {
|
||||
|
||||
private IFlexibleBakedModel normalModel;
|
||||
private IFlexibleBakedModel specialModel;
|
||||
|
||||
private IFlexibleBakedModel getNormalModel() {
|
||||
if (normalModel == null) {
|
||||
normalModel = new IFlexibleBakedModel.Wrapper(Minecraft.getMinecraft()
|
||||
.getRenderItem().getItemModelMesher().getModelManager()
|
||||
.getModel(new ModelResourceLocation("botania:lexicon_default", "inventory")), Attributes.DEFAULT_BAKED_FORMAT);
|
||||
}
|
||||
return normalModel;
|
||||
}
|
||||
|
||||
private IFlexibleBakedModel getSpecialModel() {
|
||||
if (specialModel == null) {
|
||||
specialModel = new IFlexibleBakedModel.Wrapper(new LexiconAnimatedModel(Minecraft.getMinecraft()
|
||||
.getRenderItem().getItemModelMesher().getModelManager()
|
||||
.getModel(new ModelResourceLocation("botania:lexicon_firstperson", "inventory"))), Attributes.DEFAULT_BAKED_FORMAT);
|
||||
}
|
||||
return specialModel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
if (cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON) {
|
||||
return Pair.of(getSpecialModel(), new TRSRTransformation(getSpecialModel().getItemCameraTransforms().getTransform(cameraTransformType)).getMatrix());
|
||||
} else {
|
||||
return Pair.of(getNormalModel(), new TRSRTransformation(getNormalModel().getItemCameraTransforms().getTransform(cameraTransformType)).getMatrix());
|
||||
}
|
||||
}
|
||||
|
||||
@Override public VertexFormat getFormat() { return Attributes.DEFAULT_BAKED_FORMAT; }
|
||||
@Override public List<BakedQuad> getFaceQuads(EnumFacing e) { return getNormalModel().getFaceQuads(e); }
|
||||
@Override public List<BakedQuad> getGeneralQuads() { return getNormalModel().getGeneralQuads(); }
|
||||
@Override public boolean isAmbientOcclusion() { return getNormalModel().isAmbientOcclusion(); }
|
||||
@Override public boolean isGui3d() { return getNormalModel().isGui3d(); }
|
||||
@Override public boolean isBuiltInRenderer() { return getNormalModel().isBuiltInRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return getNormalModel().getParticleTexture(); }
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return getNormalModel().getItemCameraTransforms(); }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"joints": {
|
||||
"spine": { "1": [ 1.0 ] },
|
||||
"left_side": {},
|
||||
"right_side": {},
|
||||
"left_flip": { "4": [ 1.0 ] },
|
||||
"right_flip": { "5": [ 1.0 ] }
|
||||
},
|
||||
"clips": {
|
||||
"closed": {
|
||||
"loop": false,
|
||||
"joint_clips": {},
|
||||
"events": {}
|
||||
},
|
||||
"open": {
|
||||
"loop": false,
|
||||
"joint_clips": {},
|
||||
"events": {}
|
||||
},
|
||||
"opening": {
|
||||
"loop": false,
|
||||
"joint_clips": {},
|
||||
"events": {}
|
||||
},
|
||||
"closing": {
|
||||
"loop": false,
|
||||
"joint_clips": {},
|
||||
"events": {}
|
||||
},
|
||||
"flip_left": {
|
||||
"loop": false,
|
||||
"joint_clips": {},
|
||||
"events": {}
|
||||
},
|
||||
"flip_right": {
|
||||
"loop": false,
|
||||
"joint_clips": {},
|
||||
"events": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parameters": {},
|
||||
"clips": {
|
||||
"closed": "botania:block/lexicon_firstperson@closed",
|
||||
"open": "botania:block/lexicon_firstperson@open"
|
||||
},
|
||||
"states": [ "closed", "open", "opening", "closing" ],
|
||||
"transitions": {
|
||||
"closed": "opening",
|
||||
"opening": "open",
|
||||
"open": "closing",
|
||||
"closing": "closed"
|
||||
},
|
||||
"start_state": "closed"
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [ -90, 0, 0 ],
|
||||
"translation": [ 0, 1, -3 ],
|
||||
"scale": [ 0.55, 0.55, 0.55 ]
|
||||
},
|
||||
"firstperson": {
|
||||
"rotation": [ 0, -135, 25 ],
|
||||
"translation": [ 0, 4, 2 ],
|
||||
"scale": [ 1.7, 1.7, 1.7 ]
|
||||
}
|
||||
},
|
||||
"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 ] },
|
||||
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 0.0 ] },
|
||||
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 0.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 ] },
|
||||
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 0.0 ] },
|
||||
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 0.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 ] },
|
||||
"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 ] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"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 ] },
|
||||
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 0.0 ] },
|
||||
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 0.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 ] },
|
||||
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 0.0 ] },
|
||||
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 5.0, 0.0 ] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "RightPage",
|
||||
"from": [ 5.0, 1.0, 7.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, 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 ] }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user