diff --git a/src/main/java/ru/betterend/blocks/BlockHydralux.java b/src/main/java/ru/betterend/blocks/BlockHydralux.java index b1405666..cbba5ddb 100644 --- a/src/main/java/ru/betterend/blocks/BlockHydralux.java +++ b/src/main/java/ru/betterend/blocks/BlockHydralux.java @@ -25,6 +25,7 @@ import net.minecraft.world.WorldView; import ru.betterend.blocks.BlockProperties.HydraluxShape; import ru.betterend.blocks.basis.BlockUnderwaterPlant; import ru.betterend.registry.EndBlocks; +import ru.betterend.registry.EndItems; import ru.betterend.util.MHelper; public class BlockHydralux extends BlockUnderwaterPlant { @@ -78,7 +79,10 @@ public class BlockHydralux extends BlockUnderwaterPlant { @Override public List getDroppedStacks(BlockState state, LootContext.Builder builder) { HydraluxShape shape = state.get(SHAPE); - if (shape == HydraluxShape.ROOTS) { + if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) { + return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM))); + } + else if (shape == HydraluxShape.ROOTS) { return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM))); } return Collections.emptyList(); diff --git a/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java b/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java index 1af7533b..8f418e90 100644 --- a/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java +++ b/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java @@ -4,6 +4,8 @@ import java.util.Random; import org.jetbrains.annotations.Nullable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.block.Block; @@ -22,6 +24,7 @@ import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; +import net.minecraft.particle.ParticleTypes; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.state.StateManager; @@ -37,9 +40,11 @@ import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBaseNotFull; import ru.betterend.blocks.entities.BlockEntityHydrothermalVent; import ru.betterend.registry.EndBlocks; +import ru.betterend.registry.EndParticles; public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable { public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; + public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED; private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15); public BlockHydrothermalVent() { @@ -48,12 +53,12 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti .sounds(BlockSoundGroup.STONE) .noCollision() .requiresTool()); - this.setDefaultState(getDefaultState().with(WATERLOGGED, true)); + this.setDefaultState(getDefaultState().with(WATERLOGGED, true).with(ACTIVATED, false)); } @Override protected void appendProperties(StateManager.Builder builder) { - builder.add(WATERLOGGED); + builder.add(WATERLOGGED, ACTIVATED); } @Override @@ -116,4 +121,20 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti scheduledTick(state,(ServerWorld) world, pos, world.random); } } + + @Environment(EnvType.CLIENT) + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + if (!state.get(ACTIVATED) && random.nextBoolean()) { + super.randomDisplayTick(state, world, pos, random); + double x = pos.getX() + random.nextDouble(); + double y = pos.getY() + 0.9 + random.nextDouble() * 0.3; + double z = pos.getZ() + random.nextDouble(); + if (state.get(WATERLOGGED)) { + world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0); + } + else { + world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0); + } + } + } } diff --git a/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java b/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java index b2210495..6508ad28 100644 --- a/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java +++ b/src/main/java/ru/betterend/blocks/entities/BlockEntityHydrothermalVent.java @@ -16,13 +16,13 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable @Override public void tick() { - if (world.random.nextInt(32) == 0) { + if (world.random.nextInt(20) == 0) { double x = pos.getX() + world.random.nextDouble(); double y = pos.getY() + 0.9 + world.random.nextDouble() * 0.3; double z = pos.getZ() + world.random.nextDouble(); BlockState state = getCachedState(); - if (state.isOf(EndBlocks.HYDROTHERMAL_VENT)) { - if (getCachedState().get(BlockHydrothermalVent.WATERLOGGED)) { + if (state.isOf(EndBlocks.HYDROTHERMAL_VENT) && state.get(BlockHydrothermalVent.ACTIVATED)) { + if (state.get(BlockHydrothermalVent.WATERLOGGED)) { world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0); } else { diff --git a/src/main/java/ru/betterend/registry/EndItems.java b/src/main/java/ru/betterend/registry/EndItems.java index d06c933f..79752504 100644 --- a/src/main/java/ru/betterend/registry/EndItems.java +++ b/src/main/java/ru/betterend/registry/EndItems.java @@ -62,6 +62,7 @@ public class EndItems { public final static Item AMBER_GEM = registerItem("amber_gem"); public final static Item GLOWING_BULB = registerItem("glowing_bulb"); public final static Item CRYSTALLINE_SULPHUR = registerItem("crystalline_sulphur"); + public final static Item HYDRALUX_PETAL = registerItem("hydralux_petal"); // Armor // public static final Item TERMINITE_HELMET = registerItem("terminite_helmet", new ArmorItem(EndArmorMaterial.TERMINITE, EquipmentSlot.HEAD, makeSettings())); diff --git a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java index 934c95a2..99115bd0 100644 --- a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; +import ru.betterend.blocks.BlockHydrothermalVent; import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; @@ -150,7 +151,8 @@ public class GeyserFeature extends DefaultFeature { for (int i = 0; i < 150; i++) { mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5)); - int dist = MHelper.floor(6 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2); + float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()); + int dist = MHelper.floor(6 - distRaw) + random.nextInt(2); if (dist >= 0) { BlockState state = world.getBlockState(mut); while (state.isOf(Blocks.WATER)) { @@ -162,7 +164,37 @@ public class GeyserFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); mut.setY(mut.getY() + 1); } - BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT); + state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(BlockHydrothermalVent.ACTIVATED, distRaw < 2); + BlocksHelper.setWithoutUpdate(world, mut, state); + mut.setY(mut.getY() + 1); + state = world.getBlockState(mut); + while (state.isOf(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, mut, Blocks.BUBBLE_COLUMN.getDefaultState().with(BubbleColumnBlock.DRAG, false)); + world.getBlockTickScheduler().schedule(mut, Blocks.BUBBLE_COLUMN, MHelper.randRange(8, 32, random)); + mut.setY(mut.getY() + 1); + state = world.getBlockState(mut); + } + } + } + } + + for (int i = 0; i < 10; i++) { + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 0.7 + 0.5)); + float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()); + int dist = MHelper.floor(6 - distRaw) + random.nextInt(2); + if (dist >= 0) { + BlockState state = world.getBlockState(mut); + while (state.isOf(Blocks.WATER)) { + mut.setY(mut.getY() - 1); + state = world.getBlockState(mut); + } + if (state.isIn(EndTags.GEN_TERRAIN)) { + for (int j = 0; j <= dist; j++) { + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); + mut.setY(mut.getY() + 1); + } + state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(BlockHydrothermalVent.ACTIVATED, distRaw < 2); + BlocksHelper.setWithoutUpdate(world, mut, state); mut.setY(mut.getY() + 1); state = world.getBlockState(mut); while (state.isOf(Blocks.WATER)) { diff --git a/src/main/resources/assets/betterend/textures/item/hydralux_petal.png b/src/main/resources/assets/betterend/textures/item/hydralux_petal.png new file mode 100644 index 00000000..3f38d97b Binary files /dev/null and b/src/main/resources/assets/betterend/textures/item/hydralux_petal.png differ