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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'maven-publish'
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
minecraft_version=1.21.6
yarn_mappings=1.21.6+build.1
loader_version=0.16.10

# Mod Properties
mod_version=0.0.2-beta
mod_version=0.0.3-beta
maven_group=net.superkat.tidal
archives_base_name=tidal

# Dependencies
fabric_version=0.115.0+1.21.1
fabric_version=0.128.2+1.21.6
midnightlib_version = 1.6.9+1.21-fabric
modmenu_version=11.0.3
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
53 changes: 20 additions & 33 deletions src/main/java/net/superkat/tidal/TidalClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.superkat.tidal;

import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
Expand All @@ -10,14 +9,8 @@
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.BuiltBuffer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.render.*;
import net.minecraft.resource.ResourceType;
import net.superkat.tidal.duck.TidalWorld;
import net.superkat.tidal.event.ClientBlockUpdateEvent;
Expand Down Expand Up @@ -86,30 +79,24 @@ public void onInitializeClient() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(context -> {
if(context.world() == null) return;
TidalWorld tidalWorld = (TidalWorld) context.world();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT);

tidalWorld.tidal$tidalWaveHandler().render(buffer, context);

BuiltBuffer builtBuffer = buffer.endNullable();
if(builtBuffer == null) return;

LightmapTextureManager lightmapTextureManager = MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager();

lightmapTextureManager.enable();

RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
RenderSystem.setShader(GameRenderer::getRenderTypeTripwireProgram);
RenderSystem.setShaderTexture(0, TidalSpriteHandler.WAVE_ATLAS_ID);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();

BufferRenderer.drawWithGlobalProgram(builtBuffer);

RenderSystem.depthMask(true);
RenderSystem.disableBlend();
lightmapTextureManager.disable();
VertexConsumerProvider vertexConsumers = context.consumers();

RenderLayer waveRenderLayer = RenderLayer.of(
"tidal_waves",
1536,
false,
true,
RenderPipelines.TRANSLUCENT_PARTICLE,
RenderLayer.MultiPhaseParameters.builder()
.texture(new RenderPhase.Texture(TidalSpriteHandler.WAVE_ATLAS_ID, false))
.lightmap(RenderPhase.ENABLE_LIGHTMAP)
.overlay(RenderPhase.DISABLE_OVERLAY_COLOR)
.target(RenderPhase.PARTICLES_TARGET)
.build(false)
);

VertexConsumer vertexConsumer = vertexConsumers.getBuffer(waveRenderLayer);
tidalWorld.tidal$tidalWaveHandler().render(vertexConsumer, context);
});

ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(TIDAL_SPRITE_HANDLER);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/superkat/tidal/mixin/ClientWorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.superkat.tidal.duck.TidalWorld;
import net.superkat.tidal.event.ClientBlockUpdateEvent;
import net.superkat.tidal.wave.TidalWaveHandler;
Expand All @@ -24,7 +26,7 @@ public class ClientWorldMixin implements TidalWorld {
public TidalWaveHandler tidalWaveHandler;

@Inject(method = "<init>", at = @At("TAIL"))
public void tidal$createTidalWaveHandler(ClientPlayNetworkHandler networkHandler, ClientWorld.Properties properties, RegistryKey registryRef, RegistryEntry dimensionTypeEntry, int loadDistance, int simulationDistance, Supplier profiler, WorldRenderer worldRenderer, boolean debugWorld, long seed, CallbackInfo ci) {
public void tidal$createTidalWaveHandler(ClientPlayNetworkHandler networkHandler, ClientWorld.Properties properties, RegistryKey<World> registryRef, RegistryEntry<DimensionType> dimensionType, int loadDistance, int simulationDistance, WorldRenderer worldRenderer, boolean debugWorld, long seed, int seaLevel, CallbackInfo ci) {
this.tidalWaveHandler = new TidalWaveHandler((ClientWorld) (Object) this);
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/superkat/tidal/particles/SprayParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public SprayParticle(ClientWorld world, double x, double y, double z, double vel
this.gravityStrength = 0.5f;

if(spawnWhite()) {
this.world.addParticle(new WhiteSprayParticleEffect(yaw, intensity, this.scale), x, y, z, velX, velY, velZ);
this.world.addParticleClient(new WhiteSprayParticleEffect(yaw, intensity, this.scale), x, y, z, velX, velY, velZ);
this.updateWaterColor(); //only need to update on spawn because it lasts for so little time
}

Expand All @@ -70,14 +70,14 @@ public void tick() {
this.x -= this.velocityX * 8;
this.z -= this.velocityZ * 8f;
for (int i = 0; i < 5; i++) {
this.world.addParticle(TidalParticles.SPLASH_PARTICLE,
this.world.addParticleClient(TidalParticles.SPLASH_PARTICLE,
this.x + this.random.nextGaussian(), this.y + 1,
this.z + this.random.nextGaussian(),
this.random.nextGaussian() * 0.05f,
Math.abs(this.world.random.nextGaussian()) * 0.1f + MathHelper.clamp(intensity, 0.1, 0.3),
this.random.nextGaussian() * 0.05f);

this.world.addParticle(ParticleTypes.BUBBLE,
this.world.addParticleClient(ParticleTypes.BUBBLE,
this.x + this.random.nextGaussian() / 2f, this.y + 1,
this.z + this.random.nextGaussian() / 2f,
this.random.nextGaussian() / 8f,
Expand All @@ -87,7 +87,7 @@ public void tick() {
this.markDead();
}

this.prevAngle = this.angle;
this.lastAngle = this.angle;
if(this.velocityY != 0 && !onGround) {
this.angle = this.angle + (float) this.velocityY * 35f;
} else {
Expand All @@ -98,7 +98,7 @@ public void tick() {
}

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
Quaternionf quaternionf = new Quaternionf();
quaternionf.rotateX((float) Math.toRadians(-90f));
quaternionf.rotateZ((float) Math.toRadians(-90f - this.yaw));
Expand All @@ -110,9 +110,9 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti

protected void render(VertexConsumer vertexConsumer, Camera camera, Quaternionf quaternionf, float tickDelta) {
Vec3d vec3d = camera.getPos();
float x = (float)(MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
float y = (float)(MathHelper.lerp(tickDelta, this.prevPosY, this.y) - vec3d.getY()) + (spawnWhite() ? 0.025f : 0.125f);
float z = (float)(MathHelper.lerp(tickDelta, this.prevPosZ, this.z) - vec3d.getZ());
float x = (float)(MathHelper.lerp(tickDelta, this.lastX, this.x) - vec3d.getX());
float y = (float)(MathHelper.lerp(tickDelta, this.lastY, this.y) - vec3d.getY()) + (spawnWhite() ? 0.025f : 0.125f);
float z = (float)(MathHelper.lerp(tickDelta, this.lastZ, this.z) - vec3d.getZ());
this.quad(vertexConsumer, quaternionf, x, y, z, tickDelta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static class DebugShoreParticleEffect extends AbstractDustParticleEffect
.apply(instance, DebugShoreParticleEffect::new)
);
public static final PacketCodec<RegistryByteBuf, DebugShoreParticleEffect> PACKET_CODEC = PacketCodec.tuple(
PacketCodecs.VECTOR3F, effect -> effect.color, PacketCodecs.FLOAT, AbstractDustParticleEffect::getScale, DebugShoreParticleEffect::new
PacketCodecs.VECTOR_3F, effect -> effect.color, PacketCodecs.FLOAT, AbstractDustParticleEffect::getScale, DebugShoreParticleEffect::new
);
private final Vector3f color;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static class DebugWaterParticleEffect extends AbstractDustParticleEffect
.apply(instance, DebugWaterParticleEffect::new)
);
public static final PacketCodec<RegistryByteBuf, DebugWaterParticleEffect> PACKET_CODEC = PacketCodec.tuple(
PacketCodecs.VECTOR3F, effect -> effect.color, PacketCodecs.FLOAT, AbstractDustParticleEffect::getScale, DebugWaterParticleEffect::new
PacketCodecs.VECTOR_3F, effect -> effect.color, PacketCodecs.FLOAT, AbstractDustParticleEffect::getScale, DebugWaterParticleEffect::new
);
private final Vector3f color;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public DebugWaveMovementParticle(ClientWorld world, double x, double y, double z
}

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
if(lifetimeColorMode) updateColor(tickDelta);
super.buildGeometry(vertexConsumer, camera, tickDelta);
super.render(vertexConsumer, camera, tickDelta);
}

private void updateColor(float tickDelta) {
Expand Down Expand Up @@ -118,7 +118,7 @@ public static class DebugWaveMovementParticleEffect extends AbstractDustParticle
.apply(instance, DebugWaveMovementParticleEffect::new)
);
public static final PacketCodec<RegistryByteBuf, DebugWaveMovementParticleEffect> PACKET_CODEC = PacketCodec.tuple(
PacketCodecs.VECTOR3F, effect -> effect.color,
PacketCodecs.VECTOR_3F, effect -> effect.color,
PacketCodecs.FLOAT, AbstractDustParticleEffect::getScale,
PacketCodecs.FLOAT, DebugWaveMovementParticleEffect::getYaw,
PacketCodecs.FLOAT, DebugWaveMovementParticleEffect::getSpeed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public AbstractWaveParticle(ClientWorld world, double x, double y, double z, dou

for (int i = 0; i < this.positions.size(); i++) {
BlockPos pos = this.positions.get(i);
this.world.addParticle(ParticleTypes.EGG_CRACK, pos.getX(), pos.getY() + 2, pos.getZ(), 0, 0, 0);
this.world.addParticleClient(ParticleTypes.EGG_CRACK, pos.getX(), pos.getY() + 2, pos.getZ(), 0, 0, 0);
Vector3f color = new Vector3f(1f, 1f, 1f);
float yaw = this.yaws.get(i);
DebugWaveMovementParticle.DebugWaveMovementParticleEffect particleEffect = new DebugWaveMovementParticle.DebugWaveMovementParticleEffect(
Expand All @@ -85,7 +85,7 @@ public AbstractWaveParticle(ClientWorld world, double x, double y, double z, dou
0.3f,
20
);
this.world.addParticle(particleEffect, pos.getX(), pos.getY() + 1.5, pos.getZ(), 0, 0, 0);
this.world.addParticleClient(particleEffect, pos.getX(), pos.getY() + 1.5, pos.getZ(), 0, 0, 0);
}
}

Expand Down Expand Up @@ -123,17 +123,17 @@ public void onBlockHit() {
public void spray() {
for (int i = 1; i < this.spanWidth; i++) {
for (int j = 0; j < 15; j++) {
this.world.addParticle(ParticleTypes.SPLASH, this.x + 0.5 + this.random.nextBetween(-1, 1), this.y, this.z + 0.5 + this.random.nextBetween(-1, 1), this.random.nextGaussian() * 4 * i, this.random.nextGaussian() * 8 * (i / 2f), this.random.nextGaussian() * 4 * i);
this.world.addParticleClient(ParticleTypes.SPLASH, this.x + 0.5 + this.random.nextBetween(-1, 1), this.y, this.z + 0.5 + this.random.nextBetween(-1, 1), this.random.nextGaussian() * 4 * i, this.random.nextGaussian() * 8 * (i / 2f), this.random.nextGaussian() * 4 * i);
}
}
this.markDead();
}

@Override
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
this.lastX = this.x;
this.lastY = this.y;
this.lastZ = this.z;
if (this.age++ >= this.maxAge || this.scale <= 0f) {
this.markDead();
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void move(double dx, double dy, double dz) {
}

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
Quaternionf quaternionf = new Quaternionf();
quaternionf.rotateX((float) Math.toRadians(-90f));
quaternionf.rotateZ((float) Math.toRadians(-90f - this.yaw));
Expand All @@ -200,9 +200,9 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti

protected void render(VertexConsumer vertexConsumer, Camera camera, Quaternionf quaternionf, float tickDelta) {
Vec3d vec3d = camera.getPos();
float x = (float)(MathHelper.lerp(tickDelta, this.prevPosX, this.x) - vec3d.getX());
float y = (float)(MathHelper.lerp(tickDelta, this.prevPosY, this.y) - vec3d.getY());
float z = (float)(MathHelper.lerp(tickDelta, this.prevPosZ, this.z) - vec3d.getZ());
float x = (float)(MathHelper.lerp(tickDelta, this.lastX, this.x) - vec3d.getX());
float y = (float)(MathHelper.lerp(tickDelta, this.lastY, this.y) - vec3d.getY());
float z = (float)(MathHelper.lerp(tickDelta, this.lastZ, this.z) - vec3d.getZ());
this.quad(vertexConsumer, quaternionf, x, y, z, tickDelta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public WaveParticle(ClientWorld world, double x, double y, double z, double velX
super(world, x, y, z, velX, velY, velZ, params, spriteProvider);
this.updateWaterColor();

this.world.addParticle(new WhiteWaveParticleEffect(params), x, y + 0.05f, z, velX, velY, velZ);
this.world.addParticleClient(new WhiteWaveParticleEffect(params), x, y + 0.05f, z, velX, velY, velZ);

//incase I want it for later: This creates a SpriteProvider with this particle's sprites as an example
//AW: ParticleManager#SimpleSpriteProviderer, ParticleManager#loadTextureList
Expand Down
Loading