Skip to content

Commit

Permalink
render types for test build
Browse files Browse the repository at this point in the history
+ useless wake particle
  • Loading branch information
Goby56 committed Dec 1, 2023
1 parent a9b21ce commit 3fc2296
Show file tree
Hide file tree
Showing 16 changed files with 411 additions and 146 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.4
loader_version=0.14.24

# Mod Properties
mod_version=0.2.1-test-build-1
mod_version=0.2.1-test-build-2
maven_group=com.goby56.wakes
archives_base_name=wakes

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/goby56/wakes/WakesClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.goby56.wakes;

import com.goby56.wakes.command.DebugCommand;
import com.goby56.wakes.config.WakesConfig;
import com.goby56.wakes.event.WakeTicker;
import com.goby56.wakes.particle.ModParticles;
Expand All @@ -8,6 +9,7 @@
import com.goby56.wakes.render.debug.WakeDebugRenderer;
import com.goby56.wakes.render.model.WakeModel;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
Expand Down Expand Up @@ -50,7 +52,7 @@ public void onInitializeClient() {
ClientLifecycleEvents.CLIENT_STARTED.register(new SplashPlaneRenderer());

// Commands
// ClientCommandRegistrationCallback.EVENT.register(SpawnWakesCommand::register);
ClientCommandRegistrationCallback.EVENT.register(DebugCommand::register);
}

public static boolean isYACLLoaded() {
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/com/goby56/wakes/command/DebugCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.goby56.wakes.command;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.fluid.FluidState;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;

public class DebugCommand {
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
dispatcher.register(ClientCommandManager.literal("wakes_debug")
.then(ClientCommandManager.literal("light")
.executes(DebugCommand::lightCoordinate))
.then(ClientCommandManager.literal("color")
.executes(DebugCommand::waterColor)));
}

public static int lightCoordinate(CommandContext<FabricClientCommandSource> cmdCtx) throws CommandSyntaxException {
World world = cmdCtx.getSource().getWorld();
BlockPos blockPos = cmdCtx.getSource().getPlayer().getBlockPos();

cmdCtx.getSource().sendFeedback(Text.of(String.valueOf(WorldRenderer.getLightmapCoordinates(world, blockPos))));
return 1;
}

public static int waterColor(CommandContext<FabricClientCommandSource> cmdCtx) throws CommandSyntaxException {
World world = cmdCtx.getSource().getWorld();
BlockPos blockPos = cmdCtx.getSource().getPlayer().getBlockPos();

int col = BiomeColors.getWaterColor(world, blockPos);
cmdCtx.getSource().sendFeedback(Text.of(String.format("(%d, %d, %d)",
ColorHelper.Argb.getRed(col),
ColorHelper.Argb.getGreen(col),
ColorHelper.Argb.getBlue(col))));
return 1;
}
}
60 changes: 0 additions & 60 deletions src/main/java/com/goby56/wakes/command/SpawnWakesCommand.java

This file was deleted.

23 changes: 23 additions & 0 deletions src/main/java/com/goby56/wakes/config/WakesConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.goby56.wakes.utils.WakeColor;
import com.google.gson.Gson;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
Expand All @@ -22,6 +24,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

