From 31c1a09c070fdbad0679da61dffbdbad30f9caab Mon Sep 17 00:00:00 2001 From: Pug <81167232+MerchantPug@users.noreply.github.com> Date: Mon, 13 Nov 2023 06:45:47 +1100 Subject: [PATCH] Fix remaining build errors. --- .../apugli/access/PlayerSkinAccess.java | 7 +++ .../renderer/PowerHumanoidArmorLayer.java | 2 +- .../entity/PlayerModelTypeCondition.java | 2 +- .../AbstractClientPlayerEntityMixin.java | 40 --------------- .../client/AbstractClientPlayerMixin.java | 29 +++++++++++ .../client/MinecraftClientMixin.java | 5 +- .../xplatform/client/PlayerSkinMixin.java | 43 ++++++++++++++++ .../xplatform/common/BeehiveBlockMixin.java | 5 +- .../xplatform/common/ItemStackMixin.java | 7 --- .../common/ServerPlayNetworkHandlerMixin.java | 15 ------ .../platform/services/IPlatformHelper.java | 2 - .../util/IndividualisedEmptyStackUtil.java | 50 ------------------- .../resources/apugli.common.accesswidener | 1 + common/src/main/resources/apugli.mixins.json | 5 +- .../apugli/access/ItemStackAccess.java | 8 --- .../fabric/common/LivingEntityMixin.java | 6 --- .../fabric/common/PlayerEntityMixin.java | 2 +- .../mixin/fabric/common/PlayerListMixin.java | 21 ++++++++ .../apugli/platform/FabricPlatformHelper.java | 9 +--- .../src/main/resources/apugli.accesswidener | 1 + .../main/resources/apugli.fabric.mixins.json | 6 +-- gradle.properties | 4 +- 22 files changed, 118 insertions(+), 152 deletions(-) create mode 100644 common/src/main/java/net/merchantpug/apugli/access/PlayerSkinAccess.java delete mode 100644 common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerEntityMixin.java create mode 100644 common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerMixin.java create mode 100644 common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/PlayerSkinMixin.java delete mode 100644 common/src/main/java/net/merchantpug/apugli/util/IndividualisedEmptyStackUtil.java delete mode 100644 fabric/src/main/java/net/merchantpug/apugli/access/ItemStackAccess.java create mode 100644 fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerListMixin.java diff --git a/common/src/main/java/net/merchantpug/apugli/access/PlayerSkinAccess.java b/common/src/main/java/net/merchantpug/apugli/access/PlayerSkinAccess.java new file mode 100644 index 00000000..caca8002 --- /dev/null +++ b/common/src/main/java/net/merchantpug/apugli/access/PlayerSkinAccess.java @@ -0,0 +1,7 @@ +package net.merchantpug.apugli.access; + +import net.minecraft.world.entity.player.Player; + +public interface PlayerSkinAccess { + void apugli$setPlayer(Player player); +} diff --git a/common/src/main/java/net/merchantpug/apugli/client/renderer/PowerHumanoidArmorLayer.java b/common/src/main/java/net/merchantpug/apugli/client/renderer/PowerHumanoidArmorLayer.java index 10d7dd7e..e8f6f68c 100644 --- a/common/src/main/java/net/merchantpug/apugli/client/renderer/PowerHumanoidArmorLayer.java +++ b/common/src/main/java/net/merchantpug/apugli/client/renderer/PowerHumanoidArmorLayer.java @@ -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()) { diff --git a/common/src/main/java/net/merchantpug/apugli/condition/factory/entity/PlayerModelTypeCondition.java b/common/src/main/java/net/merchantpug/apugli/condition/factory/entity/PlayerModelTypeCondition.java index 16355aae..2b0a3906 100644 --- a/common/src/main/java/net/merchantpug/apugli/condition/factory/entity/PlayerModelTypeCondition.java +++ b/common/src/main/java/net/merchantpug/apugli/condition/factory/entity/PlayerModelTypeCondition.java @@ -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()); } } diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerEntityMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerEntityMixin.java deleted file mode 100644 index 6ebc7c56..00000000 --- a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerEntityMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.merchantpug.apugli.mixin.xplatform.client; - -import com.mojang.authlib.GameProfile; -import io.github.apace100.apoli.Apoli; -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.player.AbstractClientPlayer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.player.Player; -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.callback.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(AbstractClientPlayer.class) -public abstract class AbstractClientPlayerEntityMixin extends Player { - - public AbstractClientPlayerEntityMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile) { - super(level, blockPos, f, gameProfile); - } - - @Inject(method = "getModelName", at = @At("HEAD"), cancellable = true) - private void apugli$getModel(CallbackInfoReturnable cir) { - List playerModelTypePowers = Services.POWER.getPowers(this, ApugliPowers.PLAYER_MODEL_TYPE.get()); - List setTexturePowers = Services.POWER.getPowers(this, ApugliPowers.SET_TEXTURE.get()).stream().filter(p -> p.getModel() != null).toList(); - if(playerModelTypePowers.size() + setTexturePowers.size() > 1) { - Apoli.LOGGER.warn("Entity " + this.getDisplayName() + " has two instances of player model setting powers active."); - } - if(playerModelTypePowers.size() > 0) { - cir.setReturnValue(Services.POWER.getPowers(this, ApugliPowers.PLAYER_MODEL_TYPE.get()).get(0).getModel().toString()); - } else if (setTexturePowers.size() > 0) { - cir.setReturnValue(Services.POWER.getPowers(this, ApugliPowers.SET_TEXTURE.get()).get(0).getModel().toString()); - } - } -} diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerMixin.java new file mode 100644 index 00000000..407e8db9 --- /dev/null +++ b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/AbstractClientPlayerMixin.java @@ -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 cir) { + ((PlayerSkinAccess)(Object)this.playerInfo.getSkin()).apugli$setPlayer(this); + } +} diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/MinecraftClientMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/MinecraftClientMixin.java index 73edcab0..8075a604 100644 --- a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/MinecraftClientMixin.java +++ b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/MinecraftClientMixin.java @@ -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; @@ -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> 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> cir) { for (Map.Entry entry : TextureUtilClient.getUrls().entrySet()) { ResourceLocation textureLocation = entry.getKey(); String url = entry.getValue(); diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/PlayerSkinMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/PlayerSkinMixin.java new file mode 100644 index 00000000..a8212eb3 --- /dev/null +++ b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/client/PlayerSkinMixin.java @@ -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 cir) { + List playerModelTypePowers = Services.POWER.getPowers(this.apugli$player, ApugliPowers.PLAYER_MODEL_TYPE.get()); + List 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; + } +} diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/BeehiveBlockMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/BeehiveBlockMixin.java index 772db6ca..aed69e20 100644 --- a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/BeehiveBlockMixin.java +++ b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/BeehiveBlockMixin.java @@ -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; @@ -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 list, List 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 list, List list2) { if (list2.stream().anyMatch(player -> Services.POWER.hasPower(player, ApugliPowers.PREVENT_BEE_ANGER.get()))) { ci.cancel(); } diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ItemStackMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ItemStackMixin.java index 3781fb44..360d6308 100644 --- a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ItemStackMixin.java +++ b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ItemStackMixin.java @@ -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 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) { diff --git a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ServerPlayNetworkHandlerMixin.java b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ServerPlayNetworkHandlerMixin.java index dbc1b8f6..6a7bc6c9 100644 --- a/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ServerPlayNetworkHandlerMixin.java +++ b/common/src/main/java/net/merchantpug/apugli/mixin/xplatform/common/ServerPlayNetworkHandlerMixin.java @@ -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()); @@ -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); - } - } diff --git a/common/src/main/java/net/merchantpug/apugli/platform/services/IPlatformHelper.java b/common/src/main/java/net/merchantpug/apugli/platform/services/IPlatformHelper.java index 7dab8271..71c7e15a 100644 --- a/common/src/main/java/net/merchantpug/apugli/platform/services/IPlatformHelper.java +++ b/common/src/main/java/net/merchantpug/apugli/platform/services/IPlatformHelper.java @@ -115,8 +115,6 @@ default

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); diff --git a/common/src/main/java/net/merchantpug/apugli/util/IndividualisedEmptyStackUtil.java b/common/src/main/java/net/merchantpug/apugli/util/IndividualisedEmptyStackUtil.java deleted file mode 100644 index 71538c13..00000000 --- a/common/src/main/java/net/merchantpug/apugli/util/IndividualisedEmptyStackUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.merchantpug.apugli.util; - -import net.merchantpug.apugli.platform.Services; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; - -import java.util.HashMap; -import java.util.Map; - -public class IndividualisedEmptyStackUtil { - - private static final Map ENTITY_EMPTY_STACK_MAP = new HashMap<>(); - - public static ItemStack getEntityLinkedEmptyStack(Entity entity) { - if (!ENTITY_EMPTY_STACK_MAP.containsKey(entity)) { - ItemStack stack = new ItemStack((Void) null); - Services.PLATFORM.setEntityToItemStack(stack, entity); - ENTITY_EMPTY_STACK_MAP.put(entity, stack); - } - return ENTITY_EMPTY_STACK_MAP.get(entity); - } - - public static void addEntityToStack(LivingEntity entity) { - if (entity.isRemoved() && ENTITY_EMPTY_STACK_MAP.containsKey(entity)) { - ENTITY_EMPTY_STACK_MAP.remove(entity); - return; - } - - for (EquipmentSlot slot : EquipmentSlot.values()) { - ItemStack stack = entity.getItemBySlot(slot); - - // Fix for Better Combat https://github.com/ZsoltMolnarrr/BetterCombat/issues/268. - if (Services.PLATFORM.isModLoaded("bettercombat") && slot == EquipmentSlot.OFFHAND && entity instanceof Player player) { - stack = player.getInventory().offhand.get(0); - } - - if (Services.PLATFORM.getEntityFromItemStack(stack) == null) { - if (stack == ItemStack.EMPTY) { - ItemStack newStack = getEntityLinkedEmptyStack(entity); - entity.setItemSlot(slot, newStack); - } else - Services.PLATFORM.setEntityToItemStack(stack, entity); - } - } - } - -} diff --git a/common/src/main/resources/apugli.common.accesswidener b/common/src/main/resources/apugli.common.accesswidener index 37234171..9750ff04 100644 --- a/common/src/main/resources/apugli.common.accesswidener +++ b/common/src/main/resources/apugli.common.accesswidener @@ -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 diff --git a/common/src/main/resources/apugli.mixins.json b/common/src/main/resources/apugli.mixins.json index 1a6655bd..8fa2c725 100644 --- a/common/src/main/resources/apugli.mixins.json +++ b/common/src/main/resources/apugli.mixins.json @@ -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", @@ -34,7 +33,6 @@ "common.accessor.TridentEntityAccessor" ], "client": [ - "client.AbstractClientPlayerEntityMixin", "client.AbstractSoundInstanceMixin", "client.ArmorFeatureRendererMixin", "client.CapeFeatureRendererMixin", @@ -46,6 +44,7 @@ "client.MinecraftClientMixin", "client.ParticleMixin", "client.PlayerEntityRendererMixin", + "client.PlayerSkinMixin", "client.PositionedSoundInstanceMixin", "client.SoundSystemMixin", "client.WorldRendererMixin", diff --git a/fabric/src/main/java/net/merchantpug/apugli/access/ItemStackAccess.java b/fabric/src/main/java/net/merchantpug/apugli/access/ItemStackAccess.java deleted file mode 100644 index 2fddb29a..00000000 --- a/fabric/src/main/java/net/merchantpug/apugli/access/ItemStackAccess.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.merchantpug.apugli.access; - -import net.minecraft.world.entity.Entity; - -public interface ItemStackAccess { - Entity apugli$getEntity(); - void apugli$setEntity(Entity entity); -} diff --git a/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/LivingEntityMixin.java b/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/LivingEntityMixin.java index c2fabf32..d4f30146 100644 --- a/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/LivingEntityMixin.java +++ b/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/LivingEntityMixin.java @@ -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; @@ -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 cir) { if (!cir.getReturnValue()) return; diff --git a/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerEntityMixin.java b/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerEntityMixin.java index b0834acc..9ee54121 100644 --- a/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerEntityMixin.java +++ b/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerEntityMixin.java @@ -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) @@ -17,7 +18,6 @@ protected PlayerEntityMixin(EntityType 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)) { diff --git a/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerListMixin.java b/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerListMixin.java new file mode 100644 index 00000000..6662824a --- /dev/null +++ b/fabric/src/main/java/net/merchantpug/apugli/mixin/fabric/common/PlayerListMixin.java @@ -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); + } +} diff --git a/fabric/src/main/java/net/merchantpug/apugli/platform/FabricPlatformHelper.java b/fabric/src/main/java/net/merchantpug/apugli/platform/FabricPlatformHelper.java index 21a5a5c1..f857d4d6 100644 --- a/fabric/src/main/java/net/merchantpug/apugli/platform/FabricPlatformHelper.java +++ b/fabric/src/main/java/net/merchantpug/apugli/platform/FabricPlatformHelper.java @@ -2,6 +2,7 @@ import com.google.auto.service.AutoService; import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes; +import io.github.apace100.apoli.access.EntityLinkedItemStack; import io.github.apace100.apoli.component.PowerHolderComponent; import io.github.apace100.apoli.data.ApoliDataTypes; import io.github.apace100.apoli.mixin.EyeHeightAccess; @@ -16,7 +17,6 @@ import io.github.apace100.calio.data.SerializableDataType; import net.fabricmc.fabric.api.networking.v1.PlayerLookup; import net.fabricmc.loader.api.FabricLoader; -import net.merchantpug.apugli.access.ItemStackAccess; import net.merchantpug.apugli.component.ApugliEntityComponents; import net.merchantpug.apugli.component.HitsOnTargetComponent; import net.merchantpug.apugli.component.KeyPressComponent; @@ -174,12 +174,7 @@ public float getEntityEyeHeight(Entity entity) { @Override public Entity getEntityFromItemStack(ItemStack stack) { - return stack == null ? null : ((ItemStackAccess)(Object)stack).apugli$getEntity(); - } - - @Override - public void setEntityToItemStack(ItemStack stack, Entity entity) { - ((ItemStackAccess)(Object)stack).apugli$setEntity(entity); + return stack == null ? null : ((EntityLinkedItemStack)(Object)stack).apoli$getEntity(); } @Override diff --git a/fabric/src/main/resources/apugli.accesswidener b/fabric/src/main/resources/apugli.accesswidener index 37234171..9750ff04 100644 --- a/fabric/src/main/resources/apugli.accesswidener +++ b/fabric/src/main/resources/apugli.accesswidener @@ -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 diff --git a/fabric/src/main/resources/apugli.fabric.mixins.json b/fabric/src/main/resources/apugli.fabric.mixins.json index 46bf6248..1f4fa447 100644 --- a/fabric/src/main/resources/apugli.fabric.mixins.json +++ b/fabric/src/main/resources/apugli.fabric.mixins.json @@ -9,15 +9,11 @@ "common.ActionTypeMixin", "common.AnimalEntityMixin", "common.BoneMealItemMixin", - "common.EnchantmentHelperMixin", - "common.EntityConditionsMixin", - "common.HungerManagerMixin", - "common.ItemPredicateMixin", - "common.ItemStackMixin", "common.LightningBoltMixin", "common.LivingEntityMixin", "common.MobEntityMixin", "common.PlayerEntityMixin", + "common.PlayerListMixin", "common.ProjectileEntityMixin", "common.ServerPlayNetworkHandlerMixin", "common.accessor.BucketItemAccessor", diff --git a/gradle.properties b/gradle.properties index 68edf652..daa07aa7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,14 +18,14 @@ aea_forge_version=1.4.0.4 # Fabric fabric_loader_version=0.14.24 -fabric_version=0.90.4+1.20.1 +fabric_version=0.90.4+1.20.2 calio_fabric_version=v1.12.2 apoli_fabric_version=v2.10.3 reach_version=2.4.0 modmenu_version=8.0.0 midnightlib_version=1.5.0-fabric -# Mod Properties +# Mod PropertieswrapOperation$bkg000$apoli$overrideProgressExperienceBarSprite$mixinextras$bridge$117 mod_name=Apugli mod_id=apugli version=2.8.0