Auto-Add Block/Item Tags for BaseLeavesBlock
and FeatureSaplingBlock
(paulevsGitch/BetterEnd#303)
This commit is contained in:
parent
c2452ebcc3
commit
3683ebd97a
2 changed files with 19 additions and 10 deletions
|
@ -20,7 +20,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.BlockModelProvider;
|
||||
import ru.bclib.interfaces.RenderLayerProvider;
|
||||
|
@ -40,32 +39,24 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
|||
.blockVision((state, world, pos) -> false);
|
||||
}
|
||||
|
||||
private void init(Block sapling) {
|
||||
TagAPI.addTags(this, TagAPI.BLOCK_LEAVES);
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) {
|
||||
super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color)));
|
||||
this.sapling = sapling;
|
||||
init(sapling);
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, int light, Consumer<FabricBlockSettings> customizeProperties) {
|
||||
super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color).luminance(light)));
|
||||
this.sapling = sapling;
|
||||
init(sapling);
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color) {
|
||||
super(makeLeaves(color));
|
||||
this.sapling = sapling;
|
||||
init(sapling);
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, int light) {
|
||||
super(makeLeaves(color).lightLevel(light));
|
||||
this.sapling = sapling;
|
||||
init(sapling);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,9 @@ import net.minecraft.world.item.BlockItem;
|
|||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.blocks.BaseLeavesBlock;
|
||||
import ru.bclib.blocks.FeatureSaplingBlock;
|
||||
import ru.bclib.interfaces.CustomItemProvider;
|
||||
|
||||
public abstract class BlockRegistry extends BaseRegistry<Block> {
|
||||
|
@ -29,7 +32,22 @@ public abstract class BlockRegistry extends BaseRegistry<Block> {
|
|||
.getBurnChance() == 0) {
|
||||
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
|
||||
}
|
||||
return Registry.register(Registry.BLOCK, id, block);
|
||||
|
||||
block = Registry.register(Registry.BLOCK, id, block);
|
||||
|
||||
if (block instanceof BaseLeavesBlock){
|
||||
TagAPI.addTags(block, TagAPI.BLOCK_LEAVES);
|
||||
if (item != null){
|
||||
TagAPI.addTags(item, TagAPI.ITEM_LEAVES);
|
||||
}
|
||||
} else if (block instanceof FeatureSaplingBlock){
|
||||
TagAPI.addTags(block, TagAPI.BLOCK_SAPLINGS);
|
||||
if (item != null){
|
||||
TagAPI.addTags(item, TagAPI.ITEM_SAPLINGS);
|
||||
}
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
public Block registerBlockOnly(ResourceLocation id, Block block) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue