diff --git a/src/main/java/ru/betterend/blocks/BlockMossyGlowshroomCap.java b/src/main/java/ru/betterend/blocks/BlockMossyGlowshroomCap.java new file mode 100644 index 00000000..51273696 --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockMossyGlowshroomCap.java @@ -0,0 +1,29 @@ +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.item.ItemPlacementContext; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import ru.betterend.registry.BlockRegistry; + +public class BlockMossyGlowshroomCap extends Block { + public static final BooleanProperty TRANSITION = BooleanProperty.of("transition"); + + public BlockMossyGlowshroomCap() { + super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD)); + this.setDefaultState(this.stateManager.getDefaultState().with(TRANSITION, false)); + } + + public BlockState getPlacementState(ItemPlacementContext ctx) { + return this.getDefaultState().with(TRANSITION, BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(ctx.getWorld().getBlockState(ctx.getBlockPos().down()))); + } + + protected void appendProperties(StateManager.Builder builder) { + builder.add(TRANSITION); + } +} diff --git a/src/main/java/ru/betterend/blocks/BlockMossyGlowshroomFur.java b/src/main/java/ru/betterend/blocks/BlockMossyGlowshroomFur.java new file mode 100644 index 00000000..e64493fa --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockMossyGlowshroomFur.java @@ -0,0 +1,117 @@ +package ru.betterend.blocks; + +import java.util.EnumMap; +import java.util.List; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +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.Blocks; +import net.minecraft.block.Material; +import net.minecraft.block.ShapeContext; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.item.ItemPlacementContext; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import net.minecraft.loot.context.LootContextParameters; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +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.WorldAccess; +import net.minecraft.world.WorldView; +import ru.betterend.blocks.basis.BlockBaseNotFull; +import ru.betterend.client.ERenderLayer; +import ru.betterend.client.IRenderTypeable; + +public class BlockMossyGlowshroomFur extends BlockBaseNotFull implements IRenderTypeable { + private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); + public static final DirectionProperty FACING = Properties.FACING; + + public BlockMossyGlowshroomFur() { + super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) + .breakByTool(FabricToolTags.SHEARS) + .sounds(BlockSoundGroup.WET_GRASS) + .lightLevel(15) + .breakByHand(true) + .noCollision()); + } + + @Override + protected void appendProperties(StateManager.Builder stateManager) { + stateManager.add(FACING); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { + return BOUNDING_SHAPES.get(state.get(FACING)); + } + + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + BlockState blockState = this.getDefaultState(); + WorldView worldView = ctx.getWorld(); + BlockPos blockPos = ctx.getBlockPos(); + Direction[] directions = ctx.getPlacementDirections(); + for (int i = 0; i < directions.length; ++i) { + Direction direction = directions[i]; + Direction direction2 = direction.getOpposite(); + blockState = (BlockState) blockState.with(FACING, direction2); + if (blockState.canPlaceAt(worldView, blockPos)) { + return blockState; + } + } + return null; + } + + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + Direction direction = (Direction) state.get(FACING); + BlockPos blockPos = pos.offset(direction.getOpposite()); + return sideCoversSmallSquare(world, blockPos, direction); + } + + @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 { + return state; + } + } + + @Override + public List 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; + } + + static { + BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)); + BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0)); + BOUNDING_SHAPES.put(Direction.NORTH, VoxelShapes.cuboid(0.0, 0.0, 0.5, 1.0, 1.0, 1.0)); + BOUNDING_SHAPES.put(Direction.SOUTH, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 1.0, 0.5)); + 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)); + } +} diff --git a/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java b/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java index 56ccc5b5..b71377da 100644 --- a/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java +++ b/src/main/java/ru/betterend/client/gui/EndStoneSmelterRecipeBookScreen.java @@ -5,13 +5,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import com.mojang.blaze3d.systems.RenderSystem; - -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.recipebook.AbstractFurnaceRecipeBookScreen; import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; diff --git a/src/main/java/ru/betterend/registry/BlockRegistry.java b/src/main/java/ru/betterend/registry/BlockRegistry.java index 8c68a9db..6ff2a2d3 100644 --- a/src/main/java/ru/betterend/registry/BlockRegistry.java +++ b/src/main/java/ru/betterend/registry/BlockRegistry.java @@ -8,6 +8,8 @@ import net.minecraft.util.registry.Registry; import ru.betterend.BetterEnd; import ru.betterend.blocks.AeterniumBlock; import ru.betterend.blocks.BlockEndstoneDust; +import ru.betterend.blocks.BlockMossyGlowshroomCap; +import ru.betterend.blocks.BlockMossyGlowshroomFur; import ru.betterend.blocks.BlockMossyGlowshroomHymenophore; import ru.betterend.blocks.BlockOre; import ru.betterend.blocks.BlockTerrain; @@ -24,7 +26,9 @@ public class BlockRegistry { public static final Block END_MOSS = registerBlock("end_moss", new BlockTerrain(MaterialColor.CYAN)); // Wooden Materials // + public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new BlockMossyGlowshroomCap()); public static final Block MOSSY_GLOWSHROOM_HYMENOPHORE = registerBlock("mossy_glowshroom_hymenophore", new BlockMossyGlowshroomHymenophore()); + public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockMossyGlowshroomFur()); public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD); // Ores // diff --git a/src/main/java/ru/betterend/util/sdf/SDF.java b/src/main/java/ru/betterend/util/sdf/SDF.java index 899c2782..d3dc2bb8 100644 --- a/src/main/java/ru/betterend/util/sdf/SDF.java +++ b/src/main/java/ru/betterend/util/sdf/SDF.java @@ -17,6 +17,9 @@ public abstract class SDF { private Function postProcess = (info) -> { return info.getState(); }; + private Function canReplace = (state) -> { + return state.getMaterial().isReplaceable(); + }; public abstract float getDistance(float x, float y, float z); @@ -27,13 +30,17 @@ public abstract class SDF { return this; } - public void fillRecursive(ServerWorldAccess world, BlockPos start, Function canReplace, int dx, int dy, int dz) { + public SDF setReplaceFunction(Function canReplace) { + this.canReplace = canReplace; + return this; + } + + public Set fillRecursive(ServerWorldAccess world, BlockPos start, int dx, int dy, int dz) { Map mapWorld = Maps.newHashMap(); Set blocks = Sets.newHashSet(); Set ends = Sets.newHashSet(); Set add = Sets.newHashSet(); ends.add(new BlockPos(0, 0, 0)); - boolean process = postProcess != null; boolean run = true; while (run) { @@ -70,9 +77,11 @@ public abstract class SDF { BlockState state = postProcess.apply(info); BlocksHelper.setWithoutUpdate(world, pos, state); }); + + return mapWorld.keySet(); } - public void fillRecursive(ServerWorldAccess world, BlockPos start, Function canReplace) { + public Set fillRecursive(ServerWorldAccess world, BlockPos start) { Map mapWorld = Maps.newHashMap(); Set blocks = Sets.newHashSet(); Set ends = Sets.newHashSet(); @@ -87,7 +96,7 @@ public abstract class SDF { BlockPos wpos = pos.add(start); if (!blocks.contains(pos) && canReplace.apply(world.getBlockState(wpos))) { - if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) <= 0) { + if (this.getDistance(pos.getX(), pos.getY(), pos.getZ()) < 0) { BlockState state = getBlockState(wpos); PosInfo.create(mapWorld, wpos).setState(state); add.add(pos); @@ -108,5 +117,7 @@ public abstract class SDF { BlockState state = postProcess.apply(info); BlocksHelper.setWithoutUpdate(world, pos, state); }); + + return mapWorld.keySet(); } } diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFCoordModify.java b/src/main/java/ru/betterend/util/sdf/operator/SDFCoordModify.java new file mode 100644 index 00000000..ea04ace9 --- /dev/null +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFCoordModify.java @@ -0,0 +1,22 @@ +package ru.betterend.util.sdf.operator; + +import java.util.function.Consumer; + +import net.minecraft.client.util.math.Vector3f; + +public class SDFCoordModify extends SDFUnary { + private static final Vector3f POS = new Vector3f(); + private Consumer function; + + public SDFCoordModify setFunction(Consumer function) { + this.function = function; + return this; + } + + @Override + public float getDistance(float x, float y, float z) { + POS.set(x, y, z); + function.accept(POS); + return this.source.getDistance(POS.getX(), POS.getY(), POS.getZ()); + } +} diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFCopyRotate.java b/src/main/java/ru/betterend/util/sdf/operator/SDFCopyRotate.java new file mode 100644 index 00000000..2c66bb2b --- /dev/null +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFCopyRotate.java @@ -0,0 +1,19 @@ +package ru.betterend.util.sdf.operator; + +import ru.betterend.util.MHelper; + +public class SDFCopyRotate extends SDFUnary { + int count = 1; + + public SDFCopyRotate setCount(int count) { + this.count = count; + return this; + } + + @Override + public float getDistance(float x, float y, float z) { + float px = (float) Math.atan2(x, z); + float pz = MHelper.length(x, z); + return this.source.getDistance(px, y, pz); + } +} diff --git a/src/main/java/ru/betterend/util/sdf/operator/SDFFlatWave.java b/src/main/java/ru/betterend/util/sdf/operator/SDFFlatWave.java index 83d5c540..a94f2c3c 100644 --- a/src/main/java/ru/betterend/util/sdf/operator/SDFFlatWave.java +++ b/src/main/java/ru/betterend/util/sdf/operator/SDFFlatWave.java @@ -3,10 +3,11 @@ package ru.betterend.util.sdf.operator; public class SDFFlatWave extends SDFDisplacement { private int rayCount = 1; private float intensity; + private float angle; public SDFFlatWave() { setFunction((pos) -> { - return (float) Math.cos(Math.atan2(pos.getX(), pos.getZ()) * rayCount) * intensity; + return (float) Math.cos(Math.atan2(pos.getX(), pos.getZ()) * rayCount + angle) * intensity; }); } @@ -15,6 +16,11 @@ public class SDFFlatWave extends SDFDisplacement { return this; } + public SDFFlatWave setAngle(float angle) { + this.angle = angle; + return this; + } + public SDFFlatWave setIntensity(float intensity) { this.intensity = intensity; return this; diff --git a/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java b/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java index af8cda1a..0ccfb29c 100644 --- a/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java +++ b/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java @@ -2,15 +2,19 @@ package ru.betterend.world.features; import java.util.List; import java.util.Random; -import java.util.function.Function; +import java.util.Set; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.util.math.Vector3f; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import ru.betterend.blocks.BlockMossyGlowshroomCap; +import ru.betterend.blocks.BlockMossyGlowshroomFur; +import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockTagRegistry; import ru.betterend.util.BlocksHelper; @@ -18,16 +22,21 @@ import ru.betterend.util.MHelper; import ru.betterend.util.SplineHelper; import ru.betterend.util.sdf.SDF; import ru.betterend.util.sdf.operator.SDFBinary; +import ru.betterend.util.sdf.operator.SDFCoordModify; +import ru.betterend.util.sdf.operator.SDFFlatWave; +import ru.betterend.util.sdf.operator.SDFScale3D; import ru.betterend.util.sdf.operator.SDFSmoothUnion; +import ru.betterend.util.sdf.operator.SDFSubtraction; import ru.betterend.util.sdf.operator.SDFTranslate; import ru.betterend.util.sdf.operator.SDFUnion; import ru.betterend.util.sdf.primitive.SDFCapedCone; import ru.betterend.util.sdf.primitive.SDFSphere; public class MossyGlowshroomFeature extends DefaultFeature { - private static final Function REPLACE; + private static final Vector3f CENTER = new Vector3f(); private static final SDFBinary FUNCTION; private static final SDFTranslate HEAD_POS; + private static final SDFFlatWave ROOTS; @Override public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { @@ -38,7 +47,6 @@ public class MossyGlowshroomFeature extends DefaultFeature { if (!world.getBlockState(blockPos.down()).isIn(BlockTagRegistry.END_GROUND)) { return false; } - //FUNCTION.fillRecursive(world, getTopPos(world, blockPos), REPLACE, 20, 50, 20); float height = MHelper.randRange(10F, 25F, random); int count = MHelper.floor(height / 4); @@ -48,51 +56,93 @@ public class MossyGlowshroomFeature extends DefaultFeature { return BlockRegistry.MOSSY_GLOWSHROOM.log.getDefaultState(); }); Vector3f pos = spline.get(spline.size() - 1); - BlockPos up = blockPos.add(pos.getX(), pos.getY(), pos.getZ()); + CENTER.set(blockPos.getX(), 0, blockPos.getZ()); HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ()); + ROOTS.setAngle(random.nextFloat() * MHelper.PI2); FUNCTION.setSourceA(sdf); - FUNCTION.fillRecursive(world, blockPos, REPLACE); - BlocksHelper.setWithoutUpdate(world, up, Blocks.DIAMOND_BLOCK.getDefaultState()); + Set blocks = FUNCTION.fillRecursive(world, blockPos); + + for (BlockPos bpos: blocks) { + BlockState state = world.getBlockState(bpos); + if (state.getBlock() == BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE) { + if (world.isAir(bpos.north())) { + BlocksHelper.setWithoutUpdate(world, bpos.north(), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockMossyGlowshroomFur.FACING, Direction.NORTH)); + } + if (world.isAir(bpos.east())) { + BlocksHelper.setWithoutUpdate(world, bpos.east(), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockMossyGlowshroomFur.FACING, Direction.EAST)); + } + if (world.isAir(bpos.south())) { + BlocksHelper.setWithoutUpdate(world, bpos.south(), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockMossyGlowshroomFur.FACING, Direction.SOUTH)); + } + if (world.isAir(bpos.west())) { + BlocksHelper.setWithoutUpdate(world, bpos.west(), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockMossyGlowshroomFur.FACING, Direction.WEST)); + } + if (world.getBlockState(bpos.down()).getMaterial().isReplaceable()) { + BlocksHelper.setWithoutUpdate(world, bpos.down(), BlockRegistry.MOSSY_GLOWSHROOM_FUR.getDefaultState().with(BlockMossyGlowshroomFur.FACING, Direction.DOWN)); + } + } + else if (BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(state) && random.nextBoolean() && world.getBlockState(bpos.up()).getBlock() == BlockRegistry.MOSSY_GLOWSHROOM_CAP) { + BlocksHelper.setWithoutUpdate(world, bpos, BlockRegistry.MOSSY_GLOWSHROOM_CAP.getDefaultState().with(BlockMossyGlowshroomCap.TRANSITION, true)); + BlocksHelper.setWithoutUpdate(world, bpos.up(), BlockRegistry.MOSSY_GLOWSHROOM_CAP); + } + } return true; } static { - /*SDFLine stem = new SDFLine(Blocks.GOLD_BLOCK.getDefaultState()).setRadius(2F).setEnd(0, 15, 0); + SDFCapedCone cone1 = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_CAP.getDefaultState()).setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F); + SDFCapedCone cone2 = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_CAP.getDefaultState()).setHeight(3F).setRadius1(2.5F).setRadius2(13F); + SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2); + SDF posedCone3 = new SDFTranslate().setTranslate(0, 7F, 0).setSource(cone2); + SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3); + SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone); + SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave); - SDFSphere outerSphere = new SDFSphere(Blocks.REDSTONE_BLOCK.getDefaultState()).setRadius(10); - SDFSphere innerSphere = new SDFSphere(Blocks.DIAMOND_BLOCK.getDefaultState()).setRadius(10); + SDF innerCone = new SDFTranslate().setTranslate(0, 1.25F, 0).setSource(upCone); + innerCone = new SDFScale3D().setScale(1.2F, 1F, 1.2F).setSource(innerCone); + cones = new SDFUnion().setSourceA(cones).setSourceB(innerCone); - SDFTranslate sphereOffset = new SDFTranslate().setTranslate(0, -10F, 0); + SDF glowCone = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE.getDefaultState()).setHeight(3F).setRadius1(2F).setRadius2(12.5F); + glowCone = new SDFTranslate().setTranslate(0, 4.25F, 0).setSource(glowCone); + glowCone = new SDFSubtraction().setSourceA(glowCone).setSourceB(posedCone3); - SDFFlatWave wave = new SDFFlatWave().setRaysCount(5).setIntensity(1.2F); - ISDF head = new SDFSubtraction().setSourceA(outerSphere).setSourceB(sphereOffset.setSource(innerSphere)); - head = new SDFScale3D().setScale(1, 0.5F, 1).setSource(head); - head = wave.setSource(head); + cones = new SDFUnion().setSourceA(cones).setSourceB(glowCone); - SDFTranslate headOffset = new SDFTranslate().setTranslate(0, 15, 0); + OpenSimplexNoise noise = new OpenSimplexNoise(1234); + cones = new SDFCoordModify().setFunction((pos) -> { + float dist = MHelper.length(pos.getX(), pos.getZ()); + float y = pos.getY() + (float) noise.eval(pos.getX() * 0.1 + CENTER.getX(), pos.getZ() * 0.1 + CENTER.getZ()) * dist * 0.3F - dist * 0.15F; + pos.set(pos.getX(), y, pos.getZ()); + }).setSource(cones); - FUNCTION = new SDFSmoothUnion().setRadius(5).setSourceA(stem).setSourceB(headOffset.setSource(head));*/ + HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones)); - SDFCapedCone cone = new SDFCapedCone(Blocks.GOLD_BLOCK.getDefaultState()).setHeight(10).setRadius1(0).setRadius2(10); - //SDFSphere sphere = new SDFSphere(Blocks.GOLD_BLOCK.getDefaultState()).setRadius(10); - HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(cone); + SDF roots = new SDFSphere(BlockRegistry.MOSSY_GLOWSHROOM.bark.getDefaultState()).setRadius(4F); + roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots); + ROOTS = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots); - FUNCTION = new SDFUnion().setSourceB(HEAD_POS); + FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS)); FUNCTION.setPostProcess((info) -> { if (BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) { - if (!BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp())) { + BlockState up = info.getStateUp(); + if (!BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(up) || !BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { return BlockRegistry.MOSSY_GLOWSHROOM.bark.getDefaultState(); } - else if (!BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { - return BlockRegistry.MOSSY_GLOWSHROOM.bark.getDefaultState(); + } + else if (info.getState().getBlock() == BlockRegistry.MOSSY_GLOWSHROOM_CAP) { + if (BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) { + return info.getState().with(BlockMossyGlowshroomCap.TRANSITION, true); } } return info.getState(); }); - REPLACE = (state) -> { + FUNCTION.setReplaceFunction((state) -> { + if (state.getBlock() != Blocks.END_STONE && state.isIn(BlockTagRegistry.END_GROUND)) { + return true; + } return state.getMaterial().isReplaceable(); - }; + }); } } diff --git a/src/main/resources/assets/betterend/blockstates/mossy_glowshroom_cap.json b/src/main/resources/assets/betterend/blockstates/mossy_glowshroom_cap.json new file mode 100644 index 00000000..5a55cb1b --- /dev/null +++ b/src/main/resources/assets/betterend/blockstates/mossy_glowshroom_cap.json @@ -0,0 +1,71 @@ +{ + "variants": { + "transition=false": [ + { "model": "betterend:block/mossy_glowshroom_cap" }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 90, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 180, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 270, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 90, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 180, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 270, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 90, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 180, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 270, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 90, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 180, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 270, "z": 90 }, + { "model": "betterend:block/mossy_glowshroom_cap", "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 90, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 180, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 270, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 90, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 180, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 270, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 90, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 180, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 270, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 90, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 180, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 270, "z": 180 }, + { "model": "betterend:block/mossy_glowshroom_cap", "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 90, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 180, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "y": 270, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 90, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 180, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 90, "y": 270, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 90, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 180, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 180, "y": 270, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 90, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 180, "z": 270 }, + { "model": "betterend:block/mossy_glowshroom_cap", "x": 270, "y": 270, "z": 270 } + ], + "transition=true": { "model": "betterend:block/mossy_glowshroom_cap_transition" } + } +} diff --git a/src/main/resources/assets/betterend/blockstates/mossy_glowshroom_fur.json b/src/main/resources/assets/betterend/blockstates/mossy_glowshroom_fur.json new file mode 100644 index 00000000..ad5cd9f4 --- /dev/null +++ b/src/main/resources/assets/betterend/blockstates/mossy_glowshroom_fur.json @@ -0,0 +1,10 @@ +{ + "variants": { + "facing=up": { "model": "betterend:block/mossy_glowshroom_fur" }, + "facing=down": { "model": "betterend:block/mossy_glowshroom_fur", "x": 180 }, + "facing=north": { "model": "betterend:block/mossy_glowshroom_fur", "x": 90 }, + "facing=south": { "model": "betterend:block/mossy_glowshroom_fur", "x": 90, "y": 180 }, + "facing=east": { "model": "betterend:block/mossy_glowshroom_fur", "x": 90, "y": 90 }, + "facing=west": { "model": "betterend:block/mossy_glowshroom_fur", "x": 90, "y": 270 } + } +} diff --git a/src/main/resources/assets/betterend/models/block/cube_noshade.json b/src/main/resources/assets/betterend/models/block/cube_noshade.json new file mode 100644 index 00000000..2f64924d --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/cube_noshade.json @@ -0,0 +1,22 @@ +{ + "parent": "block/block", + "textures": { + "particle": "#texture" + }, + "elements": [ + { + "__comment": "Box1", + "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "east" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_cap.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_cap.json new file mode 100644 index 00000000..18e8addd --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_cap.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "betterend:block/mossy_glowshroom_cap" + } +} diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_cap_transition.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_cap_transition.json new file mode 100644 index 00000000..ff91d84a --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_cap_transition.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube", + "textures": { + "down": "betterend:block/mossy_glowshroom_log_side", + "east": "betterend:block/mossy_glowshroom_cap_transition", + "north": "betterend:block/mossy_glowshroom_cap_transition", + "particle": "betterend:block/mossy_glowshroom_cap_transition", + "south": "betterend:block/mossy_glowshroom_cap_transition", + "up": "betterend:block/mossy_glowshroom_cap", + "west": "betterend:block/mossy_glowshroom_cap_transition" + } +} diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_fur.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_fur.json new file mode 100644 index 00000000..3eff83e4 --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_fur.json @@ -0,0 +1,75 @@ +{ + "__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio", + "textures": { + "particle": "betterend:block/mossy_glowshroom_fur", + "texture": "betterend:block/mossy_glowshroom_fur" + }, + "elements": [ + { + "__comment": "PlaneY1", + "from": [ 0, -0.001, -8 ], + "to": [ 16, 0, 8 ], + "rotation": { "origin": [ 0, 0, 8 ], "axis": "x", "angle": 22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 } + } + }, + { + "__comment": "PlaneY1", + "from": [ 0, 0, 8 ], + "to": [ 16, 0.001, 24 ], + "rotation": { "origin": [ 0, 0.000000954, 8 ], "axis": "x", "angle": -22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "PlaneY4", + "from": [ 8, -0.001, 0 ], + "to": [ 24, 0, 16 ], + "rotation": { "origin": [ 8, 0, 16 ], "axis": "z", "angle": 22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 270 }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 270 } + } + }, + { + "__comment": "PlaneY4", + "from": [ -8, 0, 2 ], + "to": [ 8, 0.001, 18 ], + "rotation": { "origin": [ 8, 0, 18 ], "axis": "z", "angle": -22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 } + } + }, + { + "__comment": "PlaneX6", + "from": [ 0, 0, -6.5 ], + "to": [ 0.001, 16, 16 ], + "rotation": { "origin": [ 0, 16, 16 ], "axis": "y", "angle": -45 }, + "shade": false, + "faces": { + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 } + } + }, + { + "__comment": "PlaneX6", + "from": [ -6.5, 0, 15.999 ], + "to": [ 16, 16, 16 ], + "rotation": { "origin": [ 16, 16, 16 ], "axis": "y", "angle": -45 }, + "shade": false, + "faces": { + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_1.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_1.json index 3049938f..ff69ee73 100644 --- a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_1.json +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_1.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", + "parent": "betterend:block/cube_noshade", "textures": { - "all": "betterend:block/mossy_glowshroom_hymenophore_1" + "texture": "betterend:block/mossy_glowshroom_hymenophore_1" } } diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_2.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_2.json index 52c99750..d66ec78c 100644 --- a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_2.json +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_2.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", + "parent": "betterend:block/cube_noshade", "textures": { - "all": "betterend:block/mossy_glowshroom_hymenophore_2" + "texture": "betterend:block/mossy_glowshroom_hymenophore_2" } } diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_3.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_3.json index 70623681..cf74621a 100644 --- a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_3.json +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_3.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", + "parent": "betterend:block/cube_noshade", "textures": { - "all": "betterend:block/mossy_glowshroom_hymenophore_3" + "texture": "betterend:block/mossy_glowshroom_hymenophore_3" } } diff --git a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_4.json b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_4.json index a18de4d5..46bae5fa 100644 --- a/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_4.json +++ b/src/main/resources/assets/betterend/models/block/mossy_glowshroom_hymenophore_4.json @@ -1,6 +1,6 @@ { - "parent": "block/cube_all", + "parent": "betterend:block/cube_noshade", "textures": { - "all": "betterend:block/mossy_glowshroom_hymenophore_4" + "texture": "betterend:block/mossy_glowshroom_hymenophore_4" } } diff --git a/src/main/resources/assets/betterend/models/item/mossy_glowshroom_cap.json b/src/main/resources/assets/betterend/models/item/mossy_glowshroom_cap.json new file mode 100644 index 00000000..19b1a71e --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/mossy_glowshroom_cap.json @@ -0,0 +1,3 @@ +{ + "parent": "betterend:block/mossy_glowshroom_cap" +} diff --git a/src/main/resources/assets/betterend/models/item/mossy_glowshroom_fur.json b/src/main/resources/assets/betterend/models/item/mossy_glowshroom_fur.json new file mode 100644 index 00000000..e7874eed --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/mossy_glowshroom_fur.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "betterend:block/mossy_glowshroom_fur" + } +} diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_cap.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_cap.png new file mode 100644 index 00000000..eebc86ac Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_cap.png differ diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_cap_transition.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_cap_transition.png new file mode 100644 index 00000000..fba06215 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_cap_transition.png differ diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_fur.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_fur.png new file mode 100644 index 00000000..725746f6 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_fur.png differ diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_1.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_1.png index cb490ec2..4bdc8986 100644 Binary files a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_1.png and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_1.png differ diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_2.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_2.png index 20a15d29..53ebac28 100644 Binary files a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_2.png and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_2.png differ diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_3.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_3.png index 28c7d2eb..f5245fd4 100644 Binary files a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_3.png and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_3.png differ diff --git a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_4.png b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_4.png index be7189e7..fe225c56 100644 Binary files a/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_4.png and b/src/main/resources/assets/betterend/textures/block/mossy_glowshroom_hymenophore_4.png differ