Skip to content

Commit

Permalink
Use 1.21 codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Provismet committed Aug 17, 2024
1 parent 752c64d commit f9ffdab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 104 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/provismet/vmcmc/ClientVMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ClientVMC implements ClientModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);

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

@Override
Expand All @@ -34,12 +34,10 @@ public void onInitializeClient () {
entrypoint.getEntrypoint().onInitializeVMC();
}
catch (Throwable e) {
LOGGER.error("Error caused by mod " + otherModId + " during integration.", e);
LOGGER.error("Error caused by mod {} during integration: ", otherModId, e);
}
});

ClientTickEvents.END_CLIENT_TICK.register(client -> {
CaptureRegistry.iterate(client);
});
ClientTickEvents.END_CLIENT_TICK.register(CaptureRegistry::iterate);
}
}
128 changes: 29 additions & 99 deletions src/main/java/com/provismet/vmcmc/vmc/CaptureRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static boolean containsKey (Identifier key) {
* @param callback A function that uses the client to output a float.
*/
public static void registerBlendShape (Identifier identifier, Function<MinecraftClient, Float> callback) {
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendShape register attempt: " + Config.getBlendName(identifier));
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendShape register attempt: {}", Config.getBlendName(identifier));
else BLEND_REGISTRY.put(Config.getBlendName(identifier), callback);
}

Expand All @@ -73,7 +73,7 @@ public static void registerBlendShape (String path, Function<MinecraftClient, Fl
* @param blendStore The BlendStore to receive input from.
*/
public static void registerBlendStore (Identifier identifier, BlendStore blendStore) {
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendStore register attempt: " + Config.getBlendName(identifier));
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate BlendStore register attempt: {}", Config.getBlendName(identifier));
else BLENDSTORE_REGISTRY.put(Config.getBlendName(identifier), blendStore);
}

Expand All @@ -92,7 +92,7 @@ public static void registerBlendStore (String path, BlendStore blendStore) {
* @param callback A function that uses the client to output a list of floats.
*/
public static void registerBone (Identifier identifier, Function<MinecraftClient, List<Float>> callback) {
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate Bone register attempt: " + identifier.toString());
if (containsKey(identifier)) ClientVMC.LOGGER.error("Duplicate Bone register attempt: {}", identifier.toString());
else BONE_REGISTRY.put(identifier.toString(), callback);
}

Expand All @@ -116,14 +116,14 @@ public static void registerBone (String path, Function<MinecraftClient, List<Flo
public static void registerStandardEvents () {
// Your block light (light gained from torches, etc).
registerBlendShape("block_light", client -> {
int lightmap = client.getEntityRenderDispatcher().getLight(client.player, client.getTickDelta());
int lightmap = client.getEntityRenderDispatcher().getLight(client.player, client.getRenderTickCounter().getTickDelta(true));
float blockLight = (lightmap >> 4) & 0xF;
return blockLight / 15f;
});

// This refers to the strength of your sky exposure. It's the same value as from the F3 menu and is NOT the same as actual brightness (but DOES impact it).
registerBlendShape("sky_light", client -> {
int lightmap = client.getEntityRenderDispatcher().getLight(client.player, client.getTickDelta());
int lightmap = client.getEntityRenderDispatcher().getLight(client.player, client.getRenderTickCounter().getTickDelta(true));
float skyLight = (lightmap >> 20) & 0xF;
return skyLight / 15f;
});
Expand All @@ -138,129 +138,59 @@ public static void registerStandardEvents () {

// Manually calculate light this way because it accounts for mods that modify the player's block-light value.
float internalLight;
int lightmap = client.getEntityRenderDispatcher().getLight(client.player, client.getTickDelta());
int lightmap = client.getEntityRenderDispatcher().getLight(client.player, client.getRenderTickCounter().getTickDelta(true));
float blockLight = (lightmap >> 4) & 0xF;
float skyLight = ((lightmap >> 20) & 0xF) - ambientDarkness;
internalLight = blockLight > skyLight ? blockLight : skyLight;
internalLight = Math.max(blockLight, skyLight);
return internalLight / 15f;
});

registerBlendShape("relative_health", client -> {
return client.player.getHealth() / client.player.getMaxHealth();
});

registerBlendShape("water_height", client -> {
return (float)client.player.getFluidHeight(FluidTags.WATER);
});

registerBlendShape("lava_height", client -> {
return (float)client.player.getFluidHeight(FluidTags.LAVA);
});

registerBlendShape("water_submerged", client -> {
return client.player.isSubmergedInWater() ? 1f : 0f;
});

registerBlendShape("lava_submerged", client -> {
return client.player.isSubmergedIn(FluidTags.LAVA) ? 1f : 0f;
});

registerBlendShape("relative_health", client -> client.player.getHealth() / client.player.getMaxHealth());
registerBlendShape("water_height", client -> (float)client.player.getFluidHeight(FluidTags.WATER));
registerBlendShape("lava_height", client -> (float)client.player.getFluidHeight(FluidTags.LAVA));
registerBlendShape("water_submerged", client -> client.player.isSubmergedInWater() ? 1f : 0f);
registerBlendShape("lava_submerged", client -> client.player.isSubmergedIn(FluidTags.LAVA) ? 1f : 0f);
registerBlendShape("time_of_day", client -> {
float time = client.world.getTimeOfDay();
while (time >= 24000f) {
time -= 24000f;
}
return time / 24000f;
});

registerBlendShape("rain_amount", client -> {
if (client.world.isThundering()) return 1f;
else if (client.world.isRaining()) return 0.5f;
else return 0f;
});

registerBlendShape("on_fire", client -> {
return client.player.isOnFire() ? 1f : 0f;
});

registerBlendShape("experience", client -> {
return (float)client.player.experienceLevel + client.player.experienceProgress;
});

registerBlendShape("is_wet", client -> {
return client.player.isWet() ? 1f : 0f;
});

registerBlendShape("sneaking", client -> {
return client.player.isSneaking() ? 1f : 0f;
});

registerBlendShape("crawling", client -> {
return client.player.isCrawling() ? 1f : 0f;
});

registerBlendShape("climbing", client -> {
return client.player.isClimbing() ? 1f : 0f;
});

registerBlendShape("blocking", client -> {
return client.player.isBlocking() ? 1f : 0f;
});

registerBlendShape("glowing", client -> {
return client.player.isGlowing() ? 1f : 0f;
});

registerBlendShape("frozen", client -> {
return client.player.isFrozen() ? 1f : 0f;
});

registerBlendShape("swimming", client -> {
return client.player.isSwimming() ? 1f : 0f;
});

registerBlendShape("sprinting", client -> {
return client.player.isSprinting() ? 1f : 0f;
});

registerBlendShape("riding_living", client -> {
return client.player.getVehicle() instanceof LivingEntity ? 1f : 0f;
});

registerBlendShape("on_fire", client -> client.player.isOnFire() ? 1f : 0f);
registerBlendShape("experience", client -> (float)client.player.experienceLevel + client.player.experienceProgress);
registerBlendShape("is_wet", client -> client.player.isWet() ? 1f : 0f);
registerBlendShape("sneaking", client -> client.player.isSneaking() ? 1f : 0f);
registerBlendShape("crawling", client -> client.player.isCrawling() ? 1f : 0f);
registerBlendShape("climbing", client -> client.player.isClimbing() ? 1f : 0f);
registerBlendShape("blocking", client -> client.player.isBlocking() ? 1f : 0f);
registerBlendShape("glowing", client -> client.player.isGlowing() ? 1f : 0f);
registerBlendShape("frozen", client -> client.player.isFrozen() ? 1f : 0f);
registerBlendShape("swimming", client -> client.player.isSwimming() ? 1f : 0f);
registerBlendShape("sprinting", client -> client.player.isSprinting() ? 1f : 0f);
registerBlendShape("riding_living", client -> client.player.getVehicle() instanceof LivingEntity ? 1f : 0f);
registerBlendShape("riding_nonliving", client -> {
if (client.player.getVehicle() == null) return 0f;
return client.player.getVehicle() instanceof LivingEntity ? 0f : 1f;
});

registerBlendShape("elytra_flying", client -> {
return client.player.isFallFlying() ? 1f : 0f;
});

registerBlendShape("sleeping", client -> {
return client.player.isSleeping() ? 1f : 0f;
});

registerBlendShape("alive", client -> {
return client.player.isAlive() ? 1f : 0f;
});

registerBlendShape("relative_food_level", client -> {
return (float)client.player.getHungerManager().getFoodLevel() / 20f;
});

registerBlendShape("elytra_flying", client -> client.player.isFallFlying() ? 1f : 0f);
registerBlendShape("sleeping", client -> client.player.isSleeping() ? 1f : 0f);
registerBlendShape("alive", client -> client.player.isAlive() ? 1f : 0f);
registerBlendShape("relative_food_level", client -> (float)client.player.getHungerManager().getFoodLevel() / 20f);
registerBlendShape("relative_air_level", client -> {
float airLevel = client.player.getAir() > 0 ? client.player.getAir() : 0f;
return airLevel / (float)client.player.getMaxAir();
});

registerBlendShape("hotbar", client -> {
float slot = client.player.getInventory().selectedSlot;
return (slot + 0.1f) / 10f;
});

registerBlendShape("exposed_to_sky", client -> {
return client.world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, client.player.getBlockPos()).getY() > client.player.getEyeY() ? 0f : 1f;
});
registerBlendShape("exposed_to_sky", client -> client.world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, client.player.getBlockPos()).getY() > client.player.getEyeY() ? 0f : 1f);

/* HOW DO BONES?
registerBone("head", client -> {
Expand Down

0 comments on commit f9ffdab

Please sign in to comment.