Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (40 sloc) 1.89 KB
package com.ayutaki.chinjufumod.init.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFacingSapo extends Block {
/*向きをいれておく変数として FACING を宣言*/
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public BlockFacingSapo(Material material) {
super(material);
/*デフォルトを北向きにする*/
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
}
/*getOppositeでプレイヤーの向きを取得*/
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/*IBlockStateからItemStackのmetadataを生成。ドロップ時とテクスチャ・モデル参照時に呼ばれる。*/
@Override
public int getMetaFromState(IBlockState state) {
return ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
}
/*ItemStackのmetadataからIBlockStateを生成。設置時に呼ばれる。*/
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
}
/*初期BlockStateContainerの生成。*/
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] { FACING });
}
}
You can’t perform that action at this time.