public class WakesConfig {
// Spawning
Expand Down Expand Up @@ -49,6 +52,7 @@ public class WakesConfig {
public boolean drawDebugBoxes = false;
public boolean renderWakes = true;
public boolean spawnWakes = true;
public RenderType renderType = RenderType.ENTITY_SOLID;

// Appearance
public Resolution wakeResolution = Resolution.SIXTEEN;
Expand Down Expand Up @@ -131,6 +135,25 @@ public String toString() {
}
}

public enum RenderType {
SOLID(GameRenderer::getRenderTypeSolidProgram),
TRANSLUCENT(GameRenderer::getRenderTypeTranslucentProgram),
CUTOUT(GameRenderer::getRenderTypeCutoutProgram),
ENTITY_SOLID(GameRenderer::getRenderTypeEntitySolidProgram),
ENTITY_TRANSLUCENT(GameRenderer::getRenderTypeEntityTranslucentProgram),
ENTITY_TRANSLUCENT_CULL(GameRenderer::getRenderTypeEntityTranslucentCullProgram),
ENTITY_CUTOUT(GameRenderer::getRenderTypeEntityCutoutProgram),
ENTITY_CUTOUT_NO_CULL(GameRenderer::getRenderTypeEntityCutoutNoNullProgram),
ENTITY_CUTOUT_NO_CULL_Z_OFFSET(GameRenderer::getRenderTypeEntityCutoutNoNullZOffsetProgram)
;

public final Supplier<ShaderProgram> program;

RenderType(Supplier<ShaderProgram> program) {
this.program = program;
}
}

public WakeSpawningRule getSpawningRule(Entity producer) {
if (producer instanceof BoatEntity boat) {
if (wakeSpawningRules.get("boat_wake_rules") == WakeSpawningRule.WAKES_AND_SPLASHES) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/goby56/wakes/config/YACLIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public static Screen createScreen(Screen parent) {
.build())
.build())
.category(configCategory("debug")
.option(optionOf(WakesConfig.RenderType.class, "render_type")
.binding(WakesConfig.RenderType.ENTITY_SOLID, () -> config.renderType, val -> config.renderType = val)
.controller(opt -> EnumControllerBuilder.create(opt)
.enumClass(WakesConfig.RenderType.class))
.build())
.option(optionOf(Integer.class, "flood_fill_distance")
.binding(3, () -> config.floodFillDistance, val -> config.floodFillDistance = val)
.controller(opt -> integerSlider(opt, 1, 5))
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/goby56/wakes/event/WakeTicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
public class WakeTicker implements ClientTickEvents.EndWorldTick {
@Override
public void onEndTick(ClientWorld world) {
WakeTextureRenderer.hasPrintedToChat = false;
WakeHandler.getInstance().tick();
}
}
11 changes: 8 additions & 3 deletions src/main/java/com/goby56/wakes/particle/ModParticles.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package com.goby56.wakes.particle;

import com.goby56.wakes.WakesClient;
import com.goby56.wakes.particle.custom.SplashPlaneParticle;
import com.goby56.wakes.particle.custom.WakeParticle;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class ModParticles {
public static WakeParticleType WAKE_SPLASH;
public static SplashPlaneParticleType SPLASH_PLANE;
public static WakeParticleType WAKE_PARTICLE;

public static void registerParticles() {
WAKE_SPLASH = Registry.register(Registries.PARTICLE_TYPE, new Identifier(WakesClient.MOD_ID, "wake"), new WakeParticleType(true));
ParticleFactoryRegistry.getInstance().register(WAKE_SPLASH, WakeParticle.Factory::new);
SPLASH_PLANE = Registry.register(Registries.PARTICLE_TYPE, new Identifier(WakesClient.MOD_ID, "splash_plane"), new SplashPlaneParticleType(true));
ParticleFactoryRegistry.getInstance().register(SPLASH_PLANE, SplashPlaneParticle.Factory::new);

WAKE_PARTICLE = Registry.register(Registries.PARTICLE_TYPE, new Identifier(WakesClient.MOD_ID, "wake_particle"), new WakeParticleType(true));
ParticleFactoryRegistry.getInstance().register(WAKE_PARTICLE, WakeParticle.Factory::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.goby56.wakes.particle;

import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;

public class SplashPlaneParticleType extends DefaultParticleType {
public Entity owner;

protected SplashPlaneParticleType(boolean alwaysShow) {
super(alwaysShow);
}

public SplashPlaneParticleType withOwner(Entity owner) {
this.owner = owner;
return this;
}
}
7 changes: 4 additions & 3 deletions src/main/java/com/goby56/wakes/particle/WakeParticleType.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.goby56.wakes.particle;

import com.goby56.wakes.utils.WakeNode;
import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;

public class WakeParticleType extends DefaultParticleType {
public Entity owner;
public WakeNode node;

protected WakeParticleType(boolean alwaysShow) {
super(alwaysShow);
}

public WakeParticleType withOwner(Entity owner) {
this.owner = owner;
public WakeParticleType withNode(WakeNode node) {
this.node = node;
return this;
}
}
Loading

0 comments on commit 3fc2296

Please sign in to comment.