base mod created
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package net.minecraft.block;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockStandingSign extends BlockSign
|
||||
{
|
||||
public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15);
|
||||
|
||||
public BlockStandingSign()
|
||||
{
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, Integer.valueOf(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
|
||||
* change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
|
||||
* block, etc.
|
||||
*/
|
||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
|
||||
{
|
||||
if (!worldIn.getBlockState(pos.down()).getMaterial().isSolid())
|
||||
{
|
||||
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(ROTATION, Integer.valueOf(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((Integer)state.getValue(ROTATION)).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
|
||||
* blockstate.
|
||||
*/
|
||||
public IBlockState withRotation(IBlockState state, Rotation rot)
|
||||
{
|
||||
return state.withProperty(ROTATION, Integer.valueOf(rot.rotate(((Integer)state.getValue(ROTATION)).intValue(), 16)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
|
||||
* blockstate.
|
||||
*/
|
||||
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
||||
{
|
||||
return state.withProperty(ROTATION, Integer.valueOf(mirrorIn.mirrorRotation(((Integer)state.getValue(ROTATION)).intValue(), 16)));
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] {ROTATION});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user