This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
a301f1a
commit 31c1a09
Showing
22 changed files
with
118 additions
and
152 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
common/src/main/java/net/merchantpug/apugli/access/PlayerSkinAccess.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 net.merchantpug.apugli.access; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
|
||
public interface PlayerSkinAccess { | ||
void apugli$setPlayer(Player player); | ||
} |
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
40 changes: 0 additions & 40 deletions
40
...n/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerEntityMixin.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...rc/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerMixin.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 net.merchantpug.apugli.mixin.xplatform.client; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import net.merchantpug.apugli.access.PlayerSkinAccess; | ||
import net.minecraft.client.multiplayer.PlayerInfo; | ||
import net.minecraft.client.player.AbstractClientPlayer; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
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(AbstractClientPlayer.class) | ||
public abstract class AbstractClientPlayerMixin extends Player { | ||
@Shadow private @Nullable PlayerInfo playerInfo; | ||
|
||
public AbstractClientPlayerMixin(Level level, BlockPos pos, float yRot, GameProfile gameProfile) { | ||
super(level, pos, yRot, gameProfile); | ||
} | ||
|
||
@Inject(method = "getPlayerInfo", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientPacketListener;getPlayerInfo(Ljava/util/UUID;)Lnet/minecraft/client/multiplayer/PlayerInfo;", shift = At.Shift.BY, by = 2)) | ||
private void apugli$setPlayerToSkin(CallbackInfoReturnable<PlayerInfo> cir) { | ||
((PlayerSkinAccess)(Object)this.playerInfo.getSkin()).apugli$setPlayer(this); | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/PlayerSkinMixin.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,43 @@ | ||
package net.merchantpug.apugli.mixin.xplatform.client; | ||
|
||
import io.github.apace100.apoli.Apoli; | ||
import net.merchantpug.apugli.access.PlayerSkinAccess; | ||
import net.merchantpug.apugli.platform.Services; | ||
import net.merchantpug.apugli.power.PlayerModelTypePower; | ||
import net.merchantpug.apugli.power.SetTexturePower; | ||
import net.merchantpug.apugli.registry.power.ApugliPowers; | ||
import net.minecraft.client.resources.PlayerSkin; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(PlayerSkin.class) | ||
public class PlayerSkinMixin implements PlayerSkinAccess { | ||
|
||
@Unique | ||
private Player apugli$player; | ||
|
||
@Inject(method = "model", at = @At("HEAD"), cancellable = true) | ||
private void apugli$getModel(CallbackInfoReturnable<String> cir) { | ||
List<PlayerModelTypePower> playerModelTypePowers = Services.POWER.getPowers(this.apugli$player, ApugliPowers.PLAYER_MODEL_TYPE.get()); | ||
List<SetTexturePower> setTexturePowers = Services.POWER.getPowers(this.apugli$player, ApugliPowers.SET_TEXTURE.get()).stream().filter(p -> p.getModel() != null).toList(); | ||
if(playerModelTypePowers.size() + setTexturePowers.size() > 1) { | ||
Apoli.LOGGER.warn("Entity " + this.apugli$player.getDisplayName() + " has two instances of player model setting powers active."); | ||
} | ||
if(!playerModelTypePowers.isEmpty()) { | ||
cir.setReturnValue(Services.POWER.getPowers(this.apugli$player, ApugliPowers.PLAYER_MODEL_TYPE.get()).get(0).getModel().toString()); | ||
} else if (!setTexturePowers.isEmpty()) { | ||
cir.setReturnValue(Services.POWER.getPowers(this.apugli$player, ApugliPowers.SET_TEXTURE.get()).get(0).getModel().toString()); | ||
} | ||
} | ||
|
||
@Override | ||
public void apugli$setPlayer(Player player) { | ||
this.apugli$player = player; | ||
} | ||
} |
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
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
50 changes: 0 additions & 50 deletions
50
common/src/main/java/net/merchantpug/apugli/util/IndividualisedEmptyStackUtil.java
This file was deleted.
Oops, something went wrong.
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
8 changes: 0 additions & 8 deletions
8
fabric/src/main/java/net/merchantpug/apugli/access/ItemStackAccess.java
This file was deleted.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerListMixin.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,21 @@ | ||
package net.merchantpug.apugli.mixin.fabric.common; | ||
|
||
import net.merchantpug.apugli.network.s2c.UpdateUrlTexturesPacket; | ||
import net.merchantpug.apugli.platform.Services; | ||
import net.merchantpug.apugli.util.TextureUtil; | ||
import net.minecraft.network.Connection; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.server.network.CommonListenerCookie; | ||
import net.minecraft.server.players.PlayerList; | ||
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.CallbackInfo; | ||
|
||
@Mixin(PlayerList.class) | ||
public class PlayerListMixin { | ||
@Inject(method = "placeNewPlayer", at = @At("TAIL")) | ||
private void apugli$sendUrlDataUponPlacement(Connection connection, ServerPlayer serverPlayer, CommonListenerCookie commonListenerCookie, CallbackInfo ci) { | ||
Services.PLATFORM.sendS2C(new UpdateUrlTexturesPacket(TextureUtil.getCache()), serverPlayer); | ||
} | ||
} |
Oops, something went wrong.