This commit is contained in:
paulevsGitch 2020-10-03 23:28:04 +03:00
parent a968b9bb23
commit 8beabd0f96
18 changed files with 176 additions and 63 deletions

View file

@ -0,0 +1,33 @@
package ru.betterend.blocks.basis;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
public abstract class BlockPlantWithAge extends BlockPlant {
public static final IntProperty AGE = IntProperty.of("age", 0, 4);
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
}
public abstract void grow(StructureWorldAccess world, Random random, BlockPos pos);
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
int age = state.get(AGE);
if (age < 3) {
world.setBlockState(pos, state.with(AGE, age + 1));
}
else {
grow(world, random, pos);
}
}
}