Mushroom fixes
This commit is contained in:
parent
18b2c691a2
commit
718b3a6fc4
2 changed files with 8 additions and 5 deletions
|
@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Fertilizable;
|
import net.minecraft.block.Fertilizable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
|
@ -33,6 +34,7 @@ import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.registry.EndFeatures;
|
import ru.betterend.registry.EndFeatures;
|
||||||
import ru.betterend.registry.EndTags;
|
import ru.betterend.registry.EndTags;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypeable, Fertilizable {
|
public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypeable, Fertilizable {
|
||||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||||
|
@ -95,6 +97,7 @@ public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypea
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||||
|
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
||||||
EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null);
|
EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class JellyshroomFeature extends DefaultFeature {
|
||||||
BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.getDefaultState();
|
BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.getDefaultState();
|
||||||
|
|
||||||
int height = MHelper.randRange(5, 8, random);
|
int height = MHelper.randRange(5, 8, random);
|
||||||
float radius = height * MHelper.randRange(0.1F, 0.2F, random);
|
float radius = height * MHelper.randRange(0.15F, 0.25F, random);
|
||||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, 5);
|
List<Vector3f> spline = SplineHelper.makeSpline(0, -1, 0, 0, height, 0, 3);
|
||||||
SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F);
|
SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F);
|
||||||
SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> {
|
SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> {
|
||||||
return bark;
|
return bark;
|
||||||
|
@ -54,13 +54,13 @@ public class JellyshroomFeature extends DefaultFeature {
|
||||||
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
|
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
|
||||||
sdf.setReplaceFunction(REPLACE).setPostProcess(POST).fillRecursive(world, pos);
|
sdf.setReplaceFunction(REPLACE).setPostProcess(POST).fillRecursive(world, pos);
|
||||||
radius = height * 0.5F;
|
radius = height * 0.5F;
|
||||||
makeRoots(world, pos.add(0, 1, 0), radius, random, bark);
|
makeRoots(world, pos.add(0, 2, 0), radius, random, bark);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) {
|
private void makeRoots(StructureWorldAccess world, BlockPos pos, float radius, Random random, BlockState wood) {
|
||||||
int count = (int) (radius * 1.5F);
|
int count = (int) (radius * 3.5F);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
float angle = (float) i / (float) count * MHelper.PI2;
|
float angle = (float) i / (float) count * MHelper.PI2;
|
||||||
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
|
||||||
|
@ -109,7 +109,7 @@ public class JellyshroomFeature extends DefaultFeature {
|
||||||
};
|
};
|
||||||
|
|
||||||
REPLACE = (state) -> {
|
REPLACE = (state) -> {
|
||||||
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.isOf(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
|
if (state.isIn(EndTags.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return state.getMaterial().isReplaceable();
|
return state.getMaterial().isReplaceable();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue