More work on animation api

This commit is contained in:
Vincent Lee committed 2016-01-25 09:38:04 -06:00
1 parent 89e00c7ae8
commit 67605075d8
5 files changed
+35 -38

No files matched your search

@@ -11,6 +11,7 @@
package vazkii.botania.common.block.mana;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@@ -21,6 +22,10 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.BlockModContainer;
@@ -38,12 +43,12 @@ public class BlockPump extends BlockModContainer implements ILexiconable {
setStepSound(soundTypeStone);
setUnlocalizedName(LibBlockNames.PUMP);
setBlockBounds(EnumFacing.Axis.X);
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.CARDINALS, EnumFacing.SOUTH));
setDefaultState(blockState.getBaseState().withProperty(Properties.StaticProperty, true).withProperty(BotaniaStateProps.CARDINALS, EnumFacing.SOUTH));
}
@Override
public BlockState createBlockState() {
return new BlockState(this, BotaniaStateProps.CARDINALS);
return new ExtendedBlockState(this, new IProperty[] { BotaniaStateProps.CARDINALS, Properties.StaticProperty }, new IUnlistedProperty[] { Properties.AnimationProperty });
}
@Override
@@ -51,6 +56,11 @@ public class BlockPump extends BlockModContainer implements ILexiconable {
return state.getValue(BotaniaStateProps.CARDINALS).getIndex();
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return state.withProperty(Properties.StaticProperty, true);
}
@Override
public IBlockState getStateFromMeta(int meta) {
if (meta < 2 || meta > 5) {
@@ -78,6 +88,14 @@ public class BlockPump extends BlockModContainer implements ILexiconable {
}
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
if (worldIn.isRemote && worldIn.getTileEntity(pos) instanceof TilePump) {
((TilePump) worldIn.getTileEntity(pos)).asm().transition("moving");
}
return true;
}
@Override
public boolean isOpaqueCube() {
return false;
@@ -46,7 +46,7 @@ public class TilePump extends TileMod implements IAnimationProvider {
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));
asm = Animation.INSTANCE.load(new ResourceLocation("botania", "asms/block/pump.json"), ImmutableMap.of());
} else {
move = null;
asm = null;
@@ -114,8 +114,6 @@ public class TilePump extends TileMod implements IAnimationProvider {
@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) {