Add NetheriteOnlyBlock and update block properties and tags
This commit is contained in:
@@ -18,13 +18,13 @@ public class ModBlocks {
|
||||
DeferredRegister.createBlocks(Stalinium.MODID);
|
||||
|
||||
public static final DeferredBlock<Block> COMPRESSED_BEDROCK = registerBlock("compressed_bedrock",
|
||||
() -> new Block(BlockBehaviour.Properties.of()
|
||||
() -> new NetheriteOnlyBlock(BlockBehaviour.Properties.of()
|
||||
.strength(50f, 1200f)
|
||||
.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.STONE)));
|
||||
|
||||
public static final DeferredBlock<Block> STALINIUM_ORE = registerBlock("stalinium_ore",
|
||||
() -> new Block(BlockBehaviour.Properties.of()
|
||||
() -> new NetheriteOnlyBlock(BlockBehaviour.Properties.of()
|
||||
.strength(5f, 6f)
|
||||
.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.NETHER_ORE)));
|
||||
@@ -35,6 +35,8 @@ public class ModBlocks {
|
||||
.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.NETHERITE_BLOCK)));
|
||||
|
||||
|
||||
|
||||
private static <T extends Block> DeferredBlock<T> registerBlock(String name, Supplier<T> block) {
|
||||
DeferredBlock<T> toReturn = BLOCKS.register(name, block);
|
||||
registerBlockItem(name, toReturn);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.krituximon.stalinium.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.Tiers;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
|
||||
public class NetheriteOnlyBlock extends Block {
|
||||
public NetheriteOnlyBlock(BlockBehaviour.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(BlockState state, BlockGetter world, BlockPos pos, Player player) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof PickaxeItem)) {
|
||||
return false;
|
||||
}
|
||||
return ((PickaxeItem) stack.getItem()).getTier() == Tiers.NETHERITE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user