This commit is contained in:
paulevsGitch 2020-10-09 18:59:06 +03:00
parent 7584321c47
commit 819de9ae0a
22 changed files with 419 additions and 3 deletions

View file

@ -0,0 +1,56 @@
package ru.betterend.blocks;
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.block.ShapeContext;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
public class BlockEndLily extends BlockUnderwaterPlant {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(2, 0, 2, 14, 6, 14);
public BlockEndLily() {
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.breakByHand(true)
.lightLevel((state) -> { return state.get(SHAPE) == TripleShape.TOP ? 13 : 0; })
.noCollision());
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
Vec3d vec3d = state.getModelOffset(view, pos);
VoxelShape shape = state.get(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
return shape.offset(vec3d.x, vec3d.y, vec3d.z);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.get(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.getDefaultState() : Fluids.WATER.getStill(false);
}
@Override
protected boolean isTerrain(BlockState state) {
return super.isTerrain(state) || state.getBlock() == this;
}
}

View file

@ -0,0 +1,34 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.fluid.Fluids;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUnderwaterPlantWithAge;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.util.BlocksHelper;
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);
BlockPos up = pos.up();
while (world.getFluidState(up).isStill()) {
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.MIDDLE));
up = up.up();
}
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
}
}
private boolean canGrow(StructureWorldAccess world, BlockPos pos) {
BlockPos up = pos.up();
while (world.getBlockState(up).getFluidState().getFluid().equals(Fluids.WATER.getStill())) {
up = up.up();
}
return world.isAir(up);
}
}

View file

@ -77,7 +77,8 @@ public class BlockUnderwaterPlant extends BlockBaseNotFull implements IRenderTyp
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState down = world.getBlockState(pos.down());
return isTerrain(down);
state = world.getBlockState(pos);
return isTerrain(down) && state.getFluidState().getFluid().equals(Fluids.WATER.getStill());
}
protected boolean isTerrain(BlockState state) {
@ -87,7 +88,7 @@ public class BlockUnderwaterPlant extends BlockBaseNotFull implements IRenderTyp
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
return Blocks.WATER.getDefaultState();
}
else {
return state;

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 BlockUnderwaterPlantWithAge extends BlockUnderwaterPlant {
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
@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);
}
}
}

View file

@ -12,6 +12,8 @@ import ru.betterend.blocks.BlockBlueVine;
import ru.betterend.blocks.BlockBlueVineLantern;
import ru.betterend.blocks.BlockBlueVineSeed;
import ru.betterend.blocks.BlockBubbleCoral;
import ru.betterend.blocks.BlockEndLily;
import ru.betterend.blocks.BlockEndLilySeed;
import ru.betterend.blocks.BlockEndstoneDust;
import ru.betterend.blocks.BlockGlowingMoss;
import ru.betterend.blocks.BlockMossyGlowshroomCap;
@ -62,6 +64,8 @@ public class BlockRegistry {
public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(BLUE_VINE_SEED, 3));
public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BlockBubbleCoral());
public static final Block END_LILY = registerBlockNI("end_lily", new BlockEndLily());
public static final Block END_LILY_SEED = registerBlock("end_lily_seed", new BlockEndLilySeed());
// Vines //
public static final Block DENSE_VINE = registerBlock("dense_vine", new BlockVine(15, true));

View file

@ -1,5 +1,7 @@
{
"variants": {
"": { "model": "betterend:block/aurora_crystal" }
"": [
{ "model": "betterend:block/aurora_crystal" }
]
}
}

View file

@ -0,0 +1,11 @@
{
"variants": {
"shape=top": [
{ "model": "betterend:block/end_lily_top" },
{ "model": "betterend:block/end_lily_top_small" },
{ "model": "betterend:block/end_lily_top_small_2" }
],
"shape=middle": { "model": "betterend:block/end_lily_stem" },
"shape=bottom": { "model": "betterend:block/end_lily_roots" }
}
}

View file

@ -0,0 +1,14 @@
{
"defaultMap": {
"spriteMap": [
{
"sprite": "betterend:block/end_lily_flower",
"material": "betterend:glow_inc"
},
{
"sprite": "betterend:block/end_lily_flower_small",
"material": "betterend:glow_inc"
}
]
}
}

View file

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

View file

