/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Nov 14, 2014, 4:43:14 PM (GMT)]
*/
package vazkii.botania.common.block.string;
import javax.annotation.Nonnull;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.client.core.handler.ModelHandler;
import vazkii.botania.common.block.BlockMod;
import vazkii.botania.common.lexicon.LexiconData;
public abstract class BlockRedString extends BlockMod implements ILexiconable {
public BlockRedString(String name) {
super(Material.ROCK, name);
setHardness(2.0F);
setResistance(10.0F);
setSoundType(SoundType.STONE);
}
@Nonnull
@Override
public BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BotaniaStateProps.FACING);
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
EnumFacing orientation = EnumFacing.getDirectionFromEntityLiving(pos, par5EntityLivingBase);
world.setBlockState(pos, state.withProperty(BotaniaStateProps.FACING, orientation), 1 | 2);
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(BotaniaStateProps.FACING).getIndex();
}
@Nonnull
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(BotaniaStateProps.FACING, EnumFacing.getFront(meta));
}
@Override
public boolean hasTileEntity(IBlockState state) {
return true;
}
@Override
public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) {
return LexiconData.redString;
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels() {
ModelHandler.registerBlockToState(this, 0, getDefaultState().withProperty(BotaniaStateProps.FACING, EnumFacing.NORTH));
}
}