From 72b173a9e3462606effdaa092c5c102b3ba83649 Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Thu, 1 Oct 2020 01:39:06 +0300 Subject: [PATCH] Mosses, fixes --- .../ru/betterend/blocks/BlockGlowingMoss.java | 30 +++++ .../betterend/blocks/BlockUmbrellaMoss.java | 9 -- .../blocks/BlockUmbrellaMossTall.java | 20 +-- .../blocks/basis/BlockDoublePlant.java | 17 ++- .../ru/betterend/blocks/basis/BlockPlant.java | 6 +- .../ru/betterend/recipe/AlloyingRecipes.java | 1 - .../ru/betterend/recipe/CraftingRecipes.java | 1 - .../ru/betterend/registry/BiomeRegistry.java | 1 - .../ru/betterend/registry/BlockRegistry.java | 5 +- .../betterend/registry/BlockTagRegistry.java | 2 - .../betterend/registry/FeatureRegistry.java | 11 ++ .../ru/betterend/registry/ItemRegistry.java | 1 - .../java/ru/betterend/tab/CreativeTab.java | 4 +- .../world/biome/BiomeFoggyMushroomland.java | 4 +- .../world/features/DefaultFeature.java | 2 +- .../world/features/DoublePlantFeature.java | 72 +++++++++++ .../world/features/EndLakeFeature.java | 10 +- .../features/MossyGlowshroomFeature.java | 2 +- .../world/features/SinglePlantFeature.java | 66 ++++++++++ .../surface/DoubleBlockSurfaceBuilder.java | 1 - .../betterend/blockstates/creeping_moss.json | 10 ++ .../assets/betterend/lang/en_us.json | 3 +- .../assets/betterend/lang/ru_ru.json | 3 +- .../betterend/models/block/creeping_moss.json | 120 ++++++++++++++++++ .../betterend/models/item/creeping_moss.json | 6 + .../textures/block/creeping_moss_leaves.png | Bin 0 -> 1902 bytes .../textures/block/creeping_moss_spores.png | Bin 0 -> 1741 bytes .../betterend/textures/item/creeping_moss.png | Bin 0 -> 2359 bytes 28 files changed, 354 insertions(+), 53 deletions(-) create mode 100644 src/main/java/ru/betterend/blocks/BlockGlowingMoss.java delete mode 100644 src/main/java/ru/betterend/blocks/BlockUmbrellaMoss.java create mode 100644 src/main/java/ru/betterend/world/features/DoublePlantFeature.java create mode 100644 src/main/java/ru/betterend/world/features/SinglePlantFeature.java create mode 100644 src/main/resources/assets/betterend/blockstates/creeping_moss.json create mode 100644 src/main/resources/assets/betterend/models/block/creeping_moss.json create mode 100644 src/main/resources/assets/betterend/models/item/creeping_moss.json create mode 100644 src/main/resources/assets/betterend/textures/block/creeping_moss_leaves.png create mode 100644 src/main/resources/assets/betterend/textures/block/creeping_moss_spores.png create mode 100644 src/main/resources/assets/betterend/textures/item/creeping_moss.png diff --git a/src/main/java/ru/betterend/blocks/BlockGlowingMoss.java b/src/main/java/ru/betterend/blocks/BlockGlowingMoss.java new file mode 100644 index 00000000..76fc6d49 --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockGlowingMoss.java @@ -0,0 +1,30 @@ +package ru.betterend.blocks; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.block.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; +import ru.betterend.blocks.basis.BlockPlant; +import ru.betterend.registry.BlockRegistry; + +public class BlockGlowingMoss extends BlockPlant { + public BlockGlowingMoss(int light) { + super(light); + } + + @Override + protected boolean isTerrain(BlockState state) { + return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM; + } + + @Environment(EnvType.CLIENT) + public boolean hasEmissiveLighting(BlockView world, BlockPos pos) { + return true; + } + + @Environment(EnvType.CLIENT) + public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) { + return 1F; + } +} \ No newline at end of file diff --git a/src/main/java/ru/betterend/blocks/BlockUmbrellaMoss.java b/src/main/java/ru/betterend/blocks/BlockUmbrellaMoss.java deleted file mode 100644 index 62eaad62..00000000 --- a/src/main/java/ru/betterend/blocks/BlockUmbrellaMoss.java +++ /dev/null @@ -1,9 +0,0 @@ -package ru.betterend.blocks; - -import ru.betterend.blocks.basis.BlockPlant; - -public class BlockUmbrellaMoss extends BlockPlant { - public BlockUmbrellaMoss() { - super(12); - } -} diff --git a/src/main/java/ru/betterend/blocks/BlockUmbrellaMossTall.java b/src/main/java/ru/betterend/blocks/BlockUmbrellaMossTall.java index 26d51cf4..02ca89b0 100644 --- a/src/main/java/ru/betterend/blocks/BlockUmbrellaMossTall.java +++ b/src/main/java/ru/betterend/blocks/BlockUmbrellaMossTall.java @@ -2,23 +2,15 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; 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.World; import ru.betterend.blocks.basis.BlockDoublePlant; import ru.betterend.registry.BlockRegistry; -import ru.betterend.util.BlocksHelper; public class BlockUmbrellaMossTall extends BlockDoublePlant { - public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3); - public BlockUmbrellaMossTall() { super(12); } @@ -30,15 +22,7 @@ public class BlockUmbrellaMossTall extends BlockDoublePlant { } @Override - public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { - int rot = world.random.nextInt(4); - BlocksHelper.setWithoutUpdate(world, pos, this.getDefaultState().with(ROTATION, rot)); - BlocksHelper.setWithoutUpdate(world, pos.up(), this.getDefaultState().with(ROTATION, rot).with(TOP, true)); - } - - @Override - protected void appendProperties(StateManager.Builder stateManager) { - super.appendProperties(stateManager); - stateManager.add(ROTATION); + protected boolean isTerrain(BlockState state) { + return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM; } } diff --git a/src/main/java/ru/betterend/blocks/basis/BlockDoublePlant.java b/src/main/java/ru/betterend/blocks/basis/BlockDoublePlant.java index 8ad2a6c9..ea09ae91 100644 --- a/src/main/java/ru/betterend/blocks/basis/BlockDoublePlant.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockDoublePlant.java @@ -25,6 +25,7 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.IntProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; @@ -40,6 +41,7 @@ import ru.betterend.util.BlocksHelper; public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable { private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12); + public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3); public static final BooleanProperty TOP = BooleanProperty.of("top"); public BlockDoublePlant() { @@ -63,7 +65,7 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl @Override protected void appendProperties(StateManager.Builder stateManager) { - stateManager.add(TOP); + stateManager.add(TOP, ROTATION); } @Override @@ -81,15 +83,19 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { BlockState down = world.getBlockState(pos.down()); BlockState up = world.getBlockState(pos.up()); - return state.get(TOP) ? down.getBlock() == this : down.isIn(BlockTagRegistry.END_GROUND) && (up.getMaterial().isReplaceable()); + return state.get(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getMaterial().isReplaceable()); } public boolean canStayAt(BlockState state, WorldView world, BlockPos pos) { BlockState down = world.getBlockState(pos.down()); BlockState up = world.getBlockState(pos.up()); - return state.get(TOP) ? down.getBlock() == this : down.isIn(BlockTagRegistry.END_GROUND) && (up.getBlock() == this); + return state.get(TOP) ? down.getBlock() == this : isTerrain(down) && (up.getBlock() == this); } + protected boolean isTerrain(BlockState state) { + return state.isIn(BlockTagRegistry.END_GROUND); + } + @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { if (!canStayAt(state, world, pos)) { @@ -138,6 +144,9 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl @Override public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { - BlocksHelper.setWithoutUpdate(world, pos.up(), this.getDefaultState().with(TOP, true)); + int rot = world.random.nextInt(4); + BlockState bs = this.getDefaultState().with(ROTATION, rot); + BlocksHelper.setWithoutUpdate(world, pos, bs); + BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(TOP, true)); } } diff --git a/src/main/java/ru/betterend/blocks/basis/BlockPlant.java b/src/main/java/ru/betterend/blocks/basis/BlockPlant.java index d50501c6..3fa9463b 100644 --- a/src/main/java/ru/betterend/blocks/basis/BlockPlant.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockPlant.java @@ -68,7 +68,11 @@ public class BlockPlant extends BlockBaseNotFull implements IRenderTypeable, Fer @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { BlockState down = world.getBlockState(pos.down()); - return down.isIn(BlockTagRegistry.END_GROUND); + return isTerrain(down); + } + + protected boolean isTerrain(BlockState state) { + return state.isIn(BlockTagRegistry.END_GROUND); } @Override diff --git a/src/main/java/ru/betterend/recipe/AlloyingRecipes.java b/src/main/java/ru/betterend/recipe/AlloyingRecipes.java index c5a201cf..fe832d48 100644 --- a/src/main/java/ru/betterend/recipe/AlloyingRecipes.java +++ b/src/main/java/ru/betterend/recipe/AlloyingRecipes.java @@ -2,7 +2,6 @@ package ru.betterend.recipe; import net.minecraft.block.Blocks; import net.minecraft.item.Items; - import ru.betterend.registry.ItemRegistry; public class AlloyingRecipes { diff --git a/src/main/java/ru/betterend/recipe/CraftingRecipes.java b/src/main/java/ru/betterend/recipe/CraftingRecipes.java index e2b36cf2..18c4efe7 100644 --- a/src/main/java/ru/betterend/recipe/CraftingRecipes.java +++ b/src/main/java/ru/betterend/recipe/CraftingRecipes.java @@ -5,7 +5,6 @@ import net.minecraft.block.Blocks; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.util.registry.Registry; - import ru.betterend.registry.BlockRegistry; public class CraftingRecipes { diff --git a/src/main/java/ru/betterend/registry/BiomeRegistry.java b/src/main/java/ru/betterend/registry/BiomeRegistry.java index 7d97a7e3..7495aaf5 100644 --- a/src/main/java/ru/betterend/registry/BiomeRegistry.java +++ b/src/main/java/ru/betterend/registry/BiomeRegistry.java @@ -12,7 +12,6 @@ import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.Category; import net.minecraft.world.biome.BiomeKeys; - import ru.betterend.world.biome.BiomeFoggyMushroomland; import ru.betterend.world.biome.EndBiome; import ru.betterend.world.generator.BiomePicker; diff --git a/src/main/java/ru/betterend/registry/BlockRegistry.java b/src/main/java/ru/betterend/registry/BlockRegistry.java index d2e63f5e..ef7f381e 100644 --- a/src/main/java/ru/betterend/registry/BlockRegistry.java +++ b/src/main/java/ru/betterend/registry/BlockRegistry.java @@ -8,13 +8,13 @@ import net.minecraft.util.registry.Registry; import ru.betterend.BetterEnd; import ru.betterend.blocks.AeterniumBlock; import ru.betterend.blocks.BlockEndstoneDust; +import ru.betterend.blocks.BlockGlowingMoss; import ru.betterend.blocks.BlockMossyGlowshroomCap; import ru.betterend.blocks.BlockMossyGlowshroomFur; import ru.betterend.blocks.BlockMossyGlowshroomHymenophore; import ru.betterend.blocks.BlockMossyGlowshroomSapling; import ru.betterend.blocks.BlockOre; import ru.betterend.blocks.BlockTerrain; -import ru.betterend.blocks.BlockUmbrellaMoss; import ru.betterend.blocks.BlockUmbrellaMossTall; import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.blocks.EnderBlock; @@ -36,8 +36,9 @@ public class BlockRegistry { public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD); // Small Plants // - public static final Block UMBRELLA_MOSS = registerBlock("umbrella_moss", new BlockUmbrellaMoss()); + public static final Block UMBRELLA_MOSS = registerBlock("umbrella_moss", new BlockGlowingMoss(10)); public static final Block UMBRELLA_MOSS_TALL = registerBlock("umbrella_moss_tall", new BlockUmbrellaMossTall()); + public static final Block CREEPING_MOSS = registerBlock("creeping_moss", new BlockGlowingMoss(10)); // Ores // public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3)); diff --git a/src/main/java/ru/betterend/registry/BlockTagRegistry.java b/src/main/java/ru/betterend/registry/BlockTagRegistry.java index 5ec14e43..a82cac0e 100644 --- a/src/main/java/ru/betterend/registry/BlockTagRegistry.java +++ b/src/main/java/ru/betterend/registry/BlockTagRegistry.java @@ -1,11 +1,9 @@ package ru.betterend.registry; import net.fabricmc.fabric.api.tag.TagRegistry; - import net.minecraft.block.Block; import net.minecraft.tag.Tag; import net.minecraft.tag.Tag.Identified; - import ru.betterend.BetterEnd; import ru.betterend.util.TagHelper; diff --git a/src/main/java/ru/betterend/registry/FeatureRegistry.java b/src/main/java/ru/betterend/registry/FeatureRegistry.java index 1698b52d..97a39ce8 100644 --- a/src/main/java/ru/betterend/registry/FeatureRegistry.java +++ b/src/main/java/ru/betterend/registry/FeatureRegistry.java @@ -1,12 +1,23 @@ package ru.betterend.registry; +import ru.betterend.world.features.DoublePlantFeature; import ru.betterend.world.features.EndFeature; import ru.betterend.world.features.EndLakeFeature; import ru.betterend.world.features.MossyGlowshroomFeature; +import ru.betterend.world.features.SinglePlantFeature; public class FeatureRegistry { + // Trees // public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 1); + + // Plants // + public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(BlockRegistry.UMBRELLA_MOSS, BlockRegistry.UMBRELLA_MOSS_TALL, 5), 5); + public static final EndFeature CREEPING_MOSS = new EndFeature("creeping_moss", new SinglePlantFeature(BlockRegistry.CREEPING_MOSS, 5), 5); + + // Features // public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 100); + + // Ores // public static final EndFeature ENDER_ORE = EndFeature.makeOreFeature("ender_ore", BlockRegistry.ENDER_ORE, 6, 3, 0, 4, 96); public static void register() {} diff --git a/src/main/java/ru/betterend/registry/ItemRegistry.java b/src/main/java/ru/betterend/registry/ItemRegistry.java index 54830293..08101d5a 100644 --- a/src/main/java/ru/betterend/registry/ItemRegistry.java +++ b/src/main/java/ru/betterend/registry/ItemRegistry.java @@ -9,7 +9,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.Items; import net.minecraft.util.registry.Registry; - import ru.betterend.BetterEnd; public class ItemRegistry { diff --git a/src/main/java/ru/betterend/tab/CreativeTab.java b/src/main/java/ru/betterend/tab/CreativeTab.java index eb8a0273..6f55e601 100644 --- a/src/main/java/ru/betterend/tab/CreativeTab.java +++ b/src/main/java/ru/betterend/tab/CreativeTab.java @@ -1,17 +1,17 @@ package ru.betterend.tab; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; -import net.minecraft.block.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import ru.betterend.BetterEnd; +import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.ItemRegistry; public class CreativeTab { public static final ItemGroup END_TAB = FabricItemGroupBuilder.create(new Identifier(BetterEnd.MOD_ID, "items")) - .icon(() -> new ItemStack(Blocks.END_STONE)).appendItems(stacks -> { + .icon(() -> new ItemStack(BlockRegistry.END_MYCELIUM)).appendItems(stacks -> { for (Item i : ItemRegistry.getModBlocks()) { stacks.add(new ItemStack(i)); } diff --git a/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java b/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java index 8f241211..e4132ce6 100644 --- a/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java +++ b/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java @@ -13,6 +13,8 @@ public class BiomeFoggyMushroomland extends EndBiome { .setSurface(BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM) .addFeature(FeatureRegistry.ENDER_ORE) .addFeature(FeatureRegistry.END_LAKE) - .addFeature(FeatureRegistry.MOSSY_GLOWSHROOM)); + .addFeature(FeatureRegistry.MOSSY_GLOWSHROOM) + .addFeature(FeatureRegistry.UMBRELLA_MOSS) + .addFeature(FeatureRegistry.CREEPING_MOSS)); } } diff --git a/src/main/java/ru/betterend/world/features/DefaultFeature.java b/src/main/java/ru/betterend/world/features/DefaultFeature.java index 03ab3ddb..16632569 100644 --- a/src/main/java/ru/betterend/world/features/DefaultFeature.java +++ b/src/main/java/ru/betterend/world/features/DefaultFeature.java @@ -16,7 +16,7 @@ public abstract class DefaultFeature extends Feature { super(DefaultFeatureConfig.CODEC); } - protected BlockPos getTopPos(StructureWorldAccess world, BlockPos pos) { + protected BlockPos getPosOnSurface(StructureWorldAccess world, BlockPos pos) { return world.getTopPosition(Type.WORLD_SURFACE, pos); } } diff --git a/src/main/java/ru/betterend/world/features/DoublePlantFeature.java b/src/main/java/ru/betterend/world/features/DoublePlantFeature.java new file mode 100644 index 00000000..adae8e95 --- /dev/null +++ b/src/main/java/ru/betterend/world/features/DoublePlantFeature.java @@ -0,0 +1,72 @@ +package ru.betterend.world.features; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +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.blocks.basis.BlockDoublePlant; +import ru.betterend.registry.BlockTagRegistry; +import ru.betterend.util.BlocksHelper; +import ru.betterend.util.MHelper; + +public class DoublePlantFeature extends DefaultFeature { + private static final Mutable POS = new Mutable(); + private final Block smallPlant; + private final Block largePlant; + private final int radius; + + public DoublePlantFeature(Block smallPlant, Block largePlant, int radius) { + this.smallPlant = smallPlant; + this.largePlant = largePlant; + this.radius = radius; + } + + @Override + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { + blockPos = getPosOnSurface(world, blockPos); + + if (blockPos.getY() < 5) { + return false; + } + if (!world.getBlockState(blockPos.down()).isIn(BlockTagRegistry.END_GROUND)) { + return false; + } + + float r = MHelper.randRange(radius * 0.5F, radius, random); + int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random)); + Block block; + 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(blockPos.getX() + x, blockPos.getY() + 5, blockPos.getZ() + z); + int down = BlocksHelper.downRay(world, POS, 16); + if (down > 10) continue; + POS.setY(POS.getY() - down); + + float d = MHelper.length(x, z) / r * 0.6F + random.nextFloat() * 0.4F; + block = d < 0.5F ? largePlant : smallPlant; + + if (block.canPlaceAt(block.getDefaultState(), world, POS)) { + if (block instanceof BlockDoublePlant) { + int rot = random.nextInt(4); + BlockState state = block.getDefaultState().with(BlockDoublePlant.ROTATION, rot); + BlocksHelper.setWithoutUpdate(world, POS, state); + BlocksHelper.setWithoutUpdate(world, POS.up(), state.with(BlockDoublePlant.TOP, true)); + } + else { + BlocksHelper.setWithoutUpdate(world, POS, block); + } + } + } + + return true; + } +} diff --git a/src/main/java/ru/betterend/world/features/EndLakeFeature.java b/src/main/java/ru/betterend/world/features/EndLakeFeature.java index e729df42..c0df9bfe 100644 --- a/src/main/java/ru/betterend/world/features/EndLakeFeature.java +++ b/src/main/java/ru/betterend/world/features/EndLakeFeature.java @@ -27,24 +27,24 @@ public class EndLakeFeature extends DefaultFeature { int dist = MHelper.floor(radius); int dist2 = MHelper.floor(radius * 1.5); int bott = MHelper.floor(depth); - blockPos = getTopPos(world, blockPos); + blockPos = getPosOnSurface(world, blockPos); if (blockPos.getY() < 10) return false; int waterLevel = blockPos.getY(); - BlockPos pos = getTopPos(world, blockPos.north(dist)); + BlockPos pos = getPosOnSurface(world, blockPos.north(dist)); if (pos.getY() < 10) return false; waterLevel = MHelper.min(pos.getY(), waterLevel); - pos = getTopPos(world, blockPos.south(dist)); + pos = getPosOnSurface(world, blockPos.south(dist)); if (pos.getY() < 10) return false; waterLevel = MHelper.min(pos.getY(), waterLevel); - pos = getTopPos(world, blockPos.east(dist)); + pos = getPosOnSurface(world, blockPos.east(dist)); if (pos.getY() < 10) return false; waterLevel = MHelper.min(pos.getY(), waterLevel); - pos = getTopPos(world, blockPos.west(dist)); + pos = getPosOnSurface(world, blockPos.west(dist)); if (pos.getY() < 10) return false; waterLevel = MHelper.min(pos.getY(), waterLevel); diff --git a/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java b/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java index 156d9628..e8a44faf 100644 --- a/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java +++ b/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java @@ -51,7 +51,7 @@ public class MossyGlowshroomFeature extends DefaultFeature { @Override public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { - blockPos = getTopPos(world, blockPos); + blockPos = getPosOnSurface(world, blockPos); if (blockPos.getY() < 5) { return false; } diff --git a/src/main/java/ru/betterend/world/features/SinglePlantFeature.java b/src/main/java/ru/betterend/world/features/SinglePlantFeature.java new file mode 100644 index 00000000..47331a95 --- /dev/null +++ b/src/main/java/ru/betterend/world/features/SinglePlantFeature.java @@ -0,0 +1,66 @@ +package ru.betterend.world.features; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +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.blocks.basis.BlockDoublePlant; +import ru.betterend.registry.BlockTagRegistry; +import ru.betterend.util.BlocksHelper; +import ru.betterend.util.MHelper; + +public class SinglePlantFeature extends DefaultFeature { + private static final Mutable POS = new Mutable(); + private final Block plant; + private final int radius; + + public SinglePlantFeature(Block plant, int radius) { + this.plant = plant; + this.radius = radius; + } + + @Override + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) { + blockPos = getPosOnSurface(world, blockPos); + + if (blockPos.getY() < 5) { + return false; + } + if (!world.getBlockState(blockPos.down()).isIn(BlockTagRegistry.END_GROUND)) { + return false; + } + + 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(blockPos.getX() + x, blockPos.getY() + 5, blockPos.getZ() + z); + int down = BlocksHelper.downRay(world, POS, 16); + if (down > 10) continue; + POS.setY(POS.getY() - down); + + if (plant.canPlaceAt(plant.getDefaultState(), world, POS)) { + if (plant instanceof BlockDoublePlant) { + int rot = random.nextInt(4); + BlockState state = plant.getDefaultState().with(BlockDoublePlant.ROTATION, rot); + BlocksHelper.setWithoutUpdate(world, POS, state); + BlocksHelper.setWithoutUpdate(world, POS.up(), state.with(BlockDoublePlant.TOP, true)); + } + else { + BlocksHelper.setWithoutUpdate(world, POS, plant); + } + } + } + + return true; + } +} diff --git a/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java b/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java index 375a5be8..7c728c2d 100644 --- a/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java +++ b/src/main/java/ru/betterend/world/surface/DoubleBlockSurfaceBuilder.java @@ -10,7 +10,6 @@ import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig; - import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.util.MHelper; diff --git a/src/main/resources/assets/betterend/blockstates/creeping_moss.json b/src/main/resources/assets/betterend/blockstates/creeping_moss.json new file mode 100644 index 00000000..49c4c6e1 --- /dev/null +++ b/src/main/resources/assets/betterend/blockstates/creeping_moss.json @@ -0,0 +1,10 @@ +{ + "variants": { + "": [ + { "model": "betterend:block/creeping_moss" }, + { "model": "betterend:block/creeping_moss", "y": 90 }, + { "model": "betterend:block/creeping_moss", "y": 180 }, + { "model": "betterend:block/creeping_moss", "y": 270 } + ] + } +} diff --git a/src/main/resources/assets/betterend/lang/en_us.json b/src/main/resources/assets/betterend/lang/en_us.json index 312b8a69..d0091ed9 100644 --- a/src/main/resources/assets/betterend/lang/en_us.json +++ b/src/main/resources/assets/betterend/lang/en_us.json @@ -38,5 +38,6 @@ "block.betterend.mossy_glowshroom_trapdoor": "Mossy Glowshroom Trapdoor", "block.betterend.umbrella_moss": "Umbrella Moss", - "block.betterend.umbrella_moss_tall": "Tall Umbrella Moss" + "block.betterend.umbrella_moss_tall": "Tall Umbrella Moss", + "block.betterend.creeping_moss": "Creeping Moss" } \ No newline at end of file diff --git a/src/main/resources/assets/betterend/lang/ru_ru.json b/src/main/resources/assets/betterend/lang/ru_ru.json index f065e133..f67be4be 100644 --- a/src/main/resources/assets/betterend/lang/ru_ru.json +++ b/src/main/resources/assets/betterend/lang/ru_ru.json @@ -38,5 +38,6 @@ "block.betterend.mossy_glowshroom_trapdoor": "Люк из мшистого светогриба", "block.betterend.umbrella_moss": "Зонтичный мох", - "block.betterend.umbrella_moss_tall": "Высокий зонтичный мох" + "block.betterend.umbrella_moss_tall": "Высокий зонтичный мох", + "block.betterend.creeping_moss": "Стелющийся мох" } \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/block/creeping_moss.json b/src/main/resources/assets/betterend/models/block/creeping_moss.json new file mode 100644 index 00000000..01a9b37f --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/creeping_moss.json @@ -0,0 +1,120 @@ +{ + "__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio", + "textures": { + "particle": "betterend:block/creeping_moss_leaves", + "texture": "betterend:block/creeping_moss_leaves", + "spore": "betterend:block/creeping_moss_spores" + }, + "elements": [ + { + "__comment": "PlaneY1", + "from": [ 0, -0.001, -10 ], + "to": [ 16, 0, 6 ], + "rotation": { "origin": [ 0, 0, 6 ], "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": "PlaneY1", + "from": [ 0, 0, 10 ], + "to": [ 16, 0.001, 26 ], + "rotation": { "origin": [ 0, 0, 10 ], "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": "PlaneY4", + "from": [ 10, -0.001, 0 ], + "to": [ 26, 0, 16 ], + "rotation": { "origin": [ 10, 0, 16 ], "axis": "z", "angle": 22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 }, + "up": { "uv": [ 0, 16, 16, 0 ], "texture": "#texture", "rotation": 270 } + } + }, + { + "__comment": "PlaneY4", + "from": [ -10, 0, 2 ], + "to": [ 6, 0.001, 18 ], + "rotation": { "origin": [ 6, 0, 18 ], "axis": "z", "angle": -22.5 }, + "shade": false, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 270 }, + "up": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "rotation": 270 } + } + }, + { + "__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": "#spore" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#spore" } + } + }, + { + "__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": "#spore" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#spore" } + } + }, + { + "__comment": "PlaneY1", + "from": [ 0, -0.001, -9 ], + "to": [ 16, 0, 7 ], + "rotation": { "origin": [ 0, 0, 7 ], "axis": "x", "angle": 45 }, + "shade": false, + "faces": { + "down": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "rotation": 180 }, + "up": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" } + } + }, + { + "__comment": "PlaneY1", + "from": [ 0, 0, 9 ], + "to": [ 16, 0.001, 25 ], + "rotation": { "origin": [ 0, 0, 9 ], "axis": "x", "angle": -45 }, + "shade": false, + "faces": { + "down": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture" }, + "up": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "rotation": 180 } + } + }, + { + "__comment": "PlaneY4", + "from": [ 9, -0.001, 0 ], + "to": [ 25, 0, 16 ], + "rotation": { "origin": [ 9, 0, 16 ], "axis": "z", "angle": 45 }, + "shade": false, + "faces": { + "down": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "rotation": 90 }, + "up": { "uv": [ 16, 16, 0, 0 ], "texture": "#texture", "rotation": 270 } + } + }, + { + "__comment": "PlaneY4", + "from": [ -9, 0, 2 ], + "to": [ 7, 0.001, 18 ], + "rotation": { "origin": [ 7, 0, 18 ], "axis": "z", "angle": -45 }, + "shade": false, + "faces": { + "down": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "rotation": 270 }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 270 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/item/creeping_moss.json b/src/main/resources/assets/betterend/models/item/creeping_moss.json new file mode 100644 index 00000000..32242104 --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/creeping_moss.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "betterend:item/creeping_moss" + } +} diff --git a/src/main/resources/assets/betterend/textures/block/creeping_moss_leaves.png b/src/main/resources/assets/betterend/textures/block/creeping_moss_leaves.png new file mode 100644 index 0000000000000000000000000000000000000000..a9b5f63d62f00d5d48e877c26cc19a56be6fab58 GIT binary patch literal 1902 zcmbVN3rrJd9B&mBVJHeJ_!!3#6~yaZ+oO+zBG8smT@|s6hsJo`UCTk+yWU-G!Qd2( z4qpj4w}_}wr^Z6ubkoeaX*8S8v5AY$ER*RBx-E(^%6x@~yDOzx7PmPs`R@C^`+nc= z|NdV?;rusZq9#YlWU?4bfvHHGW2F%}QhX=%JjcapG+R){%Vg1U(vZuVTM}flh#uNj zDwJB^#0bWvz)5B~rSQ905iOHt&GEB1QAG*Ba>_xw4dDHgr$K-w4PZ%z6|u5Ls)8=4 z;iyG5^KC>;6`?1=IoUv#9}@{&lz;<%m($H-eghcf#l*Gr83utMM5r==xspJj)LIA_ z8IA%n6dH(7qAEbES12`zUWLvERESawBU)Igh7cu&XfU-N2tA-EjU(+?ktshUOWYa2 z3PE5o820&m3ZGiRa1L0h*XvD;$9g$uP&i4zl#_B%Zh;rE$}m>+lGPf9 zzmV4D3Zr?!yh79{WZMhTyset0;3A4=yc|K9SBMf*h7@Bf7=hs{n18S%d>poh#f%(< z3k+vt80S!+3Wrz#qfrWs4oEGb-6Z4V(m z`RY93AYn$v$#7PN6uqpLQaG4OSOLw8@v06L#UjcRS~+PTm^~OyNC|EL2`RD^35Gt? zuk4vYT3-bvlKxA$2Vp#87koHJ`pu6-i>8ZRg zI-<@v4o;4^Bfm2D1b4IKOqzBKAfHaR{Gwa+;rg8!J8oS+b~SyoAKlUOhc<2h zmg>X9uX!`%zf~q&9+my9zAVr1P{{91+I6PbT<-cA=-|n+b%DUL?O@8a z*;h2p&u0l^`*LskGlyRmWRg;#ESnjW{-`9{GP zm$=gaJEq@{S=!ijD6^!^o_&Xu`}VEB`M}YcS@Zp))zPgti1?2q2J(}< zZ(X`r-wRCNO>RVY(Pr(~-A#0AYiny$TmPA==C_|8sz0#jSkp8&Q?$36wCwFyuY6Rs zw!CrksWG13dnrxDF-LlTP2Sd(u$7quOkKR>Q_toDGgHvHcTTiV+7{4vu1fuUClna? zvSQ=-{<|fGGt#;b{9ujmyzzVAj1GO-!qwLwPwY%3cUJBtpTHj^PV5@J0gdAhpYzA3 dd{$%W8y-2rq`i2HZjkrpsN4? literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/betterend/textures/block/creeping_moss_spores.png b/src/main/resources/assets/betterend/textures/block/creeping_moss_spores.png new file mode 100644 index 0000000000000000000000000000000000000000..e2c789ea63ed78521b760255856f23ad1477241e GIT binary patch literal 1741 zcmbVN3rrhj96uZbWJ5sqU~Gijb&H#^+TQK%paq#h z#>h-yp!kRjVrKG?o0%UpX1yW zas{=6WO%=ZX89_h3Hb$xMv%PxkU%pvKt`)TH5ag9zYcwdp&V<&b{Q#x5*)zG6*P#T ztfAP=G}JIw7R%p;=7mT|;0H2|hWx&OM22iwn3sfeWgExPFhs7gVRl6zT0xbd4qgPP zQDagwT7wQXTQyn}VbvM7pgKZp#tAd7)vF0DNtj5z6^(otlqRwsvefxRL>64xFt02N zB#sAzK}}Gv;l*lPYqeT&LWk>gYKTxv^#PdaT9bH9-;+Yt05GV!a$aZ;e=Yz7Z%PkIPd{K2*?t|YGYXFC5no{?@H_U z$Iz1Os)HIuY`ZI3a@Pw0F9i}`D>A@U2PLYaiV0p`<|Qxx4|c?kW7Y_yLj<(Ui*BCx zMFUk5WkDSdB`_9r(=IN+@ET5`4IRb#>1u!rf$Fd{iXsaGl1v8}Q0TN_P*n}bu_Viw zOj?7*tkwg)L0v@{V5cW&wb^3vm}nLljI23&-^nwzN)V&>+5dTer^vxaMEmZaCl(~q z!TWfT;#ufry^_M=R3ZyF3C62F@+iu{?#Rr?q2cTyX+}wK8^$P+1uPcX=I+}wi?l&6 zfTaHt?nRiyd*mQ30(&*|;=N=P4)w>C*SKg3{&y?GXMcIQQ8+9I$~0Do;38JZKme96 z5!R_e?WOk-B(AB@X?I)B^*#A%(Gq)F&*h1Z?zi_Pjf|#^6gjszbEnYuLsxR+4-bzf z9#0$iaMe&{4Nz@+>75c)Ma%CQUDL0sZVgTDm^gFZm1H@7{le_e=BdWhEorldf9Ps@ z{+U5+YgfiZd5^2k{cJaW#rQ@`$L)y)FK7Jvxyx^UwW4haGwIDArKT77<_(4Da>vri zPabuw`@(%XZ&}@MFTS>RXZnidrDWpGJtqx=%iqmiU7496T%h*^+lh|{F5Wni-ig@9 zO-J&mvdT7l>H}wQw6}UTVB68Y^_#?2aQ(ow++Rj^&vkyj?&kguGABMx-j_Od+cq{f zSe2EyvZ%w*Jk@{Fzc>H&&c-!8=@+wIujt&W&i=I@J-l*j<73%Z>l!@0U#_Yvs?S(m zeQxHD?|<4@JKtZTAJ?~@;tqa$=%Kmzqr)Hcp0#|_W-NJR&UxUw6AMk}4b8q=vomt} zz#Y|^tJ6=PX?t&c;m7!_Q|ohT=M%1_mM_eBvilm_=7%?e%wtD7W>b#tz4Suw=C`_( PA5NjG*m>;n%H}@-l0#Wd literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/betterend/textures/item/creeping_moss.png b/src/main/resources/assets/betterend/textures/item/creeping_moss.png new file mode 100644 index 0000000000000000000000000000000000000000..f6beba84cfd4ce0c4bebc8bca58fef8b0185a156 GIT binary patch literal 2359 zcmcguX-pJn7+z1VN-&~$I~^<)b#`WU_L|YHS$0tfEayfMZFP2LmL1*QS$76lAZaUF z(qfSaQqQPF8fdhNN3@D4v>r*d+KNXiDK^%4#2TSit?{7WEX$U*SdBlr$;^B+^L)?y zyzl$W_w6ScX>*2!j}2ES6vL8}%vs&|JW2CKg(6~vd<;-*+&o&L z7+T9)bEF(gD#ZvcCCv&pPU&-b09v7#Im_pvnWdZr*|GysZvjeR2Z&9F&&B%2!>ObmLf?hyhq{%HzYIC zHX&a!z(8qF3NBBO)-49g1PX@wXb*}jF*zkakY$26Prldb56&_u=j2?RTM_{l4`M-; zES4a=Us{(dh!&;90-z|6Tfb=0TIAu-EKU^iy$qLF03ycr3iCJwNe~^v3-SoQ4rb$_ zOkR$b1g}*PoV|_8=w*RSCb=XMk0h3PUgwAuy|opfoB9 z*G|I-3d4G!7GMRImgqiU9N=*)hEV{fBL4;!Sl(XrQYgz%cERhSL7{jToyVabcb-3* z#X=>!MTvGZT(a2!1F1@$XMrM;)az_GqSnzGM5|M?h|Q*E5WR}U?Rpi?sn{O1V7^&k z^5rJV^LzZv3Jl-~mX6YCHCnsfP9ru#gCQD1Z9_;F*iFx|HXUInw02C>t0vvcgHMWf z_GOh-v4D|fv|3!P*C7N)s1X~c1}6fe5uILd*U~Jf*04Gl`YWzUa0*_Fz=E0+vZ4LP zqLO$KbgwAziDYxj0wX66`MpHZjBIxU%*cJ_SUB*Q@25_$rl^Ou(7^%H|7d;>Ocd-= zA?@Xid7!4R;xF_?`bE0nCF%(b(-RsNVHpyvFNB&z^q|*>iq_~Dj3hLq4)4vrkNW=I z_?qei#bq3{JC6e^C^~DTeeQyw;o{{k7O2G z+Ad6R&#blR20dD$i99ZqHx3^5NB{NG4f2|!SLSJcI6r9QlU+NO zEZY41gl*5^fj-}j*gD7i&0!^b%6_Xy8^oBBd#kJ5b=y{La?}sZPciOW@x1oS^@r{& zHs&Pr+s59<7vk~FM`M=X%{tv_oDdRy!f|