Migrating to BCLib (WIP)
This commit is contained in:
parent
61d4a33cf6
commit
3668a4694a
184 changed files with 802 additions and 4348 deletions
|
@ -1,65 +1,19 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.blocks.BasePlantWithAgeBlock;
|
||||
|
||||
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock {
|
||||
|
||||
public EndPlantWithAgeBlock() {}
|
||||
|
||||
public abstract class EndPlantWithAgeBlock extends EndPlantBlock {
|
||||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public EndPlantWithAgeBlock() {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
}
|
||||
|
||||
public EndPlantWithAgeBlock(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(AGE);
|
||||
}
|
||||
|
||||
public abstract void growAdult(WorldGenLevel world, Random random, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||
int age = state.getValue(AGE);
|
||||
if (age < 3) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
|
||||
}
|
||||
else {
|
||||
growAdult(world, random, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
super.tick(state, world, pos, random);
|
||||
if (random.nextInt(8) == 0) {
|
||||
performBonemeal(world, random, pos, state);
|
||||
}
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
return state.is(TagAPI.END_GROUND);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue