-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
501 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.enjarai.trickster; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import dev.enjarai.trickster.cca.DisguiseCumponent; | ||
import net.minecraft.client.MinecraftClient; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class DisguiseUtil { | ||
@Nullable | ||
public static GameProfile getGameProfile(DisguiseCumponent component) { | ||
if (component.getUuid() == null) { | ||
return null; | ||
} | ||
var result = MinecraftClient.getInstance().getSessionService() | ||
.fetchProfile(component.getUuid(), true); | ||
if (result == null) { | ||
return null; | ||
} | ||
return result.profile(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/client/java/dev/enjarai/trickster/mixin/client/PlayerEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dev.enjarai.trickster.mixin.client; | ||
|
||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public abstract class PlayerEntityMixin extends LivingEntity { | ||
protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
@Inject( | ||
method = "getName", | ||
at = @At("HEAD"), | ||
cancellable = true | ||
) | ||
protected void disguiseDisplayName(CallbackInfoReturnable<Text> cir) { | ||
|
||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/client/java/dev/enjarai/trickster/mixin/client/SillyHairsFeatureRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.enjarai.trickster.mixin.client; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.mojang.authlib.GameProfile; | ||
import dev.enjarai.trickster.quack.DisguisePlayerQuack; | ||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import nl.enjarai.cicada.util.SillyHairsFeatureRenderer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(SillyHairsFeatureRenderer.class) | ||
public class SillyHairsFeatureRendererMixin { | ||
@ModifyExpressionValue( | ||
method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getGameProfile()Lcom/mojang/authlib/GameProfile;" | ||
) | ||
) | ||
private GameProfile fixSillyHairs(GameProfile original, @Local(argsOnly = true) AbstractClientPlayerEntity player) { | ||
DisguisePlayerQuack theFunny = (DisguisePlayerQuack) player; | ||
var entry = theFunny.trickster$getApplicableEntry(); | ||
if (entry != null) { | ||
return entry.getProfile(); | ||
} | ||
return original; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/client/java/dev/enjarai/trickster/quack/DisguisePlayerQuack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.enjarai.trickster.quack; | ||
|
||
import net.minecraft.client.network.PlayerListEntry; | ||
|
||
public interface DisguisePlayerQuack { | ||
PlayerListEntry trickster$getApplicableEntry(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/dev/enjarai/trickster/cca/DisguiseCumponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package dev.enjarai.trickster.cca; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.network.RegistryByteBuf; | ||
import net.minecraft.registry.RegistryWrapper; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent; | ||
|
||
import java.util.UUID; | ||
|
||
public class DisguiseCumponent implements AutoSyncedComponent { | ||
private final PlayerEntity player; | ||
private UUID targetUuid = null; | ||
|
||
public DisguiseCumponent(PlayerEntity player) { | ||
this.player = player; | ||
} | ||
|
||
@Nullable | ||
public UUID getUuid() { | ||
return targetUuid; | ||
} | ||
|
||
public void setUuid(@Nullable UUID targetUuid) { | ||
this.targetUuid = targetUuid; | ||
ModCumponents.DISGUISE.sync(player); | ||
} | ||
|
||
@Override | ||
public void readFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { | ||
if (tag.contains("targetUuid")) { | ||
targetUuid = tag.getUuid("targetUuid"); | ||
} else { | ||
targetUuid = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void writeToNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { | ||
if (targetUuid != null) { | ||
tag.putUuid("targetUuid", targetUuid); | ||
} | ||
} | ||
|
||
@Override | ||
public void applySyncPacket(RegistryByteBuf buf) { | ||
if (buf.readBoolean()) { | ||
targetUuid = buf.readUuid(); | ||
} else { | ||
targetUuid = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void writeSyncPacket(RegistryByteBuf buf, ServerPlayerEntity recipient) { | ||
buf.writeBoolean(targetUuid != null); | ||
if (targetUuid != null) { | ||
buf.writeUuid(targetUuid); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/dev/enjarai/trickster/cca/ModCumponents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.enjarai.trickster.cca; | ||
|
||
import dev.enjarai.trickster.Trickster; | ||
import org.ladysnake.cca.api.v3.component.ComponentKey; | ||
import org.ladysnake.cca.api.v3.component.ComponentRegistry; | ||
import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry; | ||
import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer; | ||
import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy; | ||
|
||
public class ModCumponents implements EntityComponentInitializer { | ||
public static final ComponentKey<DisguiseCumponent> DISGUISE = | ||
ComponentRegistry.getOrCreate(Trickster.id("disguise"), DisguiseCumponent.class); | ||
|
||
@Override | ||
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) { | ||
registry.registerForPlayers(DISGUISE, DisguiseCumponent::new, RespawnCopyStrategy.LOSSLESS_ONLY); | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
...ai/trickster/mixin/LivingEntityMixin.java → ...ckster/mixin/event/LivingEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../ServerPlayerInteractionManagerMixin.java → .../ServerPlayerInteractionManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/dev/enjarai/trickster/spell/tricks/entity/DispelPolymorphTrick.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.enjarai.trickster.spell.tricks.entity; | ||
|
||
import dev.enjarai.trickster.cca.ModCumponents; | ||
import dev.enjarai.trickster.spell.Fragment; | ||
import dev.enjarai.trickster.spell.Pattern; | ||
import dev.enjarai.trickster.spell.SpellContext; | ||
import dev.enjarai.trickster.spell.fragment.BooleanFragment; | ||
import dev.enjarai.trickster.spell.fragment.FragmentType; | ||
import dev.enjarai.trickster.spell.fragment.VectorFragment; | ||
import dev.enjarai.trickster.spell.tricks.Trick; | ||
import dev.enjarai.trickster.spell.tricks.blunder.BlunderException; | ||
import dev.enjarai.trickster.spell.tricks.blunder.UnknownEntityBlunder; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.joml.Vector3d; | ||
|
||
import java.util.List; | ||
|
||
public class DispelPolymorphTrick extends Trick { | ||
public DispelPolymorphTrick() { | ||
super(Pattern.of(1, 0, 4, 8, 7)); | ||
} | ||
|
||
@Override | ||
public Fragment activate(SpellContext ctx, List<Fragment> fragments) throws BlunderException { | ||
var entity = expectInput(fragments, FragmentType.ENTITY, 0); | ||
|
||
var realEntity = entity.getEntity(ctx).orElseThrow(() -> new UnknownEntityBlunder(this)); | ||
|
||
if (realEntity instanceof ServerPlayerEntity player) { | ||
var cumpoonent = player.getComponent(ModCumponents.DISGUISE); | ||
|
||
if (cumpoonent.getUuid() != null) { | ||
cumpoonent.setUuid(null); | ||
return BooleanFragment.TRUE; | ||
} | ||
} | ||
return BooleanFragment.FALSE; | ||
} | ||
} |
Oops, something went wrong.
23fb926
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that feeling when you mixin into your own mod from a different mod