-
Notifications
You must be signed in to change notification settings - Fork 81
/
BlockColoredGrass.java
68 lines (54 loc) · 1.87 KB
/
BlockColoredGrass.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.progwml6.natura.overworld.block.grass;
import java.util.Locale;
import com.progwml6.natura.library.NaturaRegistry;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import slimeknights.mantle.block.EnumBlock;
public class BlockColoredGrass extends EnumBlock<BlockColoredGrass.GrassType>
{
public static PropertyEnum<GrassType> TYPE = PropertyEnum.create("type", GrassType.class);
public BlockColoredGrass()
{
super(Material.GRASS, TYPE, GrassType.class);
this.setCreativeTab(NaturaRegistry.tabWorld);
this.setHardness(0.6F);
this.setSoundType(SoundType.PLANT);
}
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));
if (plantType == EnumPlantType.Plains)
{
return true;
}
return super.canSustainPlant(state, world, pos, direction, plantable);
}
public enum GrassType implements IStringSerializable, EnumBlock.IEnumMeta
{
TOPIARY, BLUEGRASS, AUTUMNAL;
public final int meta;
GrassType()
{
this.meta = this.ordinal();
}
@Override
public String getName()
{
return this.toString().toLowerCase(Locale.US);
}
@Override
public int getMeta()
{
return this.meta;
}
}
}