@ -0,0 +1,76 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/end_lily_stem",
"texture": "betterend:block/end_lily_stem",
"roots": "betterend:block/end_lily_roots"
},
"elements": [
{
"__comment": "PlaneX1",
"from": [ 2.375, 0, 2.25 ],
"to": [ 2.376, 16, 18.25 ],
"rotation": { "origin": [ 2.375, 0, 2.25 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneX1",
"from": [ 13.75, 0, 2.25 ],
"to": [ 13.751, 16, 18.25 ],
"rotation": { "origin": [ 13.75, 0, 2.25 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneX4",
"from": [ 5, 0, 0.5 ],
"to": [ 5.001, 16, 16.5 ],
"rotation": { "origin": [ 5, 0, 0.5 ], "axis": "y", "angle": 22.5 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" }
}
},
{
"__comment": "PlaneZ5",
"from": [ 0.5, 0, 11 ],
"to": [ 16.5, 16, 11.001 ],
"rotation": { "origin": [ 0.5, 0, 11 ], "axis": "y", "angle": 22.5 },
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" }
}
},
{
"__comment": "PlaneX4",
"from": [ 11, 0, 0.5 ],
"to": [ 11.001, 16, 16.5 ],
"rotation": { "origin": [ 11, 0, 0.5 ], "axis": "y", "angle": -22.5 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" }
}
},
{
"__comment": "PlaneZ5",
"from": [ 0.5, 0, 5 ],
"to": [ 16.5, 16, 5.001 ],
"rotation": { "origin": [ 0.5, 0, 5 ], "axis": "y", "angle": -22.5 },
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#roots" }
}
}
]
}

View file

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

View file

@ -0,0 +1,92 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/end_lily_leaf",
"leaf": "betterend:block/end_lily_leaf",
"flower": "betterend:block/end_lily_flower"
},
"elements": [
{
"__comment": "PlaneX2",
"from": [ 8, 0, 0 ],
"to": [ 8.001, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneZ3",
"from": [ 0, 0, 8 ],
"to": [ 16, 16, 8.001 ],
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneX2",
"from": [ 2.5, 0, 2.5 ],
"to": [ 2.501, 16, 18.5 ],
"rotation": { "origin": [ 2.5, 0, 2.5 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 2.5, 0, 16, 16 ], "texture": "#flower" },
"east": { "uv": [ 0, 0, 13.5, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneZ3",
"from": [ 2.5, 0, 13.5 ],
"to": [ 18.5, 16, 13.501 ],
"rotation": { "origin": [ 2.5, 0, 13.5 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 14.5, 16 ], "texture": "#flower" },
"south": { "uv": [ 1.5, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneY6",
"from": [ 8, 0.018, 8 ],
"to": [ 24, 0.018, 24 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf" }
}
},
{
"__comment": "PlaneY6",
"from": [ -8, 0.014, 8 ],
"to": [ 8, 0.014, 24 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 180 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 90 }
}
},
{
"__comment": "PlaneY6",
"from": [ -8, 0.012, -8 ],
"to": [ 8, 0.012, 8 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 90 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 180 }
}
},
{
"__comment": "PlaneY6",
"from": [ 8, 0.01, -8 ],
"to": [ 24, 0.01, 8 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 }
}
}
]
}

View file

@ -0,0 +1,62 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/end_lily_leaf",
"leaf": "betterend:block/end_lily_leaf_small",
"flower": "betterend:block/end_lily_flower_small"
},
"elements": [
{
"__comment": "PlaneX2",
"from": [ 8, 0, 0 ],
"to": [ 8.001, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneZ3",
"from": [ 0, 0, 8 ],
"to": [ 16, 16, 8.001 ],
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneX2",
"from": [ 2.5, 0, 2.5 ],
"to": [ 2.501, 16, 18.5 ],
"rotation": { "origin": [ 2.5, 0, 2.5 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 2.5, 0, 16, 16 ], "texture": "#flower" },
"east": { "uv": [ 0, 0, 13.5, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneZ3",
"from": [ 2.5, 0, 13.5 ],
"to": [ 18.5, 16, 13.501 ],
"rotation": { "origin": [ 2.5, 0, 13.5 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 14.5, 16 ], "texture": "#flower" },
"south": { "uv": [ 1.5, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "PlaneY6",
"from": [ 0, 0, 0 ],
"to": [ 16, 0.001, 16 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf" }
}
}
]
}

View file

@ -0,0 +1,19 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/end_lily_leaf",
"leaf": "betterend:block/end_lily_leaf_small"
},
"elements": [
{
"__comment": "PlaneY6",
"from": [ 0, 0, 0 ],
"to": [ 16, 0.001, 16 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf", "rotation": 270 },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#leaf" }
}
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 460 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB