package com.yolp900.itsjustacharm.common.blocks;
import com.yolp900.itsjustacharm.api.IJCConstants;
import com.yolp900.itsjustacharm.common.avchievemetns.ICraftAchievement;
import com.yolp900.itsjustacharm.common.avchievemetns.ModAchievements;
import com.yolp900.itsjustacharm.common.blocks.base.ModBlock;
import com.yolp900.itsjustacharm.common.tileEntities.TileEntityLevitator;
import com.yolp900.itsjustacharm.reference.LibMisc;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BlockLevitator extends ModBlock implements ITileEntityProvider, ICraftAchievement {
public static final PropertyBool POWERED = PropertyBool.create(LibMisc.POWERED.toLowerCase());
public BlockLevitator() {
super(IJCConstants.Blocks.Levitator, Material.ROCK);
this.setHardness(1);
this.setResistance(8);
setDefaultState(this.blockState.getBaseState().withProperty(POWERED, false));
}
@Override
@Nonnull
public BlockStateContainer createBlockState() {
return new BlockStateContainer(this, POWERED);
}
@Override
@Nonnull
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile == null || !(tile instanceof TileEntityLevitator)) return state;
TileEntityLevitator levitator = (TileEntityLevitator) tile;
return state.withProperty(POWERED, levitator.isPowered());
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
@Nonnull
public TileEntity createNewTileEntity(@Nonnull World world, int meta) {
return new TileEntityLevitator();
}
@Override
public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) {
return ModAchievements.CraftLevitator.getAchievement();
}
}