Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Fix remaining build errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Nov 12, 2023
1 parent a301f1a commit 31c1a09
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 152 deletions.
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void renderArmor(T entity, ItemStack stack, PoseStack matrices, MultiBuff
((ArmorFeatureRendererAccessor)this).apugli$invokeRenderArmorParts(matrices, vertexConsumers, light, armorItem, model, bl, 1.0F, 1.0F, 1.0F, null);
}

ArmorTrim.getTrim(entity.level().registryAccess(), stack).ifPresent((armorTrim) -> {
ArmorTrim.getTrim(entity.level().registryAccess(), stack, true).ifPresent((armorTrim) -> {
((ArmorFeatureRendererAccessor)(this)).apugli$invokeRenderTrim(armorItem.getMaterial(), matrices, vertexConsumers, light, armorTrim, model, bl);
});
if (stack.hasFoil()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public SerializableData getSerializableData() {
@Override
public boolean check(SerializableData.Instance data, Entity entity) {
if(!entity.level().isClientSide() || !(entity instanceof AbstractClientPlayer)) return false;
return ((AbstractClientPlayer) entity).getModelName().equals(data.get("model_type").toString());
return ((AbstractClientPlayer) entity).getSkin().model().id().equals(data.get("model_type").toString());
}

}

This file was deleted.

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.merchantpug.apugli.client.util.TextureUtilClient;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -13,8 +14,8 @@

@Mixin(Minecraft.class)
public class MinecraftClientMixin {
@Inject(method = "reloadResourcePacks(Z)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
private void apugli$reloadUrlTextures(boolean force, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
@Inject(method = "reloadResourcePacks(ZLnet/minecraft/client/Minecraft$GameLoadCookie;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN"))
private void apugli$reloadUrlTextures(boolean bl, Minecraft.@Nullable GameLoadCookie gameLoadCookie, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
for (Map.Entry<ResourceLocation, String> entry : TextureUtilClient.getUrls().entrySet()) {
ResourceLocation textureLocation = entry.getKey();
String url = entry.getValue();
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BeehiveBlock;
import net.minecraft.world.phys.AABB;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -18,8 +19,8 @@
@Mixin(BeehiveBlock.class)
public class BeehiveBlockMixin {

@Inject(method = "angerNearbyBees", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void apugli$dontAngerBees(Level world, BlockPos pos, CallbackInfo ci, List<Bee> list, List<Player> list2) {
@Inject(method = "angerNearbyBees", at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void apugli$dontAngerBees(Level level, BlockPos pos, CallbackInfo ci, AABB aABB, List<Bee> list, List<Player> list2) {
if (list2.stream().anyMatch(player -> Services.POWER.hasPower(player, ApugliPowers.PREVENT_BEE_ANGER.get()))) {
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ public abstract class ItemStackMixin {
@Unique
private int apugli$previousDamage;

@Inject(method = "copy", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;setPopTime(I)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
private void apugli$copyNewParams(CallbackInfoReturnable<ItemStack> cir, ItemStack itemStack) {
if (Services.PLATFORM.getEntityFromItemStack((ItemStack)(Object)this) != null) {
Services.PLATFORM.setEntityToItemStack(itemStack, Services.PLATFORM.getEntityFromItemStack((ItemStack)(Object)this));
}
}

@ModifyVariable(method = "setDamageValue", at = @At(value = "HEAD"), argsOnly = true)
private int apugli$captureDamageValue(int newDamage) {
if (Services.PLATFORM.getEntityFromItemStack((ItemStack)(Object)this) instanceof LivingEntity living) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
package net.merchantpug.apugli.mixin.xplatform.common;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.merchantpug.apugli.network.s2c.UpdateUrlTexturesPacket;
import net.merchantpug.apugli.platform.Services;
import net.merchantpug.apugli.registry.power.ApugliPowers;
import net.merchantpug.apugli.util.TextureUtil;
import net.minecraft.network.protocol.game.ServerboundResourcePackPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
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.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ServerGamePacketListenerImpl.class)
public class ServerPlayNetworkHandlerMixin {
@Shadow public ServerPlayer player;

@Shadow @Final private MinecraftServer server;

@ModifyExpressionValue(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;clientIsFloating:Z", ordinal = 0))
private boolean apugli$doNotKickIfUsingHoverPower(boolean original) {
return original && !Services.POWER.hasPower(this.player, ApugliPowers.HOVER.get());
Expand Down Expand Up @@ -52,10 +43,4 @@ public class ServerPlayNetworkHandlerMixin {
return original;
}

@Inject(method = "handleResourcePackResponse", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ServerboundResourcePackPacket;getAction()Lnet/minecraft/network/protocol/game/ServerboundResourcePackPacket$Action;"))
private void apugli$sendUrlTexturesToPlayerAfterResourceLoad(ServerboundResourcePackPacket packet, CallbackInfo ci) {
if (packet.getAction() == ServerboundResourcePackPacket.Action.DECLINED && this.server.isResourcePackRequired()) return;
Services.PLATFORM.sendS2C(new UpdateUrlTexturesPacket(TextureUtil.getCache()), player);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ default <P> double applyModifiers(LivingEntity entity, ValueModifyingPowerFactor

Entity getEntityFromItemStack(ItemStack stack);

void setEntityToItemStack(ItemStack stack, Entity entity);

SerializableDataType<?> damageSourceDescriptionDataType();

DamageSource createDamageSource(DamageSources damageSources, SerializableData.Instance data, String typeFieldName, String descriptionFieldName);
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions common/src/main/resources/apugli.common.accesswidener
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
accessWidener v1 named
accessible class net/minecraft/client/Minecraft$GameLoadCookie
accessible class net/minecraft/client/renderer/ItemInHandRenderer$HandRenderSelection
accessible class net/minecraft/world/entity/animal/Cat$CatTemptGoal
accessible class net/minecraft/world/item/enchantment/EnchantmentHelper$EnchantmentVisitor
Expand Down
5 changes: 2 additions & 3 deletions common/src/main/resources/apugli.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17",
"mixins": [
"client.AbstractClientPlayerMixin",
"common.AnvilScreenHandlerMixin",
"common.BeehiveBlockEntityMixin",
"common.BeehiveBlockMixin",
"common.BlockItemMixin",
"common.EnchantmentHelperMixin",
"common.EnchantmentMixin",
"common.EntityMixin",
"common.ExplosionMixin",
"common.ItemStackMixin",
Expand All @@ -34,7 +33,6 @@
"common.accessor.TridentEntityAccessor"
],
"client": [
"client.AbstractClientPlayerEntityMixin",
"client.AbstractSoundInstanceMixin",
"client.ArmorFeatureRendererMixin",
"client.CapeFeatureRendererMixin",
Expand All @@ -46,6 +44,7 @@
"client.MinecraftClientMixin",
"client.ParticleMixin",
"client.PlayerEntityRendererMixin",
"client.PlayerSkinMixin",
"client.PositionedSoundInstanceMixin",
"client.SoundSystemMixin",
"client.WorldRendererMixin",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.merchantpug.apugli.platform.Services;
import net.merchantpug.apugli.power.ActionOnJumpPower;
import net.merchantpug.apugli.registry.power.ApugliPowers;
import net.merchantpug.apugli.util.IndividualisedEmptyStackUtil;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.Tuple;
Expand Down Expand Up @@ -53,11 +52,6 @@ public LivingEntityMixin(EntityType<?> entityType, Level level) {
Services.POWER.getPowers((LivingEntity)(Object)this, ApugliPowers.ACTION_ON_JUMP.get()).forEach(ActionOnJumpPower::executeAction);
}

@Inject(method = "tick", at = @At("HEAD"))
private void apugli$setItemStackEntities(CallbackInfo ci) {
IndividualisedEmptyStackUtil.addEntityToStack((LivingEntity)(Object)this);
}

@Inject(method = "hurt", at = @At("RETURN"))
private void apugli$runDamageFunctions(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (!cir.getReturnValue()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.world.level.Level;
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.ModifyArg;

@Mixin(Player.class)
Expand All @@ -17,7 +18,6 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, Level
super(entityType, level);
}


@ModifyArg(method = "updatePlayerPose", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;setPose(Lnet/minecraft/world/entity/Pose;)V"))
private Pose apugli$setPlayerToCrawl(Pose pose) {
if (Services.POWER.hasPower(this, ApugliPowers.CRAWLING.get()) && (pose == Pose.STANDING || pose == Pose.CROUCHING)) {
Expand Down
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);
}
}
Loading

0 comments on commit 31c1a09

Please sign in to comment.