From 8ef7cc3ee166e67d37a170d51fb06a31fe1d169f Mon Sep 17 00:00:00 2001 From: Luke100000 Date: Tue, 1 Aug 2023 10:21:55 +0200 Subject: [PATCH] fixed server crash --- changelog.md | 4 + .../java/net/mca/mixin/MixinPlayerEntity.java | 23 ------ .../mixin/client/MixinPlayerEntityClient.java | 40 ++++++++++ common/src/main/resources/mca.mixin.json | 77 ++++++++++--------- 4 files changed, 83 insertions(+), 61 deletions(-) create mode 100644 common/src/main/java/net/mca/mixin/client/MixinPlayerEntityClient.java diff --git a/changelog.md b/changelog.md index 591cef3bd1..96cacdcde7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# 7.5.5 + +* Fixed server crash + # 7.5.4 * Removed size requirements of blueprint buildings diff --git a/common/src/main/java/net/mca/mixin/MixinPlayerEntity.java b/common/src/main/java/net/mca/mixin/MixinPlayerEntity.java index d831dfcd48..4a4188ae10 100644 --- a/common/src/main/java/net/mca/mixin/MixinPlayerEntity.java +++ b/common/src/main/java/net/mca/mixin/MixinPlayerEntity.java @@ -1,11 +1,7 @@ package net.mca.mixin; -import net.mca.Config; -import net.mca.MCAClient; import net.mca.item.BabyItem; import net.mca.server.world.data.VillageManager; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityPose; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; @@ -39,23 +35,4 @@ private void onDropItem(ItemStack stack, boolean throwRandomly, boolean retainOw info.setReturnValue(null); } } - - @Inject(method = "getActiveEyeHeight(Lnet/minecraft/entity/EntityPose;Lnet/minecraft/entity/EntityDimensions;)F", at = @At("HEAD"), cancellable = true) - public void mca$getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions, CallbackInfoReturnable cir) { - if (Config.getInstance().adjustPlayerEyesToHeight) { - MCAClient.getPlayerData(getUuid()).ifPresent(data -> { - switch (pose) { - case SWIMMING, FALL_FLYING, SPIN_ATTACK -> { - cir.setReturnValue(0.4f * data.getRawScaleFactor()); - } - case CROUCHING -> { - cir.setReturnValue(1.27f * data.getRawScaleFactor()); - } - default -> { - cir.setReturnValue(1.62f * data.getRawScaleFactor()); - } - } - }); - } - } } diff --git a/common/src/main/java/net/mca/mixin/client/MixinPlayerEntityClient.java b/common/src/main/java/net/mca/mixin/client/MixinPlayerEntityClient.java new file mode 100644 index 0000000000..83c3084e41 --- /dev/null +++ b/common/src/main/java/net/mca/mixin/client/MixinPlayerEntityClient.java @@ -0,0 +1,40 @@ +package net.mca.mixin.client; + +import net.mca.Config; +import net.mca.MCAClient; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +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) +abstract class MixinPlayerEntityClient extends LivingEntity { + protected MixinPlayerEntityClient(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "getActiveEyeHeight(Lnet/minecraft/entity/EntityPose;Lnet/minecraft/entity/EntityDimensions;)F", at = @At("HEAD"), cancellable = true) + public void mca$getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions, CallbackInfoReturnable cir) { + if (Config.getInstance().adjustPlayerEyesToHeight) { + MCAClient.getPlayerData(getUuid()).ifPresent(data -> { + switch (pose) { + case SWIMMING, FALL_FLYING, SPIN_ATTACK -> { + cir.setReturnValue(0.4f * data.getRawScaleFactor()); + } + case CROUCHING -> { + cir.setReturnValue(1.27f * data.getRawScaleFactor()); + } + default -> { + cir.setReturnValue(1.62f * data.getRawScaleFactor()); + } + } + }); + } + } +} diff --git a/common/src/main/resources/mca.mixin.json b/common/src/main/resources/mca.mixin.json index 3662697af9..7b3177f817 100644 --- a/common/src/main/resources/mca.mixin.json +++ b/common/src/main/resources/mca.mixin.json @@ -1,40 +1,41 @@ { - "required": true, - "minVersion": "0.7", - "package": "net.mca.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "MixinAbstractFurnaceBlockEntity", - "MixinActivity", - "MixinCriteria", - "MixinDefaultParticleType", - "MixinEntityType", - "MixinGoatEntity", - "MixinHorseBaseEntity", - "MixinMemoryModuleType", - "MixinMilkBucketItem", - "MixinPlayerEntity", - "MixinPlayerInventory", - "MixinProtoChunk", - "MixinSensorType", - "MixinServerPlayNetworkHandler", - "MixinServerWorld", - "MixinTranslatableText", - "MixinVillagerEntity", - "MixinVillagerEntityInvoker", - "MixinVillagerProfession", - "MixinZombieVillagerEntity" - ], - "client": [ - "client.MixinArmorFeatureRenderer", - "client.MixinGameRenderer", - "client.MixinHeldItemFeatureRenderer", - "client.MixinMessageHandler", - "client.MixinLivingEntityRenderer", - "client.MixinPlayerEntityRenderer", - "client.MixinTranslationStorage" - ], - "injectors": { - "defaultRequire": 1 - } + "required": true, + "minVersion": "0.7", + "package": "net.mca.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "MixinAbstractFurnaceBlockEntity", + "MixinActivity", + "MixinCriteria", + "MixinDefaultParticleType", + "MixinEntityType", + "MixinGoatEntity", + "MixinHorseBaseEntity", + "MixinMemoryModuleType", + "MixinMilkBucketItem", + "MixinPlayerEntity", + "MixinPlayerInventory", + "MixinProtoChunk", + "MixinSensorType", + "MixinServerPlayNetworkHandler", + "MixinServerWorld", + "MixinTranslatableText", + "MixinVillagerEntity", + "MixinVillagerEntityInvoker", + "MixinVillagerProfession", + "MixinZombieVillagerEntity" + ], + "client": [ + "client.MixinArmorFeatureRenderer", + "client.MixinGameRenderer", + "client.MixinHeldItemFeatureRenderer", + "client.MixinLivingEntityRenderer", + "client.MixinMessageHandler", + "client.MixinPlayerEntityRenderer", + "client.MixinTranslationStorage", + "client.MixinPlayerEntityClient" + ], + "injectors": { + "defaultRequire": 1 + } }