Mosses, fixes
This commit is contained in:
parent
4eb7105e33
commit
72b173a9e3
28 changed files with 354 additions and 53 deletions
30
src/main/java/ru/betterend/blocks/BlockGlowingMoss.java
Normal file
30
src/main/java/ru/betterend/blocks/BlockGlowingMoss.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
package ru.betterend.blocks;
|
|
||||||
|
|
||||||
import ru.betterend.blocks.basis.BlockPlant;
|
|
||||||
|
|
||||||
public class BlockUmbrellaMoss extends BlockPlant {
|
|
||||||
public BlockUmbrellaMoss() {
|
|
||||||
super(12);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,23 +2,15 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
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.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import ru.betterend.blocks.basis.BlockDoublePlant;
|
import ru.betterend.blocks.basis.BlockDoublePlant;
|
||||||
import ru.betterend.registry.BlockRegistry;
|
import ru.betterend.registry.BlockRegistry;
|
||||||
import ru.betterend.util.BlocksHelper;
|
|
||||||
|
|
||||||
public class BlockUmbrellaMossTall extends BlockDoublePlant {
|
public class BlockUmbrellaMossTall extends BlockDoublePlant {
|
||||||
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3);
|
|
||||||
|
|
||||||
public BlockUmbrellaMossTall() {
|
public BlockUmbrellaMossTall() {
|
||||||
super(12);
|
super(12);
|
||||||
}
|
}
|
||||||
|
@ -30,15 +22,7 @@ public class BlockUmbrellaMossTall extends BlockDoublePlant {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
int rot = world.random.nextInt(4);
|
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
|
||||||
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<Block, BlockState> stateManager) {
|
|
||||||
super.appendProperties(stateManager);
|
|
||||||
stateManager.add(ROTATION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
|
import net.minecraft.state.property.IntProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
@ -40,6 +41,7 @@ import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
|
public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
|
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 static final BooleanProperty TOP = BooleanProperty.of("top");
|
||||||
|
|
||||||
public BlockDoublePlant() {
|
public BlockDoublePlant() {
|
||||||
|
@ -63,7 +65,7 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(TOP);
|
stateManager.add(TOP, ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,15 +83,19 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.down());
|
||||||
BlockState up = world.getBlockState(pos.up());
|
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) {
|
public boolean canStayAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.down());
|
||||||
BlockState up = world.getBlockState(pos.up());
|
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
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canStayAt(state, world, pos)) {
|
if (!canStayAt(state, world, pos)) {
|
||||||
|
@ -138,6 +144,9 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,11 @@ public class BlockPlant extends BlockBaseNotFull implements IRenderTypeable, Fer
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
BlockState down = world.getBlockState(pos.down());
|
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
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package ru.betterend.recipe;
|
||||||
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
|
||||||
import ru.betterend.registry.ItemRegistry;
|
import ru.betterend.registry.ItemRegistry;
|
||||||
|
|
||||||
public class AlloyingRecipes {
|
public class AlloyingRecipes {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import ru.betterend.registry.BlockRegistry;
|
import ru.betterend.registry.BlockRegistry;
|
||||||
|
|
||||||
public class CraftingRecipes {
|
public class CraftingRecipes {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import net.minecraft.util.registry.RegistryKey;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.Biome.Category;
|
import net.minecraft.world.biome.Biome.Category;
|
||||||
import net.minecraft.world.biome.BiomeKeys;
|
import net.minecraft.world.biome.BiomeKeys;
|
||||||
|
|
||||||
import ru.betterend.world.biome.BiomeFoggyMushroomland;
|
import ru.betterend.world.biome.BiomeFoggyMushroomland;
|
||||||
import ru.betterend.world.biome.EndBiome;
|
import ru.betterend.world.biome.EndBiome;
|
||||||
import ru.betterend.world.generator.BiomePicker;
|
import ru.betterend.world.generator.BiomePicker;
|
||||||
|
|
|
@ -8,13 +8,13 @@ import net.minecraft.util.registry.Registry;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.AeterniumBlock;
|
import ru.betterend.blocks.AeterniumBlock;
|
||||||
import ru.betterend.blocks.BlockEndstoneDust;
|
import ru.betterend.blocks.BlockEndstoneDust;
|
||||||
|
import ru.betterend.blocks.BlockGlowingMoss;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomFur;
|
import ru.betterend.blocks.BlockMossyGlowshroomFur;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
||||||
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
||||||
import ru.betterend.blocks.BlockOre;
|
import ru.betterend.blocks.BlockOre;
|
||||||
import ru.betterend.blocks.BlockTerrain;
|
import ru.betterend.blocks.BlockTerrain;
|
||||||
import ru.betterend.blocks.BlockUmbrellaMoss;
|
|
||||||
import ru.betterend.blocks.BlockUmbrellaMossTall;
|
import ru.betterend.blocks.BlockUmbrellaMossTall;
|
||||||
import ru.betterend.blocks.EndStoneSmelter;
|
import ru.betterend.blocks.EndStoneSmelter;
|
||||||
import ru.betterend.blocks.EnderBlock;
|
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);
|
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
|
||||||
|
|
||||||
// Small Plants //
|
// 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 UMBRELLA_MOSS_TALL = registerBlock("umbrella_moss_tall", new BlockUmbrellaMossTall());
|
||||||
|
public static final Block CREEPING_MOSS = registerBlock("creeping_moss", new BlockGlowingMoss(10));
|
||||||
|
|
||||||
// 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));
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package ru.betterend.registry;
|
package ru.betterend.registry;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.tag.Tag;
|
import net.minecraft.tag.Tag;
|
||||||
import net.minecraft.tag.Tag.Identified;
|
import net.minecraft.tag.Tag.Identified;
|
||||||
|
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.util.TagHelper;
|
import ru.betterend.util.TagHelper;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
package ru.betterend.registry;
|
package ru.betterend.registry;
|
||||||
|
|
||||||
|
import ru.betterend.world.features.DoublePlantFeature;
|
||||||
import ru.betterend.world.features.EndFeature;
|
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;
|
||||||
|
|
||||||
public class FeatureRegistry {
|
public class FeatureRegistry {
|
||||||
|
// Trees //
|
||||||
public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 1);
|
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);
|
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 final EndFeature ENDER_ORE = EndFeature.makeOreFeature("ender_ore", BlockRegistry.ENDER_ORE, 6, 3, 0, 4, 96);
|
||||||
|
|
||||||
public static void register() {}
|
public static void register() {}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
|
|
||||||
public class ItemRegistry {
|
public class ItemRegistry {
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package ru.betterend.tab;
|
package ru.betterend.tab;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
|
import ru.betterend.registry.BlockRegistry;
|
||||||
import ru.betterend.registry.ItemRegistry;
|
import ru.betterend.registry.ItemRegistry;
|
||||||
|
|
||||||
public class CreativeTab {
|
public class CreativeTab {
|
||||||
public static final ItemGroup END_TAB = FabricItemGroupBuilder.create(new Identifier(BetterEnd.MOD_ID, "items"))
|
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()) {
|
for (Item i : ItemRegistry.getModBlocks()) {
|
||||||
stacks.add(new ItemStack(i));
|
stacks.add(new ItemStack(i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ public class BiomeFoggyMushroomland extends EndBiome {
|
||||||
.setSurface(BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM)
|
.setSurface(BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM)
|
||||||
.addFeature(FeatureRegistry.ENDER_ORE)
|
.addFeature(FeatureRegistry.ENDER_ORE)
|
||||||
.addFeature(FeatureRegistry.END_LAKE)
|
.addFeature(FeatureRegistry.END_LAKE)
|
||||||
.addFeature(FeatureRegistry.MOSSY_GLOWSHROOM));
|
.addFeature(FeatureRegistry.MOSSY_GLOWSHROOM)
|
||||||
|
.addFeature(FeatureRegistry.UMBRELLA_MOSS)
|
||||||
|
.addFeature(FeatureRegistry.CREEPING_MOSS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public abstract class DefaultFeature extends Feature<DefaultFeatureConfig> {
|
||||||
super(DefaultFeatureConfig.CODEC);
|
super(DefaultFeatureConfig.CODEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BlockPos getTopPos(StructureWorldAccess world, BlockPos pos) {
|
protected BlockPos getPosOnSurface(StructureWorldAccess world, BlockPos pos) {
|
||||||
return world.getTopPosition(Type.WORLD_SURFACE, pos);
|
return world.getTopPosition(Type.WORLD_SURFACE, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,24 +27,24 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
int dist = MHelper.floor(radius);
|
int dist = MHelper.floor(radius);
|
||||||
int dist2 = MHelper.floor(radius * 1.5);
|
int dist2 = MHelper.floor(radius * 1.5);
|
||||||
int bott = MHelper.floor(depth);
|
int bott = MHelper.floor(depth);
|
||||||
blockPos = getTopPos(world, blockPos);
|
blockPos = getPosOnSurface(world, blockPos);
|
||||||
if (blockPos.getY() < 10) return false;
|
if (blockPos.getY() < 10) return false;
|
||||||
|
|
||||||
int waterLevel = blockPos.getY();
|
int waterLevel = blockPos.getY();
|
||||||
|
|
||||||
BlockPos pos = getTopPos(world, blockPos.north(dist));
|
BlockPos pos = getPosOnSurface(world, blockPos.north(dist));
|
||||||
if (pos.getY() < 10) return false;
|
if (pos.getY() < 10) return false;
|
||||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||||
|
|
||||||
pos = getTopPos(world, blockPos.south(dist));
|
pos = getPosOnSurface(world, blockPos.south(dist));
|
||||||
if (pos.getY() < 10) return false;
|
if (pos.getY() < 10) return false;
|
||||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||||
|
|
||||||
pos = getTopPos(world, blockPos.east(dist));
|
pos = getPosOnSurface(world, blockPos.east(dist));
|
||||||
if (pos.getY() < 10) return false;
|
if (pos.getY() < 10) return false;
|
||||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||||
|
|
||||||
pos = getTopPos(world, blockPos.west(dist));
|
pos = getPosOnSurface(world, blockPos.west(dist));
|
||||||
if (pos.getY() < 10) return false;
|
if (pos.getY() < 10) return false;
|
||||||
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
waterLevel = MHelper.min(pos.getY(), waterLevel);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
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) {
|
if (blockPos.getY() < 5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
|
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
|
||||||
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
|
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
|
||||||
|
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
|
|
|
@ -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 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,5 +38,6 @@
|
||||||
"block.betterend.mossy_glowshroom_trapdoor": "Mossy Glowshroom Trapdoor",
|
"block.betterend.mossy_glowshroom_trapdoor": "Mossy Glowshroom Trapdoor",
|
||||||
|
|
||||||
"block.betterend.umbrella_moss": "Umbrella Moss",
|
"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"
|
||||||
}
|
}
|
|
@ -38,5 +38,6 @@
|
||||||
"block.betterend.mossy_glowshroom_trapdoor": "Люк из мшистого светогриба",
|
"block.betterend.mossy_glowshroom_trapdoor": "Люк из мшистого светогриба",
|
||||||
|
|
||||||
"block.betterend.umbrella_moss": "Зонтичный мох",
|
"block.betterend.umbrella_moss": "Зонтичный мох",
|
||||||
"block.betterend.umbrella_moss_tall": "Высокий зонтичный мох"
|
"block.betterend.umbrella_moss_tall": "Высокий зонтичный мох",
|
||||||
|
"block.betterend.creeping_moss": "Стелющийся мох"
|
||||||
}
|
}
|
|
@ -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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "betterend:item/creeping_moss"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue