New Interfaces to handle MineableTags for Blocks
This commit is contained in:
parent
7e981ca1d9
commit
5f17127ba5
13 changed files with 65 additions and 27 deletions
|
@ -10,6 +10,7 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import ru.bclib.BCLib;
|
import ru.bclib.BCLib;
|
||||||
import ru.bclib.api.biomes.BiomeAPI;
|
import ru.bclib.api.biomes.BiomeAPI;
|
||||||
|
import ru.bclib.api.tag.NamedMineableTags;
|
||||||
import ru.bclib.api.tag.TagAPI;
|
import ru.bclib.api.tag.TagAPI;
|
||||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||||
import ru.bclib.blocks.BaseBarrelBlock;
|
import ru.bclib.blocks.BaseBarrelBlock;
|
||||||
|
@ -23,6 +24,7 @@ import ru.bclib.config.Configs;
|
||||||
import ru.bclib.interfaces.PostInitable;
|
import ru.bclib.interfaces.PostInitable;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.interfaces.tools.*;
|
||||||
import ru.bclib.registry.BaseBlockEntities;
|
import ru.bclib.registry.BaseBlockEntities;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -111,6 +113,24 @@ public class PostInitAPI {
|
||||||
else if (block instanceof BaseFurnaceBlock) {
|
else if (block instanceof BaseFurnaceBlock) {
|
||||||
BaseBlockEntities.FURNACE.registerBlock(block);
|
BaseBlockEntities.FURNACE.registerBlock(block);
|
||||||
}
|
}
|
||||||
|
if (block instanceof AddMineableShears){
|
||||||
|
TagAPI.addBlockTags(block, NamedMineableTags.SHEARS);
|
||||||
|
}
|
||||||
|
if (block instanceof AddMineableAxe){
|
||||||
|
TagAPI.addBlockTags(block, NamedMineableTags.AXE);
|
||||||
|
}
|
||||||
|
if (block instanceof AddMineablePickaxe){
|
||||||
|
TagAPI.addBlockTags(block, NamedMineableTags.PICKAXE);
|
||||||
|
}
|
||||||
|
if (block instanceof AddMineableShovel){
|
||||||
|
TagAPI.addBlockTags(block, NamedMineableTags.SHOVEL);
|
||||||
|
}
|
||||||
|
if (block instanceof AddMineableHoe){
|
||||||
|
TagAPI.addBlockTags(block, NamedMineableTags.HOE);
|
||||||
|
}
|
||||||
|
if (block instanceof AddMineableSword){
|
||||||
|
TagAPI.addBlockTags(block, NamedMineableTags.SWORD);
|
||||||
|
}
|
||||||
if (block instanceof TagProvider) {
|
if (block instanceof TagProvider) {
|
||||||
TagProvider.class.cast(block).addTags(blockTags, itemTags);
|
TagProvider.class.cast(block).addTags(blockTags, itemTags);
|
||||||
blockTags.forEach(tag -> TagAPI.addBlockTag(tag, block));
|
blockTags.forEach(tag -> TagAPI.addBlockTag(tag, block));
|
||||||
|
|
|
@ -24,6 +24,8 @@ import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.BlockModelProvider;
|
import ru.bclib.interfaces.BlockModelProvider;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableHoe;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableShears;
|
||||||
import ru.bclib.items.tool.BaseShearsItem;
|
import ru.bclib.items.tool.BaseShearsItem;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, RenderLayerProvider, TagProvider {
|
public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, RenderLayerProvider, TagProvider, AddMineableShears, AddMineableHoe {
|
||||||
protected final Block sapling;
|
protected final Block sapling;
|
||||||
|
|
||||||
private static FabricBlockSettings makeLeaves(MaterialColor color) {
|
private static FabricBlockSettings makeLeaves(MaterialColor color) {
|
||||||
|
@ -100,8 +102,6 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
||||||
blockTags.add(NamedMineableTags.SHEARS);
|
|
||||||
blockTags.add(NamedMineableTags.HOE);
|
|
||||||
blockTags.add(NamedBlockTags.LEAVES);
|
blockTags.add(NamedBlockTags.LEAVES);
|
||||||
itemTags.add(NamedItemTags.LEAVES);
|
itemTags.add(NamedItemTags.LEAVES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.world.item.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.OreBlock;
|
import net.minecraft.world.level.block.OreBlock;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -17,7 +18,11 @@ import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
|
import ru.bclib.api.tag.NamedCommonBlockTags;
|
||||||
|
import ru.bclib.api.tag.NamedMineableTags;
|
||||||
|
import ru.bclib.api.tag.TagAPI;
|
||||||
import ru.bclib.interfaces.BlockModelProvider;
|
import ru.bclib.interfaces.BlockModelProvider;
|
||||||
|
import ru.bclib.interfaces.TagProvider;
|
||||||
import ru.bclib.util.LootUtil;
|
import ru.bclib.util.LootUtil;
|
||||||
import ru.bclib.util.MHelper;
|
import ru.bclib.util.MHelper;
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,15 @@ import ru.bclib.client.models.PatternsHelper;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableHoe;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableShears;
|
||||||
import ru.bclib.items.tool.BaseShearsItem;
|
import ru.bclib.items.tool.BaseShearsItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, TagProvider {
|
public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, AddMineableShears, AddMineableHoe {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||||
|
|
||||||
public BasePlantBlock() {
|
public BasePlantBlock() {
|
||||||
|
@ -170,10 +172,4 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
||||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation);
|
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_CROSS, resourceLocation);
|
||||||
return ModelsHelper.fromPattern(pattern);
|
return ModelsHelper.fromPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
|
||||||
blockTags.add(NamedMineableTags.SHEARS);
|
|
||||||
blockTags.add(NamedMineableTags.HOE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,12 @@ import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableHoe;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableShears;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerProvider, TagProvider {
|
public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerProvider, TagProvider, AddMineableShears, AddMineableHoe {
|
||||||
public SimpleLeavesBlock(MaterialColor color) {
|
public SimpleLeavesBlock(MaterialColor color) {
|
||||||
this(
|
this(
|
||||||
FabricBlockSettings
|
FabricBlockSettings
|
||||||
|
@ -58,8 +60,6 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
||||||
blockTags.add(NamedMineableTags.SHEARS);
|
|
||||||
blockTags.add(NamedMineableTags.HOE);
|
|
||||||
blockTags.add(NamedBlockTags.LEAVES);
|
blockTags.add(NamedBlockTags.LEAVES);
|
||||||
itemTags.add(NamedItemTags.LEAVES);
|
itemTags.add(NamedItemTags.LEAVES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,14 @@ import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableHoe;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableShears;
|
||||||
import ru.bclib.items.tool.BaseShearsItem;
|
import ru.bclib.items.tool.BaseShearsItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer, TagProvider {
|
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer, AddMineableShears, AddMineableHoe {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||||
|
|
||||||
public UnderwaterPlantBlock() {
|
public UnderwaterPlantBlock() {
|
||||||
|
@ -161,10 +163,5 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return Fluids.WATER.getSource(false);
|
return Fluids.WATER.getSource(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
|
||||||
blockTags.add(NamedMineableTags.SHEARS);
|
|
||||||
blockTags.add(NamedMineableTags.HOE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,13 @@ import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.RenderLayerProvider;
|
import ru.bclib.interfaces.RenderLayerProvider;
|
||||||
import ru.bclib.interfaces.TagProvider;
|
import ru.bclib.interfaces.TagProvider;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableHoe;
|
||||||
|
import ru.bclib.interfaces.tools.AddMineableShears;
|
||||||
import ru.bclib.items.tool.BaseShearsItem;
|
import ru.bclib.items.tool.BaseShearsItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, TagProvider {
|
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, AddMineableShears, AddMineableHoe {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
|
||||||
|
|
||||||
public UpDownPlantBlock() {
|
public UpDownPlantBlock() {
|
||||||
|
@ -106,10 +108,4 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements Rende
|
||||||
super.playerDestroy(world, player, pos, state, blockEntity, stack);
|
super.playerDestroy(world, player, pos, state, blockEntity, stack);
|
||||||
world.neighborChanged(pos, Blocks.AIR, pos.below());
|
world.neighborChanged(pos, Blocks.AIR, pos.below());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
|
||||||
blockTags.add(NamedMineableTags.SHEARS);
|
|
||||||
blockTags.add(NamedMineableTags.HOE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package ru.bclib.interfaces.tools;
|
||||||
|
|
||||||
|
public interface AddMineableAxe {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package ru.bclib.interfaces.tools;
|
||||||
|
|
||||||
|
public interface AddMineableHoe {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package ru.bclib.interfaces.tools;
|
||||||
|
|
||||||
|
public interface AddMineablePickaxe {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package ru.bclib.interfaces.tools;
|
||||||
|
|
||||||
|
public interface AddMineableShears {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package ru.bclib.interfaces.tools;
|
||||||
|
|
||||||
|
public interface AddMineableShovel {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package ru.bclib.interfaces.tools;
|
||||||
|
|
||||||
|
public interface AddMineableSword {
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue