Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/net/superkat/tidal/config/TidalConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class TidalConfig extends MidnightConfig {
@Comment(category = WAVES, centered = true) public static Comment reloadReminder;
@Entry(category = WAVES, isSlider = true, min = 3, max = 16) public static int chunkRadius = 5;
@Entry(category = WAVES, min = 1, max = 1024) public static int chunkUpdatesRescanAmount = 50;
@Entry(category = WAVES) public static boolean waveEmissionAtNight = false;

@Entry(category = WAVES) public static boolean debug = false;
@Comment(category = WAVES, centered = true) public static Comment debugDocs;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/superkat/tidal/wave/TidalWaveHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import net.minecraft.client.world.ClientWorld;
import net.minecraft.fluid.FluidState;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.tag.BiomeTags;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
Expand All @@ -37,6 +39,7 @@
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.Locale;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -160,6 +163,7 @@ public void spawnWaves(Set<BlockPos> waterBlocks) {
BlockPos beneath = spawnPos.add(0, -1, 0);
if (world.isAir(beneath) || !world.getBlockState(beneath).getFluidState().isStill()) continue;

if (!biomeNameAllowsTides(spawnPos)) continue;
if (world.getBiome(spawnPos).isIn(BiomeTags.IS_RIVER)) bigWave = false;

Wave wave = new Wave(this.world, spawnPos, yaw, yOffset, bigWave);
Expand All @@ -169,6 +173,18 @@ public void spawnWaves(Set<BlockPos> waterBlocks) {
}
}

private boolean biomeNameAllowsTides(BlockPos pos) {
return this.world.getBiome(pos)
.getKey()
.map(RegistryKey::getValue)
.map(Identifier::getPath)
.map(path -> {
String biomeName = path.toLowerCase(Locale.ROOT);
return biomeName.contains("beach") || biomeName.contains("ocean") || biomeName.contains("sea");
})
.orElse(false);
}

public Set<BlockPos> findConnected(BlockPos start, float yaw, Set<BlockPos> waterBlocks, Set<BlockPos> ignoreSet) {
int maxLength = 3;
Set<BlockPos> connected = Sets.newHashSet();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/superkat/tidal/wave/Wave.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.LightType;
import net.superkat.tidal.TidalParticles;
import net.superkat.tidal.config.TidalConfig;
import net.superkat.tidal.particles.SprayParticleEffect;
import org.jetbrains.annotations.Range;

Expand Down Expand Up @@ -356,7 +357,7 @@ public int getMaxAge() {

public int getLight() {
//emissive during full moon :)
if (this.world.getMoonPhase() == 0 && this.world.getTimeOfDay() >= 12000)
if (TidalConfig.waveEmissionAtNight && this.world.getMoonPhase() == 0 && this.world.getTimeOfDay() >= 12000)
return LightmapTextureManager.pack(15, 15);
BlockPos pos = this.getBlockPos().add(0, 1, 0);
int blockLight = this.world.getLightLevel(LightType.BLOCK, pos);
Expand Down