First attempt at animation API

This commit is contained in:
Vincent Lee committed 2016-01-25 00:19:04 -06:00
1 parent 7601eecba3
commit 89e00c7ae8
9 files changed
+268 -14

No files matched your search

@@ -630,7 +630,7 @@ public final class ModelHandler {
ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.hourglass), 0, TileHourglass.class);
registerItemModel(ModBlocks.pump); // todo await animation api
ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.pump), 0, TilePump.class);
//ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.pump), 0, TilePump.class);
registerItemModel(ModBlocks.teruTeruBozu);
ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.teruTeruBozu), 0, TileTeruTeruBozu.class);
@@ -806,7 +806,6 @@ public final class ModelHandler {
ModelLoader.setCustomStateMapper(ModBlocks.brewery, new StateMap.Builder().ignore(BotaniaStateProps.POWERED).build());
ModelLoader.setCustomStateMapper(ModBlocks.gaiaHead, new StateMap.Builder().ignore(BlockSkull.FACING, BlockSkull.NODROP).build());
ModelLoader.setCustomStateMapper(ModBlocks.hourglass, new StateMap.Builder().ignore(BotaniaStateProps.POWERED).build());
ModelLoader.setCustomStateMapper(ModBlocks.pump, new StateMap.Builder().ignore(BotaniaStateProps.CARDINALS).build());
}
private static void registerMushrooms() {
@@ -34,6 +34,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraftforge.client.model.animation.AnimationTESR;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.item.IExtendedPlayerController;
import vazkii.botania.api.lexicon.LexiconEntry;
@@ -236,14 +237,13 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingFlower.class, renderTileFloatingFlower);
ClientRegistry.bindTileEntitySpecialRenderer(TileFloatingSpecialFlower.class, renderTileFloatingFlower);
ClientRegistry.bindTileEntitySpecialRenderer(TileTinyPotato.class, new RenderTileTinyPotato());
// ClientRegistry.bindTileEntitySpecialRenderer(TileSpawnerClaw.class, new RenderTileSpawnerClaw());
ClientRegistry.bindTileEntitySpecialRenderer(TileStarfield.class, new RenderTileStarfield());
ClientRegistry.bindTileEntitySpecialRenderer(TileBrewery.class, new RenderTileBrewery());
ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate());
ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString());
ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism());
ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex());
ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderTilePump());
ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new AnimationTESR<>());
ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaCrystalCube.class, new RenderTileCorporeaCrystalCube());
ClientRegistry.bindTileEntitySpecialRenderer(TileIncensePlate.class, new RenderTileIncensePlate());
ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass());
@@ -78,11 +78,6 @@ public class BlockPump extends BlockModContainer implements ILexiconable {
}
}
@Override
public int getRenderType() {
return 2;
}
@Override
public boolean isOpaqueCube() {
return false;
@@ -10,14 +10,23 @@
*/
package vazkii.botania.common.block.tile.mana;
import com.google.common.collect.ImmutableMap;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ITickable;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.animation.Animation;
import net.minecraftforge.client.model.animation.IAnimationProvider;
import net.minecraftforge.client.model.animation.ITimeValue;
import net.minecraftforge.client.model.animation.TimeValues;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.common.block.tile.TileMod;
public class TilePump extends TileMod {
public class TilePump extends TileMod implements IAnimationProvider {
private static final String TAG_ACTIVE = "active";
@@ -31,6 +40,19 @@ public class TilePump extends TileMod {
public boolean hasRedstone = false;
int lastComparator = 0;
private final TimeValues.VariableValue move;
private final IAnimationStateMachine asm;
public TilePump() {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
move = new TimeValues.VariableValue(0);
asm = Animation.INSTANCE.load(new ResourceLocation("botania", "asms/block/pump.json"), ImmutableMap.of("move", move));
} else {
move = null;
asm = null;
}
}
@Override
public void updateEntity() {
hasRedstone = false;
@@ -64,11 +86,15 @@ public class TilePump extends TileMod {
moving = 0F;
}
}
move.setValue(innerRingPos);
if(!hasCartOnTop)
comparator = 0;
if(!hasCart && active)
if(!hasCart && active) {
setActive(false);
}
if(active && hasRedstone)
setActive(false);
@@ -88,6 +114,8 @@ public class TilePump extends TileMod {
@Override
public void readCustomNBT(NBTTagCompound cmp) {
active = cmp.getBoolean(TAG_ACTIVE);
if(worldObj != null && worldObj.isRemote)
asm.transition(active ? "moving" : "default");
}
public void setActive(boolean active) {
@@ -99,4 +127,8 @@ public class TilePump extends TileMod {
}
}
@Override
public IAnimationStateMachine asm() {
return asm;
}
}
@@ -0,0 +1,24 @@
{
"joints": {
"head": { "0": [ 1.0 ], "1": [ 1.0 ], "2": [ 1.0 ], "3": [ 1.0 ] }
},
"clips": {
"default": {
"loop": false,
"joint_clips": {},
"events": {}
},
"moving": {
"loop": true,
"joint_clips": {
"head": [{
"variable": "offset_z",
"type": "uniform",
"interpolation": "linear",
"samples": [ 0.0, 3.2, 4.0, 4.8, 8.0, 4.8, 4.0, 3.2, 0.0 ]
}]
},
"events": {}
}
}
}
@@ -0,0 +1,13 @@
{
"parameters": {},
"clips": {
"default": "botania:block/pump_head@default",
"moving": [ "apply", "botania:block/pump_head@moving", "#move"]
},
"states": [ "default", "moving" ],
"transitions": {
"default": "moving",
"moving": "default"
},
"start_state": "default"
}
@@ -1,12 +1,52 @@
{
"forge_marker": 1,
"defaults": {
"model": "botania:dummy",
"model": "botania:pump",
"textures": {
"particle": "botania:blocks/livingrock0"
}
},
"transform": "forge:default-block"
},
"variants": {
"normal": [{}]
"facing": {
"north": {
"submodel": {
"head": {
"model": "botania:pump_head"
}
}
},
"south": {
"y": 180,
"submodel": {
"head": {
"model": "botania:pump_head"
}
}
},
"west": {
"y": 270,
"submodel": {
"head": {
"model": "botania:pump_head"
}
}
},
"east": {
"y": 90,
"submodel": {
"head": {
"model": "botania:pump_head"
}
}
}
},
"inventory": [{
"submodel": {
"head": {
"model": "botania:pump_head"
}
}
}]
}
}
@@ -0,0 +1,95 @@
{
"elements": [
{
"name": "EndNorth",
"from": [ 4.0, 0.0, 0.0 ],
"to": [ 12.0, 8.0, 1.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 8.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 8.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] }
}
},
{
"name": "EndSouth",
"from": [ 4.0, 0.0, 15.0 ],
"to": [ 12.0, 8.0, 16.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 8.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 8.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 8.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] }
}
},
{
"name": "Axle",
"from": [ 6.0, 2.0, 1.0 ],
"to": [ 10.0, 6.0, 15.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 4.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 4.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 4.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 4.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 14.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 14.0 ] }
}
},
{
"name": "PinkTop",
"from": [ 4.0, 7.0, 11.0 ],
"to": [ 12.0, 8.0, 15.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 4.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 4.0 ] }
}
},
{
"name": "PinkBottom",
"from": [ 4.0, 0.0, 11.0 ],
"to": [ 12.0, 1.0, 15.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 4.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 8.0, 4.0 ] }
}
},
{
"name": "PinkWest",
"from": [ 4.0, 1.0, 11.0 ],
"to": [ 5.0, 7.0, 15.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 6.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 6.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] }
}
},
{
"name": "PinkEast",
"from": [ 11.0, 1.0, 11.0 ],
"to": [ 12.0, 7.0, 15.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 6.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 4.0, 6.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] }
}
}
]
}
@@ -0,0 +1,56 @@
{
"elements": [
{
"name": "BlueTop",
"from": [ 5.0, 6.0, 1.0 ],
"to": [ 11.0, 7.0, 7.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ] }
}
},
{
"name": "BlueBottom",
"from": [ 5.0, 1.0, 1.0 ],
"to": [ 11.0, 2.0, 7.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 1.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ] }
}
},
{
"name": "BlueWest",
"from": [ 5.0, 2.0, 1.0 ],
"to": [ 6.0, 6.0, 7.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 4.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 4.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] }
}
},
{
"name": "BlueEast",
"from": [ 10.0, 2.0, 1.0 ],
"to": [ 11.0, 6.0, 7.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
"east": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 4.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
"west": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 4.0 ] },
"up": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
"down": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 6.0 ] }
}
}
]
}