diff --git a/src/main/java/ru/betterend/blocks/BlockBlueVineLantern.java b/src/main/java/ru/betterend/blocks/BlockBlueVineLantern.java index c841fe04..2fb9db2e 100644 --- a/src/main/java/ru/betterend/blocks/BlockBlueVineLantern.java +++ b/src/main/java/ru/betterend/blocks/BlockBlueVineLantern.java @@ -12,7 +12,9 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.WorldAccess; +import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBase; +import ru.betterend.registry.BlockRegistry; public class BlockBlueVineLantern extends BlockBase { public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); @@ -22,9 +24,14 @@ public class BlockBlueVineLantern extends BlockBase { this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false)); } + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == BlockRegistry.BLUE_VINE : true; + } + @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - if (state.get(NATURAL) && world.isAir(pos.down())) { + if (!canPlaceAt(state, world, pos)) { return Blocks.AIR.getDefaultState(); } else { diff --git a/src/main/java/ru/betterend/blocks/BlockBlueVineSeed.java b/src/main/java/ru/betterend/blocks/BlockBlueVineSeed.java index de7dc262..0674d716 100644 --- a/src/main/java/ru/betterend/blocks/BlockBlueVineSeed.java +++ b/src/main/java/ru/betterend/blocks/BlockBlueVineSeed.java @@ -2,18 +2,19 @@ package ru.betterend.blocks; import java.util.Random; -import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.world.StructureWorldAccess; import ru.betterend.blocks.BlockProperties.TripleShape; -import ru.betterend.blocks.basis.BlockPlantWithStages; +import ru.betterend.blocks.basis.BlockGlowingFur; +import ru.betterend.blocks.basis.BlockPlantWithAge; import ru.betterend.registry.BlockRegistry; import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; -public class BlockBlueVineSeed extends BlockPlantWithStages { +public class BlockBlueVineSeed extends BlockPlantWithAge { @Override - public void grow(ServerWorld world, Random random, BlockPos pos) { + public void grow(StructureWorldAccess world, Random random, BlockPos pos) { int height = MHelper.randRange(2, 5, random); int h = BlocksHelper.upRay(world, pos, height + 2); if (h < height + 1) { @@ -27,7 +28,7 @@ public class BlockBlueVineSeed extends BlockPlantWithStages { placeLantern(world, pos.up(height + 1)); } - private void placeLantern(ServerWorld world, BlockPos pos) { + private void placeLantern(StructureWorldAccess world, BlockPos pos) { BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.BLUE_VINE_LANTERN.getDefaultState().with(BlockBlueVineLantern.NATURAL, true)); for (Direction dir: BlocksHelper.HORIZONTAL) { BlockPos p = pos.offset(dir); diff --git a/src/main/java/ru/betterend/blocks/BlockGlowingFur.java b/src/main/java/ru/betterend/blocks/basis/BlockGlowingFur.java similarity index 92% rename from src/main/java/ru/betterend/blocks/BlockGlowingFur.java rename to src/main/java/ru/betterend/blocks/basis/BlockGlowingFur.java index 84e72ee8..dc6f3dac 100644 --- a/src/main/java/ru/betterend/blocks/BlockGlowingFur.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockGlowingFur.java @@ -1,4 +1,4 @@ -package ru.betterend.blocks; +package ru.betterend.blocks.basis; import java.util.EnumMap; import java.util.List; @@ -15,6 +15,7 @@ import net.minecraft.block.Material; import net.minecraft.block.ShapeContext; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; +import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; import net.minecraft.loot.context.LootContext; @@ -30,24 +31,24 @@ 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; -import ru.betterend.registry.BlockRegistry; import ru.betterend.util.MHelper; public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable { private static final EnumMap BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); public static final DirectionProperty FACING = Properties.FACING; + private final ItemConvertible drop; private final int dropChance; - public BlockGlowingFur(int dropChance) { + public BlockGlowingFur(ItemConvertible drop, int dropChance) { super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT) .breakByTool(FabricToolTags.SHEARS) .sounds(BlockSoundGroup.WET_GRASS) .lightLevel(15) .breakByHand(true) .noCollision()); + this.drop = drop; this.dropChance = dropChance; } @@ -102,7 +103,7 @@ public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable return Lists.newArrayList(new ItemStack(this)); } else if (MHelper.RANDOM.nextInt(dropChance) == 0) { - return Lists.newArrayList(new ItemStack(BlockRegistry.MOSSY_GLOWSHROOM_SAPLING)); + return Lists.newArrayList(new ItemStack(drop)); } else { return Lists.newArrayList(); diff --git a/src/main/java/ru/betterend/blocks/basis/BlockPlantWithStages.java b/src/main/java/ru/betterend/blocks/basis/BlockPlantWithAge.java similarity index 77% rename from src/main/java/ru/betterend/blocks/basis/BlockPlantWithStages.java rename to src/main/java/ru/betterend/blocks/basis/BlockPlantWithAge.java index 7829eb7e..7aca0f55 100644 --- a/src/main/java/ru/betterend/blocks/basis/BlockPlantWithStages.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockPlantWithAge.java @@ -8,8 +8,9 @@ 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.StructureWorldAccess; -public abstract class BlockPlantWithStages extends BlockPlant { +public abstract class BlockPlantWithAge extends BlockPlant { public static final IntProperty AGE = IntProperty.of("age", 0, 4); @Override @@ -17,7 +18,7 @@ public abstract class BlockPlantWithStages extends BlockPlant { stateManager.add(AGE); } - public abstract void grow(ServerWorld world, Random random, BlockPos pos); + public abstract void grow(StructureWorldAccess world, Random random, BlockPos pos); @Override public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { diff --git a/src/main/java/ru/betterend/blocks/basis/BlockUpDownPlant.java b/src/main/java/ru/betterend/blocks/basis/BlockUpDownPlant.java index 6eb2e13b..978cd889 100644 --- a/src/main/java/ru/betterend/blocks/basis/BlockUpDownPlant.java +++ b/src/main/java/ru/betterend/blocks/basis/BlockUpDownPlant.java @@ -1,27 +1,29 @@ package ru.betterend.blocks.basis; import java.util.List; + import com.google.common.collect.Lists; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.minecraft.block.AbstractBlock; 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.block.entity.BlockEntity; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.player.PlayerEntity; 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.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; +import net.minecraft.world.World; import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldView; import ru.betterend.client.ERenderLayer; @@ -41,24 +43,23 @@ public class BlockUpDownPlant extends BlockBaseNotFull implements IRenderTypeabl @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { - Vec3d vec3d = state.getModelOffset(view, pos); - return SHAPE.offset(vec3d.x, vec3d.y, vec3d.z); - } - - @Override - public AbstractBlock.OffsetType getOffsetType() { - return AbstractBlock.OffsetType.XZ; + return SHAPE; } @Override public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { BlockState down = world.getBlockState(pos.down()); - return isTerrain(down); + BlockState up = world.getBlockState(pos.up()); + return (isTerrain(down) || down.getBlock() == this) && (isSupport(up, world, pos) || up.getBlock() == this); } protected boolean isTerrain(BlockState state) { return state.isIn(BlockTagRegistry.END_GROUND); } + + protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) { + return sideCoversSmallSquare(world, pos.up(), Direction.UP); + } @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { @@ -85,4 +86,10 @@ public class BlockUpDownPlant extends BlockBaseNotFull implements IRenderTypeabl public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; } + + @Override + public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack stack) { + super.afterBreak(world, player, pos, state, blockEntity, stack); + world.updateNeighbor(pos, Blocks.AIR, pos.down()); + } } diff --git a/src/main/java/ru/betterend/item/EndAxe.java b/src/main/java/ru/betterend/item/EndAxe.java index cf1b6ae4..1965e5b6 100644 --- a/src/main/java/ru/betterend/item/EndAxe.java +++ b/src/main/java/ru/betterend/item/EndAxe.java @@ -1,7 +1,6 @@ package ru.betterend.item; import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; - import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; import net.minecraft.item.AxeItem; diff --git a/src/main/java/ru/betterend/item/EndHammer.java b/src/main/java/ru/betterend/item/EndHammer.java index 20a1aa76..8bf84b0f 100644 --- a/src/main/java/ru/betterend/item/EndHammer.java +++ b/src/main/java/ru/betterend/item/EndHammer.java @@ -8,10 +8,8 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import io.netty.util.internal.ThreadLocalRandom; - import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; import net.fabricmc.fabric.api.tool.attribute.v1.ToolManager; - import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.entity.EquipmentSlot; diff --git a/src/main/java/ru/betterend/mixin/common/ChunkGeneratorMixin.java b/src/main/java/ru/betterend/mixin/common/ChunkGeneratorMixin.java new file mode 100644 index 00000000..ee1f54c9 --- /dev/null +++ b/src/main/java/ru/betterend/mixin/common/ChunkGeneratorMixin.java @@ -0,0 +1,17 @@ +package ru.betterend.mixin.common; + +import org.spongepowered.asm.mixin.Mixin; + +import net.minecraft.world.gen.chunk.ChunkGenerator; + +@Mixin(ChunkGenerator.class) +public class ChunkGeneratorMixin { + /*@Inject(method = "generateFeatures", at = @At("RETURN")) + private void fixerPass(ChunkRegion region, StructureAccessor accessor, CallbackInfo info) { + int chunkX = region.getCenterChunkX(); + int chunkZ = region.getCenterChunkZ(); + BlockPos start = new BlockPos(chunkX << 4, 16, chunkZ << 4); + BlockPos end = start.add(15, 64, 15); + BlocksHelper.fixBlocks(region, start, end); + }*/ +} diff --git a/src/main/java/ru/betterend/mixin/common/TagAccessor.java b/src/main/java/ru/betterend/mixin/common/TagAccessor.java deleted file mode 100644 index 7a59df45..00000000 --- a/src/main/java/ru/betterend/mixin/common/TagAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package ru.betterend.mixin.common; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.tag.Tag; - -@Deprecated -@Mixin(targets = "net.minecraft.tag.RequiredTagList$TagWrapper") -public interface TagAccessor { - @Accessor - Tag getDelegate(); -} diff --git a/src/main/java/ru/betterend/registry/BlockRegistry.java b/src/main/java/ru/betterend/registry/BlockRegistry.java index aaa277c7..c52c581e 100644 --- a/src/main/java/ru/betterend/registry/BlockRegistry.java +++ b/src/main/java/ru/betterend/registry/BlockRegistry.java @@ -13,7 +13,6 @@ import ru.betterend.blocks.BlockBlueVineSeed; import ru.betterend.blocks.BlockEndstoneDust; import ru.betterend.blocks.BlockGlowingMoss; import ru.betterend.blocks.BlockMossyGlowshroomCap; -import ru.betterend.blocks.BlockGlowingFur; import ru.betterend.blocks.BlockMossyGlowshroomHymenophore; import ru.betterend.blocks.BlockMossyGlowshroomSapling; import ru.betterend.blocks.BlockOre; @@ -24,7 +23,7 @@ import ru.betterend.blocks.BlockUmbrellaMossTall; import ru.betterend.blocks.EndStoneSmelter; import ru.betterend.blocks.EnderBlock; import ru.betterend.blocks.TerminiteBlock; -import ru.betterend.blocks.basis.BlockUpDownPlant; +import ru.betterend.blocks.basis.BlockGlowingFur; import ru.betterend.blocks.complex.WoodenMaterial; import ru.betterend.tab.CreativeTab; @@ -42,7 +41,7 @@ public class BlockRegistry { public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling()); 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 BlockGlowingFur(16)); + public static final Block MOSSY_GLOWSHROOM_FUR = registerBlock("mossy_glowshroom_fur", new BlockGlowingFur(MOSSY_GLOWSHROOM_SAPLING, 16)); public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD); // Small Plants // @@ -53,7 +52,7 @@ public class BlockRegistry { public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlockBlueVineSeed()); public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlockBlueVine()); public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlockBlueVineLantern()); - public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(3)); + public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockGlowingFur(BLUE_VINE_SEED, 3)); // 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/FeatureRegistry.java b/src/main/java/ru/betterend/registry/FeatureRegistry.java index dba1c55f..c0ef18ac 100644 --- a/src/main/java/ru/betterend/registry/FeatureRegistry.java +++ b/src/main/java/ru/betterend/registry/FeatureRegistry.java @@ -1,5 +1,6 @@ package ru.betterend.registry; +import ru.betterend.world.features.BlueVineFeature; import ru.betterend.world.features.DoublePlantFeature; import ru.betterend.world.features.EndFeature; import ru.betterend.world.features.EndLakeFeature; @@ -13,6 +14,7 @@ public class FeatureRegistry { // 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); + public static final EndFeature BLUE_VINE = new EndFeature("blue_vine", new BlueVineFeature(), 1); // Features // public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4); diff --git a/src/main/java/ru/betterend/util/BlocksHelper.java b/src/main/java/ru/betterend/util/BlocksHelper.java index e16aa6c8..e45dbd7e 100644 --- a/src/main/java/ru/betterend/util/BlocksHelper.java +++ b/src/main/java/ru/betterend/util/BlocksHelper.java @@ -6,14 +6,18 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.block.Blocks; import net.minecraft.state.property.Property; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3i; import net.minecraft.world.WorldAccess; +import ru.betterend.blocks.BlockBlueVine; +import ru.betterend.blocks.basis.BlockDoublePlant; +import ru.betterend.blocks.basis.BlockGlowingFur; public class BlocksHelper { public static final int FLAG_UPDATE_BLOCK = 1; @@ -24,6 +28,9 @@ public class BlocksHelper { public static final int SET_SILENT = FLAG_UPDATE_BLOCK | FLAG_IGNORE_OBSERVERS | FLAG_SEND_CLIENT_CHANGES; public static final Direction[] HORIZONTAL = new Direction[] { Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST }; + + private static final Mutable POS = new Mutable(); + protected static final BlockState AIR = Blocks.AIR.getDefaultState(); private static final Vec3i[] OFFSETS = new Vec3i[] { new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1), @@ -69,7 +76,7 @@ public class BlocksHelper { return state.rotate(mirror.getRotation((Direction) state.get(facing))); } - public static int getLengthDown(ServerWorld world, BlockPos pos, Block block) { + public static int getLengthDown(WorldAccess world, BlockPos pos, Block block) { int count = 1; while (world.getBlockState(pos.down(count)).getBlock() == block) count++; @@ -105,4 +112,47 @@ public class BlocksHelper { } } } + + public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) { + synchronized (world) { + BlockState state; + for (int x = start.getX(); x <= end.getX(); x++) { + POS.setX(x); + for (int z = start.getZ(); z <= end.getZ(); z++) { + POS.setZ(z); + for (int y = start.getY(); y <= end.getY(); y++) { + POS.setY(y); + state = world.getBlockState(POS); + if (!state.canPlaceAt(world, POS)) { + // Is blue Vine + if (state.getBlock() instanceof BlockBlueVine) { + while (!state.canPlaceAt(world, POS)) { + BlocksHelper.setWithoutUpdate(world, POS, AIR); + for (Direction dir : HORIZONTAL) { + BlockPos p = POS.offset(dir).up(); + state = world.getBlockState(p); + if (state.getBlock() instanceof BlockGlowingFur) { + BlocksHelper.setWithoutUpdate(world, p, AIR); + } + } + POS.setY(POS.getY() + 1); + state = world.getBlockState(POS); + } + } + // Double plants + if (state.getBlock() instanceof BlockDoublePlant) { + BlocksHelper.setWithoutUpdate(world, POS, AIR); + POS.setY(POS.getY() + 1); + BlocksHelper.setWithoutUpdate(world, POS, AIR); + } + // Common plants & blocks + else { + BlocksHelper.setWithoutUpdate(world, POS, AIR); + } + } + } + } + } + } + } } diff --git a/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java b/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java index fefd4f98..2fc5a825 100644 --- a/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java +++ b/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java @@ -16,6 +16,7 @@ public class BiomeFoggyMushroomland extends EndBiome { .addFeature(FeatureRegistry.ENDER_ORE) .addFeature(FeatureRegistry.END_LAKE) .addFeature(FeatureRegistry.MOSSY_GLOWSHROOM) + .addFeature(FeatureRegistry.BLUE_VINE) .addFeature(FeatureRegistry.UMBRELLA_MOSS) .addFeature(FeatureRegistry.CREEPING_MOSS)); } diff --git a/src/main/java/ru/betterend/world/features/BlueVineFeature.java b/src/main/java/ru/betterend/world/features/BlueVineFeature.java new file mode 100644 index 00000000..71491db3 --- /dev/null +++ b/src/main/java/ru/betterend/world/features/BlueVineFeature.java @@ -0,0 +1,36 @@ +package ru.betterend.world.features; + +import java.util.Random; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.StructureWorldAccess; +import ru.betterend.blocks.basis.BlockPlantWithAge; +import ru.betterend.registry.BlockRegistry; +import ru.betterend.util.BlocksHelper; +import ru.betterend.util.MHelper; + +public class BlueVineFeature extends ScatterFeature { + private boolean small; + + public BlueVineFeature() { + super(5); + } + + @Override + public boolean canGenerate(StructureWorldAccess world, Random random, BlockPos center, BlockPos blockPos, float radius) { + float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F; + small = d > 0.5F; + return BlockRegistry.BLUE_VINE_SEED.canPlaceAt(AIR, world, blockPos); + } + + @Override + public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) { + if (small) { + BlocksHelper.setWithoutUpdate(world, blockPos, BlockRegistry.BLUE_VINE_SEED.getDefaultState().with(BlockPlantWithAge.AGE, random.nextInt(4))); + } + else { + BlockPlantWithAge seed = ((BlockPlantWithAge) BlockRegistry.BLUE_VINE_SEED); + seed.grow(world, random, blockPos); + } + } +} diff --git a/src/main/java/ru/betterend/world/features/EndFeature.java b/src/main/java/ru/betterend/world/features/EndFeature.java index 06449053..4cde028a 100644 --- a/src/main/java/ru/betterend/world/features/EndFeature.java +++ b/src/main/java/ru/betterend/world/features/EndFeature.java @@ -6,6 +6,7 @@ import net.minecraft.structure.rule.BlockMatchRuleTest; import net.minecraft.util.Identifier; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; +import net.minecraft.world.gen.CountConfig; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.decorator.ChanceDecoratorConfig; import net.minecraft.world.gen.decorator.Decorator; @@ -72,6 +73,11 @@ public class EndFeature { return newFeature; } + public static EndFeature makeChunkFeature(String name, Feature feature) { + ConfiguredFeature configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.COUNT.configure(new CountConfig(1))); + return new EndFeature(name, feature, GenerationStep.Feature.LOCAL_MODIFICATIONS, configured); + } + public Feature getFeature() { return feature; } diff --git a/src/main/java/ru/betterend/world/features/EndLakeFeature.java b/src/main/java/ru/betterend/world/features/EndLakeFeature.java index c3ce3ebc..2086c59f 100644 --- a/src/main/java/ru/betterend/world/features/EndLakeFeature.java +++ b/src/main/java/ru/betterend/world/features/EndLakeFeature.java @@ -4,7 +4,6 @@ import java.util.Random; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.block.Material; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.world.StructureWorldAccess; @@ -50,14 +49,19 @@ public class EndLakeFeature extends DefaultFeature { waterLevel = MHelper.min(pos.getY(), waterLevel); BlockState state; + int minX = blockPos.getX() - dist2; + int maxX = blockPos.getX() + dist2; + int minZ = blockPos.getZ() - dist2; + int maxZ = blockPos.getZ() + dist2; + for (int y = blockPos.getY(); y <= blockPos.getY() + 10; y++) { POS.setY(y); int add = y - blockPos.getY(); - for (int x = blockPos.getX() - dist2; x <= blockPos.getX() + dist2; x++) { + for (int x = minX; x <= maxX; x++) { POS.setX(x); int x2 = x - blockPos.getX(); x2 *= x2; - for (int z = blockPos.getZ() - dist2; z <= blockPos.getZ() + dist2; z++) { + for (int z = minZ; z <= maxZ; z++) { POS.setZ(z); int z2 = z - blockPos.getZ(); z2 *= z2; @@ -65,7 +69,7 @@ public class EndLakeFeature extends DefaultFeature { r *= r; if (x2 + z2 <= r) { state = world.getBlockState(POS); - if (state.isIn(BlockTagRegistry.END_GROUND) || !state.canPlaceAt(world, POS) || state.getMaterial().equals(Material.PLANT)/* || state.getBlock() == BlockRegistry.ENDSTONE_DUST*/) { + if (state.isIn(BlockTagRegistry.END_GROUND)) { BlocksHelper.setWithoutUpdate(world, POS, AIR); } pos = POS.down(); @@ -79,11 +83,6 @@ public class EndLakeFeature extends DefaultFeature { else BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.ENDSTONE_DUST.getDefaultState()); } - /*pos = POS.up(); - while (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND) || !state.canPlaceAt(world, pos) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) { - BlocksHelper.setWithoutUpdate(world, pos, AIR); - pos = pos.up(); - }*/ } } } @@ -108,7 +107,7 @@ public class EndLakeFeature extends DefaultFeature { rb *= rb; if (y2 + x2 + z2 <= r) { state = world.getBlockState(POS); - if (state.isIn(BlockTagRegistry.END_GROUND) || !state.canPlaceAt(world, POS) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) { + if (state.isIn(BlockTagRegistry.END_GROUND) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) { BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR); } pos = POS.down(); @@ -139,6 +138,8 @@ public class EndLakeFeature extends DefaultFeature { } } + BlocksHelper.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2)); + return true; } } diff --git a/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java b/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java index 3e31a320..0e8853f5 100644 --- a/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java +++ b/src/main/java/ru/betterend/world/features/MossyGlowshroomFeature.java @@ -17,7 +17,7 @@ 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.BlockGlowingFur; +import ru.betterend.blocks.basis.BlockGlowingFur; import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockTagRegistry; @@ -77,10 +77,6 @@ public class MossyGlowshroomFeature extends DefaultFeature { return BlockRegistry.MOSSY_GLOWSHROOM.log.getDefaultState(); }); Vector3f pos = spline.get(spline.size() - 1); - CENTER.set(blockPos.getX(), 0, blockPos.getZ()); - HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ()); - ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2); - FUNCTION.setSourceA(sdf); float scale = MHelper.randRange(0.75F, 1.1F, random); Vector3f vec = spline.get(0); @@ -112,6 +108,11 @@ public class MossyGlowshroomFeature extends DefaultFeature { } BlocksHelper.setWithoutUpdate(world, blockPos, AIR); + CENTER.set(blockPos.getX(), 0, blockPos.getZ()); + HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ()); + ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2); + FUNCTION.setSourceA(sdf); + Set blocks = new SDFScale() .setScale(scale) .setSource(FUNCTION) @@ -187,7 +188,7 @@ public class MossyGlowshroomFeature extends DefaultFeature { FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT)); REPLACE = (state) -> { - if (state.getBlock() != Blocks.END_STONE && state.isIn(BlockTagRegistry.END_GROUND)) { + if (state.isIn(BlockTagRegistry.END_GROUND)) { return true; } if (state.getMaterial().equals(Material.PLANT)) { diff --git a/src/main/resources/betterend.mixins.common.json b/src/main/resources/betterend.mixins.common.json index 5088161e..0bd577f9 100644 --- a/src/main/resources/betterend.mixins.common.json +++ b/src/main/resources/betterend.mixins.common.json @@ -11,8 +11,7 @@ "CraftingScreenHandlerMixin", "GenerationSettingsMixin", "LivingEntityMixin", - "BiomeMixin", - "TagAccessor" + "BiomeMixin" ], "injectors": { "defaultRequire": 1