Skip to content

Commit

Permalink
Merge branch 'master' of github.com:enjarai/trickster
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarWitch7 committed Sep 22, 2024
2 parents 8c1e654 + ff8bf36 commit 9f16a19
Show file tree
Hide file tree
Showing 58 changed files with 229 additions and 186 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id 'me.fallenbreath.yamlang' version '1.3.1'
id "me.modmuss50.mod-publish-plugin" version "0.4.4"
Expand Down Expand Up @@ -109,7 +109,7 @@ dependencies {
include modApi("org.ladysnake.cardinal-components-api:cardinal-components-entity:${property('deps.cardinal-components-api')}")

modCompileOnly modLocalRuntime("com.terraformersmc:modmenu:${property('deps.modmenu')}")
modClientCompileOnly "maven.modrinth:sodium:${property('deps.sodium')}"
modClientCompileOnly modLocalRuntime("maven.modrinth:sodium:${property('deps.sodium')}")

modApi("io.wispforest:accessories-fabric:${property('deps.accessories')}")

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod_github=enjarai/trickster
git_branch=master

# Dependencies
deps.fabric-api=0.100.1+1.21
deps.fabric-api=0.102.0+1.21
deps.owo-lib=0.12.14+1.21
deps.lavender=0.1.13+1.21
deps.cicada=0.8.3+1.21-and-above
Expand All @@ -31,5 +31,5 @@ deps.modmenu=11.0.1
deps.accessories=1.0.0-beta.11+1.21

# Optional
deps.sodium=mc1.21-0.5.11
deps.sodium=mc1.21-0.6.0-beta.2-fabric
deps.transmog=fabric-1.4.1+1.21
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.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
8 changes: 2 additions & 6 deletions src/client/java/dev/enjarai/trickster/DisguiseUtil.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package dev.enjarai.trickster;

import com.mojang.authlib.GameProfile;
import dev.enjarai.trickster.cca.DisguiseCumponent;
import dev.enjarai.trickster.cca.ModChunkCumponents;
import dev.enjarai.trickster.cca.DisguiseComponent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.EmptyChunk;
import org.jetbrains.annotations.Nullable;

public class DisguiseUtil {
@Nullable
public static GameProfile getGameProfile(DisguiseCumponent component) {
public static GameProfile getGameProfile(DisguiseComponent component) {
if (component.getUuid() == null) {
return null;
}
Expand Down
8 changes: 2 additions & 6 deletions src/client/java/dev/enjarai/trickster/TricksterClient.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.enjarai.trickster;

import dev.enjarai.trickster.block.ModBlocks;
import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import dev.enjarai.trickster.item.ModItems;
import dev.enjarai.trickster.item.ScrollAndQuillItem;
import dev.enjarai.trickster.net.IsEditingScrollPacket;
Expand All @@ -26,14 +26,10 @@
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
import net.minecraft.component.type.DyedColorComponent;
import net.minecraft.util.math.ColorHelper;

public class TricksterClient implements ClientModInitializer {
@Override
Expand Down Expand Up @@ -65,7 +61,7 @@ public void onInitializeClient() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player != null) {
var editing = client.currentScreen instanceof ScrollAndQuillScreen;
var serverEditing = ModEntityCumponents.IS_EDITING_SCROLL.get(client.player).isEditing();
var serverEditing = ModEntityComponents.IS_EDITING_SCROLL.get(client.player).isEditing();
if (editing != serverEditing) {
ModNetworking.CHANNEL.clientHandle().send(new IsEditingScrollPacket(editing));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.mojang.authlib.GameProfile;
import dev.enjarai.trickster.DisguiseUtil;
import dev.enjarai.trickster.Trickster;
import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import dev.enjarai.trickster.pond.DisguisePlayerDuck;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
Expand Down Expand Up @@ -32,7 +32,7 @@ protected AbstractClientPlayerEntityMixin(EntityType<? extends LivingEntity> ent
}

public PlayerListEntry trickster$getApplicableEntry() {
var disguise = getComponent(ModEntityCumponents.DISGUISE);
var disguise = getComponent(ModEntityComponents.DISGUISE);
if (disguise.getUuid() != null) {
if (disguisePlayerListEntry == null || !disguisePlayerListEntry.getProfile().getId().equals(disguise.getUuid())) {
// Update the entry if its out of date
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.enjarai.trickster.mixin.client;

import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import dev.enjarai.trickster.screen.SpellSlotWidget;
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
Expand Down Expand Up @@ -31,7 +31,7 @@ public InventoryScreenMixin(PlayerScreenHandler screenHandler, PlayerInventory p
)
private void initSpellSlots(CallbackInfo ci) {
spellSlots = new ArrayList<>();
var spellData = client.player.getComponent(ModEntityCumponents.CASTER).getRunningSpellData();
var spellData = client.player.getComponent(ModEntityComponents.CASTER).getRunningSpellData();

for (int i = 0; i < 5; i++) {
var widget = new SpellSlotWidget(x + 156 - i * 18, y + 166, i);
Expand All @@ -46,7 +46,7 @@ private void initSpellSlots(CallbackInfo ci) {
at = @At("TAIL")
)
private void tickSpellSlots(CallbackInfo ci) {
var spellData = client.player.getComponent(ModEntityCumponents.CASTER).getRunningSpellData();
var spellData = client.player.getComponent(ModEntityComponents.CASTER).getRunningSpellData();

for (var slot : spellSlots) {
slot.setPosition(x + 156 - slot.index * 18, y + 166);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.enjarai.trickster.mixin.client;

import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import dev.enjarai.trickster.item.ModItems;
import dev.enjarai.trickster.item.component.ModComponents;
import dev.enjarai.trickster.render.SpellCircleRenderer;
Expand Down Expand Up @@ -57,7 +57,7 @@ public abstract class PlayerRendererMixin {
var mainHandSpell = mainHandStack.get(ModComponents.SPELL);
var offHandSpell = offHandStack.get(ModComponents.SPELL);

if (entity.getComponent(ModEntityCumponents.IS_EDITING_SCROLL).isEditing()) {
if (entity.getComponent(ModEntityComponents.IS_EDITING_SCROLL).isEditing()) {
if (mainHandStack.isIn(ModItems.SCROLLS) && mainHandStack.get(ModComponents.SPELL) != null && mainHandSpell != null) {
return Optional.of(mainHandSpell.spell());
} else if (offHandStack.isIn(ModItems.SCROLLS) && offHandStack.get(ModComponents.SPELL) != null && offHandSpell != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.enjarai.trickster.mixin.client;

import com.google.common.base.Suppliers;
import dev.enjarai.trickster.cca.ModChunkCumponents;
import dev.enjarai.trickster.cca.ModChunkComponents;
import dev.enjarai.trickster.cca.ShadowDisguiseMapComponent;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
Expand All @@ -23,7 +23,7 @@ public class RenderedChunkMixin {
private WorldChunk chunk;
@Unique
private final Supplier<ShadowDisguiseMapComponent> disguises =
Suppliers.memoize(() -> ModChunkCumponents.SHADOW_DISGUISE_MAP.getNullable(chunk));
Suppliers.memoize(() -> ModChunkComponents.SHADOW_DISGUISE_MAP.getNullable(chunk));

@Inject(
method = "getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.enjarai.trickster.mixin.client;

import dev.enjarai.trickster.Trickster;
import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.SubtitlesHud;
Expand All @@ -16,7 +16,7 @@ public class SubtitlesHudMixin {
private void offsetSubtitles(DrawContext context, CallbackInfo ci) {
var player = MinecraftClient.getInstance().player;
if (player == null) return;
var barsComponent = player.getComponent(ModEntityCumponents.BARS);
var barsComponent = player.getComponent(ModEntityComponents.BARS);
var bars = barsComponent.getBars();

if (Trickster.CONFIG.barsHorizontal()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.enjarai.trickster.mixin.client.animation;

import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import dev.enjarai.trickster.render.PlayerAnimator;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.entity.LivingEntity;
Expand All @@ -13,7 +13,7 @@ public class PlayerEntityModelMixin<T extends LivingEntity> extends BipedEntityM
@Override
protected void positionModelParts(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (livingEntity instanceof PlayerEntity player) {
PlayerAnimator.setAngles(player, ModEntityCumponents.PLAYER_ANIMATION.get(player), tickDelta, rightArm, leftArm);
PlayerAnimator.setAngles(player, ModEntityComponents.PLAYER_ANIMATION.get(player), tickDelta, rightArm, leftArm);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import dev.enjarai.trickster.cca.ModEntityCumponents;
import dev.enjarai.trickster.cca.ModEntityComponents;
import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -27,7 +27,7 @@ private static void changeAvatarWhenPolymorphed(UUID uuid, CallbackInfoReturnabl
if (world != null) {
var player = world.getPlayerByUuid(uuidRef.get());
if (player != null) {
var disguise = ModEntityCumponents.DISGUISE.get(player).getUuid();
var disguise = ModEntityComponents.DISGUISE.get(player).getUuid();
if (disguise != null) {
uuidRef.set(disguise);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package dev.enjarai.trickster.mixin.client.sodium;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import dev.enjarai.trickster.cca.ModChunkComponents;
import dev.enjarai.trickster.cca.ShadowDisguiseMapComponent;
import dev.enjarai.trickster.pond.WorldlyRenderContextDuck;
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildOutput;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderTask;
import net.caffeinemc.mods.sodium.client.util.task.CancellationToken;
import net.caffeinemc.mods.sodium.client.world.LevelSlice;
import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext;
import net.minecraft.block.BlockState;
import net.minecraft.world.World;
import org.joml.Vector3dc;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ChunkBuilderMeshingTask.class)
public abstract class ChunkBuilderMeshingTaskMixin extends ChunkBuilderTask<ChunkBuildOutput> {
@Shadow @Final private ChunkRenderContext renderContext;

public ChunkBuilderMeshingTaskMixin(RenderSection render, int time, Vector3dc absoluteCameraPos) {
super(render, time, absoluteCameraPos);
}

@Inject(
method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
at = @At("HEAD"),
remap = false
)
private void preGetComponent(ChunkBuildContext buildContext, CancellationToken cancellationToken,
CallbackInfoReturnable<ChunkBuildOutput> cir,
@Share("shadow_map") LocalRef<ShadowDisguiseMapComponent> shadowMap) {
//noinspection resource
var world = ((WorldlyRenderContextDuck) renderContext).trickster$getWorld();
shadowMap.set(ModChunkComponents.SHADOW_DISGUISE_MAP.get(world.getChunk(render.getChunkX(), render.getChunkZ())));
}

@WrapOperation(
method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;",
at = @At(
value = "INVOKE",
target = "Lnet/caffeinemc/mods/sodium/client/world/LevelSlice;getBlockState(III)Lnet/minecraft/block/BlockState;"
),
remap = false
)
private BlockState modifyBlockState(LevelSlice instance, int blockX, int blockY, int blockZ, Operation<BlockState> original, @Share("shadow_map") LocalRef<ShadowDisguiseMapComponent> shadowMap) {
var customState = shadowMap.get().getFunnyState(blockX, blockY, blockZ);
return customState != null ? customState : original.call(instance, blockX, blockY, blockZ);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package dev.enjarai.trickster.mixin.client.sodium;

import dev.enjarai.trickster.pond.WorldlyRenderContextDuck;
import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Mixin(ChunkRenderContext.class)
public class ChunkRenderContextMixin implements WorldlyRenderContextDuck {
@Unique
private World world;

@Override
public World trickster$getWorld() {
return world;
}

@Override
public void trickster$setWorld(World world) {
this.world = world;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dev.enjarai.trickster.mixin.client.sodium;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import dev.enjarai.trickster.pond.WorldlyRenderContextDuck;
import net.caffeinemc.mods.sodium.client.world.LevelSlice;
import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(LevelSlice.class)
public abstract class LevelSliceMixin {
@ModifyReturnValue(
method = "prepare",
at = @At(
value = "RETURN",
ordinal = 1
),
remap = false
)
private static ChunkRenderContext addWorldContext(ChunkRenderContext original, @Local(argsOnly = true) World world) {
((WorldlyRenderContextDuck) original).trickster$setWorld(world);
return original;
}
}

This file was deleted.

Loading

0 comments on commit 9f16a19

Please sign in to comment.