Skip to content

Commit

Permalink
Add more standard blendshapes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Provismet committed Sep 30, 2023
1 parent 672a468 commit 767efe3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
9 changes: 2 additions & 7 deletions src/main/java/com/provismet/vmcmc/ClientVMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@

import com.provismet.vmcmc.vmc.CaptureRegistry;
import com.provismet.vmcmc.vmc.PacketSender;
import com.provismet.vmcmc.vmc.CaptureRegistry.CaptureType;

public class ClientVMC implements ClientModInitializer {
public static final String MODID = "vmc-mc";
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);

private static Identifier identifier (String path) {
public static Identifier identifier (String path) {
return Identifier.of(MODID, path);
}

@Override
public void onInitializeClient () {
PacketSender.initPort(39541);

CaptureRegistry.register(identifier("light"), CaptureType.BLEND_SHAPE, client -> {
float light = client.getEntityRenderDispatcher().getLight(client.player, client.getTickDelta());
return 15f / light;
});
CaptureRegistry.registerStandardEvents();

ClientTickEvents.END_CLIENT_TICK.register(client -> {
CaptureRegistry.iterate(client);
Expand Down
37 changes: 35 additions & 2 deletions src/main/java/com/provismet/vmcmc/vmc/CaptureRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,48 @@
import java.util.HashMap;
import java.util.function.Function;

import com.provismet.vmcmc.ClientVMC;

import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;

public class CaptureRegistry {
private static final HashMap<Identifier, Pair<CaptureType, Function<MinecraftClient, Float>>> REGISTRY = new HashMap<>();

public static void register (Identifier path, CaptureType type, Function<MinecraftClient, Float> callback) {
CaptureRegistry.REGISTRY.put(path, new Pair<>(type, callback));
public static void register (Identifier identifier, CaptureType type, Function<MinecraftClient, Float> callback) {
CaptureRegistry.REGISTRY.put(identifier, new Pair<>(type, callback));
}

public static void register (String path, CaptureType type, Function<MinecraftClient, Float> callback) {
CaptureRegistry.register(ClientVMC.identifier(path), type, callback);
}

public static void registerStandardEvents () {
CaptureRegistry.register("light", CaptureType.BLEND_SHAPE, client -> {
float light = client.getEntityRenderDispatcher().getLight(client.player, client.getTickDelta());
return 15f / light;
});

CaptureRegistry.register("relative_health", CaptureType.BLEND_SHAPE, client -> {
return client.player.getMaxHealth() / client.player.getHealth();
});

CaptureRegistry.register("hurt", CaptureType.BLEND_SHAPE, client -> {
final float DURATION = 5f;
float elapsed = client.player.getLastAttackedTime() - client.player.age;
if (elapsed > DURATION) return 0f;
else return elapsed / DURATION;
});

CaptureRegistry.register("in_water", CaptureType.BLEND_SHAPE, client -> {
return (float)client.player.getFluidHeight(FluidTags.WATER);
});

CaptureRegistry.register("in_lava", CaptureType.BLEND_SHAPE, client -> {
return (float)client.player.getFluidHeight(FluidTags.LAVA);
});
}

public static void iterate (MinecraftClient client) {
Expand Down

0 comments on commit 767efe3

Please sign in to comment.