Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package netvirtuahd.mart.blocks;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.PropertyDirection;
- import net.minecraft.block.state.BlockState;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumWorldBlockLayer;
- import net.minecraft.world.World;
- import netvirtuahd.mart.Main;
- public class EAP extends Block {
- public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
- public EAP(String unlocalizedName, Material material){
- super(material);
- this.setUnlocalizedName(unlocalizedName);
- this.setCreativeTab(Main.tabMart);
- useNeighborBrightness = true;
- setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
- }
- @Override
- public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
- {
- worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()));
- }
- @Override
- public IBlockState getStateFromMeta(int meta)
- {
- EnumFacing facing = EnumFacing.getFront(meta);
- if (facing.getAxis() == EnumFacing.Axis.Y)
- facing = EnumFacing.NORTH;
- return getDefaultState().withProperty(FACING, facing);
- }
- @Override
- public int getMetaFromState(IBlockState state)
- {
- return state.getValue(FACING).getIndex();
- }
- @Override
- protected BlockState createBlockState()
- {
- return new BlockState(this, FACING);
- }
- @Override
- public boolean isOpaqueCube() {
- return false;
- }
- @Override
- public boolean isFullCube() {
- return false;
- }
- public EAP(String unlocalizedName, float hardness, float resistance) {
- this(unlocalizedName, Material.rock);
- }
- public EAP(String unlocalizedName) {
- this(unlocalizedName, 2.0f, 10.0f);
- }
- @Override
- public EnumWorldBlockLayer getBlockLayer() {
- return EnumWorldBlockLayer.CUTOUT;
- }
- @Override
- public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) {
- float f = 0.125F;
- return new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)((float)(pos.getY() + 1) - f), (double)(pos.getZ() + 1));
- }
- @Override
- public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
- entity.motionX *= 2.3D;
- entity.motionY *= 2.3D;
- }
- @Override
- public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
- player.openGui(Main.instance, Main.modguidefaultcraftingtable, world, pos.getX(), pos.getY(), pos.getZ());
- return super.onBlockActivated(world, pos, state, player, side, hitX, hitY, hitZ);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment