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;
}
}