Dragon tree prototype (WIP)

This commit is contained in:
paulevsGitch 2020-11-01 00:49:29 +03:00
parent 30f7f53c7f
commit 3691e4b67e
21 changed files with 324 additions and 15 deletions

View file

@ -2,6 +2,7 @@ package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
@ -16,6 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
@ -29,7 +31,7 @@ public class BlockTerrain extends BlockBase {
private Block pathBlock;
public BlockTerrain(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND));
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND).ticksRandomly());
}
public void setPathBlock(Block roadBlock) {
@ -59,4 +61,11 @@ public class BlockTerrain extends BlockBase {
}
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
}
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && world.getBlockState(pos.up()).getMaterial().blocksLight()) {
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
}
}
}