-
Notifications
You must be signed in to change notification settings - Fork 18
/
BlockEnlightenedBush.java
101 lines (85 loc) · 2.8 KB
/
BlockEnlightenedBush.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package knightminer.inspirations.building.block;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import knightminer.inspirations.building.tileentity.TileEnlightenedBush;
import knightminer.inspirations.common.Config;
import knightminer.inspirations.common.IHidable;
import knightminer.inspirations.library.util.TextureBlockUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class BlockEnlightenedBush extends Block implements IHidable {
private final int color;
public BlockEnlightenedBush(int color) {
super(Block.Properties.create(Material.LEAVES)
.lightValue(15)
.hardnessAndResistance(0.2F)
.sound(SoundType.PLANT)
);
this.color = color;
}
public int getColor() {
return color;
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEnlightenedBush();
}
@Override
public boolean isEnabled() {
return Config.enableEnlightenedBush.get();
}
@Override
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
if(shouldAddtoItemGroup(group)) {
TextureBlockUtil.addBlocksFromTag(BlockTags.LEAVES, this, items);
}
}
/*
* Properties
*/
@Override
public boolean causesSuffocation(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos) {
return false;
}
@Nonnull
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT_MIPPED;
}
public boolean canEntitySpawn(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, EntityType<?> type) {
return type == EntityType.OCELOT || type == EntityType.PARROT;
}
/*
* Texturing
*/
@Override
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
TextureBlockUtil.placeTextureBlock(world, pos, stack);
}
@Nonnull
@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
return TextureBlockUtil.getBlockItemStack(world, pos, state);
}
}