This commit is contained in:
paulevsGitch 2020-10-11 14:05:28 +03:00
parent 3f9e524b54
commit 287c1fce62
15 changed files with 120 additions and 26 deletions

View file

@ -6,6 +6,7 @@ import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUpDownPlant;
import ru.betterend.registry.BlockRegistry;
public class BlockBlueVine extends BlockUpDownPlant {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@ -14,4 +15,9 @@ public class BlockBlueVine extends BlockUpDownPlant {
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
}
}

View file

@ -2,6 +2,7 @@ package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
@ -40,4 +41,9 @@ public class BlockBlueVineSeed extends BlockPlantWithAge {
BlocksHelper.setWithoutUpdate(world, pos.up(), BlockRegistry.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, Direction.UP));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
}
}

View file

@ -14,7 +14,7 @@ public class BlockEndLilySeed extends BlockUnderwaterPlantWithAge {
@Override
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
if (canGrow(world, pos)) {
world.setBlockState(pos, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM), 0);
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM));
BlockPos up = pos.up();
while (world.getFluidState(up).isStill()) {
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.MIDDLE));

View file

@ -46,7 +46,7 @@ public class BlockPlant extends BlockBaseNotFull implements IRenderTypeable, Fer
}
public BlockPlant(boolean replaceable) {
super(FabricBlockSettings.of(replaceable ? Material.PLANT : Material.REPLACEABLE_PLANT)
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
@ -54,13 +54,17 @@ public class BlockPlant extends BlockBaseNotFull implements IRenderTypeable, Fer
}
public BlockPlant(boolean replaceable, int light) {
super(FabricBlockSettings.of(replaceable ? Material.PLANT : Material.REPLACEABLE_PLANT)
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.lightLevel(light)
.breakByHand(true)
.noCollision());
}
public BlockPlant(Settings settings) {
super(settings);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {

View file

@ -2,9 +2,13 @@ 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.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
@ -13,6 +17,15 @@ import net.minecraft.world.StructureWorldAccess;
public abstract class BlockPlantWithAge extends BlockPlant {
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
public BlockPlantWithAge() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.ticksRandomly()
.noCollision());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
@ -22,12 +35,22 @@ public abstract class BlockPlantWithAge extends BlockPlant {
@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));
if (random.nextInt(4) == 0) {
int age = state.get(AGE);
if (age < 3) {
world.setBlockState(pos, state.with(AGE, age + 1));
}
else {
grow(world, random, pos);
}
}
else {
grow(world, random, pos);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state)) {
grow(world, random, pos, state);
}
}
}

View file

@ -2,9 +2,13 @@ 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.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
@ -13,6 +17,15 @@ import net.minecraft.world.StructureWorldAccess;
public abstract class BlockUnderwaterPlantWithAge extends BlockUnderwaterPlant {
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
public BlockUnderwaterPlantWithAge() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.breakByHand(true)
.ticksRandomly()
.noCollision());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
@ -22,12 +35,22 @@ public abstract class BlockUnderwaterPlantWithAge extends BlockUnderwaterPlant {
@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));
if (random.nextInt(4) == 0) {
int age = state.get(AGE);
if (age < 3) {
world.setBlockState(pos, state.with(AGE, age + 1));
}
else {
grow(world, random, pos);
}
}
else {
grow(world, random, pos);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state)) {
grow(world, random, pos, state);
}
}
}

View file

@ -215,7 +215,7 @@ public class EndLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.BUBBLE_CORAL.getDefaultState());
}
else if (NOISE.eval(x * 0.1, z * 0.1, 1) > 0) {
world.setBlockState(POS, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM), 0);
BlocksHelper.setWithoutUpdate(world, POS, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM));
BlockPos up = POS.up();
while (up.getY() < waterLevel) {
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.MIDDLE));

View file

@ -0,0 +1,8 @@
{
"variants": {
"age=0": { "model": "betterend:block/end_lily_seed_0" },
"age=1": { "model": "betterend:block/end_lily_seed_1" },
"age=2": { "model": "betterend:block/end_lily_seed_2" },
"age=3": { "model": "betterend:block/end_lily_seed_3" }
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/end_lily_0"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/end_lily_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/end_lily_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/end_lily_3"
}
}

View file

@ -50,8 +50,8 @@
},
{
"__comment": "PlaneY6",
"from": [ 8, 0.018, 8 ],
"to": [ 24, 0.018, 24 ],
"from": [ 8, 0.029, 8 ],
"to": [ 24, 0.029, 24 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 },
@ -60,8 +60,8 @@
},
{
"__comment": "PlaneY6",
"from": [ -8, 0.014, 8 ],
"to": [ 8, 0.014, 24 ],
"from": [ -8, 0.026, 8 ],
"to": [ 8, 0.026, 24 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 180 },
@ -70,8 +70,8 @@
},
{
"__comment": "PlaneY6",
"from": [ -8, 0.012, -8 ],
"to": [ 8, 0.012, 8 ],
"from": [ -8, 0.023, -8 ],
"to": [ 8, 0.023, 8 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 90 },
@ -80,8 +80,8 @@
},
{
"__comment": "PlaneY6",
"from": [ 8, 0.01, -8 ],
"to": [ 24, 0.01, 8 ],
"from": [ 8, 0.02, -8 ],
"to": [ 24, 0.02, 8 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf" },

View file

@ -50,8 +50,8 @@
},
{
"__comment": "PlaneY6",
"from": [ 0, 0, 0 ],
"to": [ 16, 0.001, 16 ],
"from": [ 0, 0.02, 0 ],
"to": [ 16, 0.02, 16 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 },

View file

@ -7,8 +7,8 @@
"elements": [
{
"__comment": "PlaneY6",
"from": [ 0, 0, 0 ],
"to": [ 16, 0.001, 16 ],
"from": [ 0, 0.02, 0 ],
"to": [ 16, 0.02, 16 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 },