Dense vines

This commit is contained in:
paulevsGitch 2020-10-06 01:06:59 +03:00
parent 3927e177d7
commit 1ceb433a61
22 changed files with 470 additions and 4 deletions

View file

@ -44,8 +44,7 @@ public class BlockSign extends AbstractSignBlock {
public BlockSign(Block source) { public BlockSign(Block source) {
super(FabricBlockSettings.copyOf(source).noCollision().nonOpaque(), SignType.OAK); super(FabricBlockSettings.copyOf(source).noCollision().nonOpaque(), SignType.OAK);
this.setDefaultState( this.setDefaultState(this.stateManager.getDefaultState().with(ROTATION, 0).with(FLOOR, true).with(WATERLOGGED, false));
this.stateManager.getDefaultState().with(ROTATION, 0).with(FLOOR, true).with(WATERLOGGED, false));
} }
@Override @Override

View file

@ -0,0 +1,140 @@
package ru.betterend.blocks.basis;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
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.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.util.BlocksHelper;
public class BlockVine extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VOXEL_SHAPE = Block.createCuboidShape(2, 0, 2, 14, 16, 14);
public BlockVine() {
this(0, false);
}
public BlockVine(int light) {
this(light, false);
}
public BlockVine(int light, boolean bottomOnly) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.lightLevel((state) -> {
return bottomOnly ? state.get(SHAPE) == TripleShape.BOTTOM ? light : 0 : light;
})
.breakByHand(true)
.noCollision());
this.setDefaultState(this.stateManager.getDefaultState().with(SHAPE, TripleShape.BOTTOM));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
Vec3d vec3d = state.getModelOffset(view, pos);
return VOXEL_SHAPE.offset(vec3d.x, vec3d.y, vec3d.z);
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.XZ;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return isSupport(state, world, pos);
}
protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.up()).getBlock() == this || sideCoversSmallSquare(world, pos.up(), Direction.UP);
}
@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();
}
else {
if (world.getBlockState(pos.up()).getBlock() != this)
return state.with(SHAPE, TripleShape.TOP);
else if (world.getBlockState(pos.down()).getBlock() != this)
return state.with(SHAPE, TripleShape.BOTTOM);
return state.with(SHAPE, TripleShape.MIDDLE);
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
return true;
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
while (world.getBlockState(pos).getBlock() == this) {
pos = pos.down();
}
return world.isAir(pos);
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
while (world.getBlockState(pos).getBlock() == this) {
pos = pos.down();
}
world.setBlockState(pos, getDefaultState());
BlocksHelper.setWithoutUpdate(world, pos, getDefaultState());
}
}

View file

@ -24,6 +24,7 @@ import ru.betterend.blocks.EndStoneSmelter;
import ru.betterend.blocks.EnderBlock; import ru.betterend.blocks.EnderBlock;
import ru.betterend.blocks.TerminiteBlock; import ru.betterend.blocks.TerminiteBlock;
import ru.betterend.blocks.basis.BlockGlowingFur; import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.blocks.basis.BlockVine;
import ru.betterend.blocks.complex.WoodenMaterial; import ru.betterend.blocks.complex.WoodenMaterial;
import ru.betterend.tab.CreativeTab; import ru.betterend.tab.CreativeTab;
@ -54,6 +55,9 @@ public class BlockRegistry {
public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlockBlueVineLantern()); public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlockBlueVineLantern());
public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(BLUE_VINE_SEED, 3)); public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(BLUE_VINE_SEED, 3));
// Vines //
public static final Block DENSE_VINE = registerBlock("dense_vine", new BlockVine(15, true));
// Ores // // Ores //
public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3)); public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3));

View file

@ -6,6 +6,7 @@ import ru.betterend.world.features.EndFeature;
import ru.betterend.world.features.EndLakeFeature; import ru.betterend.world.features.EndLakeFeature;
import ru.betterend.world.features.MossyGlowshroomFeature; import ru.betterend.world.features.MossyGlowshroomFeature;
import ru.betterend.world.features.SinglePlantFeature; import ru.betterend.world.features.SinglePlantFeature;
import ru.betterend.world.features.VineFeature;
public class FeatureRegistry { public class FeatureRegistry {
// Trees // // Trees //
@ -16,6 +17,8 @@ public class FeatureRegistry {
public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(BlockRegistry.CREEPING_MOSS, 5), 5); public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(BlockRegistry.CREEPING_MOSS, 5), 5);
public static final EndFeature BLUE_VINE = new EndFeature("blue_vine", new BlueVineFeature(), 1); public static final EndFeature BLUE_VINE = new EndFeature("blue_vine", new BlueVineFeature(), 1);
public static final EndFeature DENSE_VINE = new EndFeature("dense_vine", new VineFeature(BlockRegistry.DENSE_VINE, 24), 3);
// Features // // Features //
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4); public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);

View file

@ -24,6 +24,7 @@ public class BiomeFoggyMushroomland extends EndBiome {
.addFeature(FeatureRegistry.BLUE_VINE) .addFeature(FeatureRegistry.BLUE_VINE)
.addFeature(FeatureRegistry.UMBRELLA_MOSS) .addFeature(FeatureRegistry.UMBRELLA_MOSS)
.addFeature(FeatureRegistry.CREEPING_MOSS) .addFeature(FeatureRegistry.CREEPING_MOSS)
.addFeature(FeatureRegistry.DENSE_VINE)
.addMobSpawn(EntityRegistry.DRAGONFLY, 80, 2, 5) .addMobSpawn(EntityRegistry.DRAGONFLY, 80, 2, 5)
.addMobSpawn(EntityRegistry.END_SLIME, 10, 1, 2) .addMobSpawn(EntityRegistry.END_SLIME, 10, 1, 2)
.addMobSpawn(EntityType.ENDERMAN, 10, 1, 2)); .addMobSpawn(EntityType.ENDERMAN, 10, 1, 2));

View file

@ -0,0 +1,51 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public abstract class InvertedScatterFeature extends DefaultFeature {
private static final Mutable POS = new Mutable();
private final int radius;
public InvertedScatterFeature(int radius) {
this.radius = radius;
}
public abstract boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius);
public abstract void generate(StructureWorldAccess world, Random random, BlockPos blockPos);
@Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
for (int y = 128; y > 0; y--) {
POS.set(center.getX(), y, center.getZ());
if (world.getBlockState(POS).isAir() && !world.getBlockState(POS.up()).isAir()) {
float r = MHelper.randRange(radius * 0.5F, radius, random);
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
for (int i = 0; i < count; i++) {
float pr = r * (float) Math.sqrt(random.nextFloat());
float theta = random.nextFloat() * MHelper.PI2;
float x = pr * (float) Math.cos(theta);
float z = pr * (float) Math.sin(theta);
POS.set(center.getX() + x, center.getY() - 5, center.getZ() + z);
int up = BlocksHelper.upRay(world, POS, 16);
if (up > 10) continue;
POS.setY(POS.getY() + up);
if (canGenerate(world, random, center, POS, r)) {
generate(world, random, POS);
}
}
}
}
return true;
}
}

View file

@ -0,0 +1,36 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.util.BlocksHelper;
public class VineFeature extends InvertedScatterFeature {
private final Block vineBlock;
private final int maxLength;
public VineFeature(Block vineBlock, int maxLength) {
super(6);
this.vineBlock = vineBlock;
this.maxLength = maxLength;
}
@Override
public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return vineBlock.canPlaceAt(AIR, world, blockPos);
}
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
int h = BlocksHelper.downRay(world, blockPos, random.nextInt(maxLength));
BlocksHelper.setWithoutUpdate(world, blockPos, vineBlock.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
for (int i = 1; i < h; i++) {
BlocksHelper.setWithoutUpdate(world, blockPos.down(i), vineBlock.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithoutUpdate(world, blockPos.down(h), vineBlock.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
}
}

View file

@ -0,0 +1,13 @@
{
"variants": {
"shape=top": { "model": "betterend:block/dense_vine_top" },
"shape=middle": [
{ "model": "betterend:block/dense_vine_middle_1" },
{ "model": "betterend:block/dense_vine_middle_2" }
],
"shape=bottom": [
{ "model": "betterend:block/dense_vine_bottom_1" },
{ "model": "betterend:block/dense_vine_bottom_2" }
]
}
}

View file

@ -80,5 +80,7 @@
"block.betterend.blue_vine_seed": "Blue Vine Seed", "block.betterend.blue_vine_seed": "Blue Vine Seed",
"block.betterend.blue_vine": "Blue Vine", "block.betterend.blue_vine": "Blue Vine",
"block.betterend.blue_vine_lantern": "Blue Vine Lantern", "block.betterend.blue_vine_lantern": "Blue Vine Lantern",
"block.betterend.blue_vine_fur": "Blue Vine Fur" "block.betterend.blue_vine_fur": "Blue Vine Fur",
"block.betterend.dense_vine": "Dense Vine"
} }

View file

@ -80,5 +80,7 @@
"block.betterend.blue_vine_seed": "Семя синей лозы", "block.betterend.blue_vine_seed": "Семя синей лозы",
"block.betterend.blue_vine": "Синяя лоза", "block.betterend.blue_vine": "Синяя лоза",
"block.betterend.blue_vine_lantern": "Фонарь синей лозы", "block.betterend.blue_vine_lantern": "Фонарь синей лозы",
"block.betterend.blue_vine_fur": "Пух синей лозы" "block.betterend.blue_vine_fur": "Пух синей лозы",
"block.betterend.dense_vine": "Плотная лоза"
} }

View file

@ -0,0 +1,40 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#texture"
},
"elements": [
{ "from": [ 4.1, 0, 0 ],
"to": [ 4.1, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{ "from": [ 11.9, 0, 0 ],
"to": [ 11.9, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{ "from": [ 0, 0, 4.1 ],
"to": [ 16, 16, 4.1 ],
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
},
{ "from": [ 0, 0, 11.9 ],
"to": [ 16, 16, 11.9 ],
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }
}
}
]
}

View file

@ -0,0 +1,40 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#texture"
},
"elements": [
{ "from": [ 4, 0, 0 ],
"to": [ 4, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" },
"east": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" }
}
},
{ "from": [ 12, 0, 0 ],
"to": [ 12, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" },
"east": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" }
}
},
{ "from": [ 0, 0, 4 ],
"to": [ 16, 16, 4 ],
"shade": false,
"faces": {
"north": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" },
"south": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" }
}
},
{ "from": [ 0, 0, 12 ],
"to": [ 16, 16, 12 ],
"shade": false,
"faces": {
"north": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" },
"south": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" }
}
}
]
}

View file

@ -0,0 +1,29 @@
{
"textures": {
"particle": "#texture"
},
"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": [ 16, 0, 0, 16 ], "texture": "#texture" },
"east": { "uv": [ 16, 0, 0, 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": [ 16, 0, 0, 16 ], "texture": "#texture" },
"east": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" }
}
}
]
}

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,76 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/dense_vine",
"texture": "betterend:block/dense_vine",
"roots": "betterend:block/dense_vine_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, 16, 16, 0 ], "texture": "#roots" },
"east": { "uv": [ 0, 16, 16, 0 ], "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, 16, 16, 0 ], "texture": "#roots" },
"south": { "uv": [ 0, 16, 16, 0 ], "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, 16, 16, 0 ], "texture": "#roots" },
"east": { "uv": [ 0, 16, 16, 0 ], "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, 16, 16, 0 ], "texture": "#roots" },
"south": { "uv": [ 0, 16, 16, 0 ], "texture": "#roots" }
}
}
]
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:block/dense_vine_bottom"
}
}

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