Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BlockWispFlame extends Block implements ITileEntityProvider {
- Random random = new Random();
- public static final PropertyInteger COLOR = PropertyInteger.create("color", 0, 4);
- public BlockWispFlame(String name, Material material){
- super(material);
- this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, Integer.valueOf(0)));
- float light = random.nextFloat() * (0.7F - 0.4F) + 0.4F;
- this.setLightLevel(light);
- setUnlocalizedName(name);
- setRegistryName(name);
- this.setLightOpacity(0);
- ModBlocks.BLOCKS.add(this);
- ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
- }
- @Override
- protected BlockStateContainer createBlockState(){
- return new BlockStateContainer(this, new IProperty[] {COLOR});
- }
- @Override
- public int getMetaFromState(IBlockState state){
- return state.getValue(COLOR);
- }
- @Override
- public IBlockState getStateFromMeta(int meta){
- return this.getDefaultState().withProperty(COLOR, meta);
- }
- @Override
- public TileEntity createNewTileEntity(World worldIn, int meta) {
- return new TileEntityWispFlame();
- }
- @Override
- public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
- {
- return null;
- }
- @SideOnly(Side.CLIENT)
- public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand){
- double height = random.nextFloat() * (0.7F - 0.4F) + 0.4F;
- int color = stateIn.getValue(COLOR);
- switch(color) {
- case 0:
- worldIn.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + 0.5D, pos.getY() + height, pos.getZ() + 0.5D, 0, 0, 0);
- break;
- case 1:
- Particles.BLUE_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
- break;
- case 2:
- Particles.RED_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
- break;
- case 3:
- Particles.GREEN_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
- break;
- case 4:
- Particles.PURPLE_FLAME.spawn(worldIn,pos.getX()+0.5D, pos.getY() + height, pos.getZ()+0.5D, 0, 0, 0);
- }
- }
- @Override
- public boolean isCollidable() {
- return false;
- }
- @Override
- public boolean isOpaqueCube(IBlockState state) {
- return false;
- }
- @Override
- public BlockRenderLayer getBlockLayer() {
- return BlockRenderLayer.TRANSLUCENT;
- }
- @Override
- public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) {
- return true;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos)
- {
- return 15728880;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement