This commit is contained in:
paulevsGitch 2020-12-26 19:18:21 +03:00
parent 1065d770bb
commit 6ef6090123
3 changed files with 28 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -10,6 +11,7 @@ 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.Fertilizable;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
@ -17,18 +19,22 @@ 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.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockAttached;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndTags;
public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypeable {
public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypeable, Fertilizable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public BlockSmallJellyshroom() {
@ -57,7 +63,7 @@ public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypea
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
Direction direction = state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
BlockState support = world.getBlockState(blockPos);
return sideCoversSmallSquare(world, blockPos, direction) && support.isOpaque() && support.getLuminance() == 0;
@ -76,4 +82,19 @@ public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypea
BOUNDING_SHAPES.put(Direction.WEST, VoxelShapes.cuboid(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.EAST, VoxelShapes.cuboid(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
return state.get(FACING) == Direction.UP && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0;
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null);
}
}

View file

@ -60,7 +60,7 @@ public class EndFeatures {
public static final EndFeature TENANEA = new EndFeature("tenanea", new TenaneaFeature(), 3);
public static final EndFeature HELIX_TREE = new EndFeature("helix_tree", new HelixTreeFeature(), 2);
public static final EndFeature UMBRELLA_TREE = new EndFeature("umbrella_tree", new UmbrellaTreeFeature(), 4);
public static final EndFeature JELLYSHROOM = new EndFeature("jellyshroom", new JellyshroomFeature(), 2);
public static final EndFeature JELLYSHROOM = new EndFeature("jellyshroom", new JellyshroomFeature(), 3);
// Bushes //
public static final EndFeature PYTHADENDRON_BUSH = new EndFeature("pythadendron_bush", new BushFeature(EndBlocks.PYTHADENDRON_LEAVES, EndBlocks.PYTHADENDRON.bark), 4);

View file

@ -47,14 +47,14 @@ public class JellyshroomFeature extends DefaultFeature {
return bark;
});
radius = height * MHelper.randRange(0.8F, 1.2F, random);
radius = height * MHelper.randRange(0.7F, 0.9F, random);
SDF cap = makeCap(radius, random, membrane);
Vector3f last = spline.get(spline.size() - 1);
cap = new SDFTranslate().setTranslate(last.getX(), last.getY(), last.getZ()).setSource(cap);
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
sdf.setReplaceFunction(REPLACE).setPostProcess(POST).fillRecursive(world, pos);
radius = height * 0.3F;
makeRoots(world, pos, radius, random, bark);
radius = height * 0.5F;
makeRoots(world, pos.add(0, 1, 0), radius, random, bark);
return true;
}
@ -70,7 +70,7 @@ public class JellyshroomFeature extends DefaultFeature {
SplineHelper.scale(branch, scale);
Vector3f last = branch.get(branch.size() - 1);
if (world.getBlockState(pos.add(last.getX(), last.getY(), last.getZ())).isIn(EndTags.GEN_TERRAIN)) {
SplineHelper.fillSplineForce(branch, world, wood, pos, REPLACE);
SplineHelper.fillSpline(branch, world, wood, pos, REPLACE);
}
}
}