Skip to content

Commit

Permalink
fixed server crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Aug 1, 2023
1 parent 8fb958f commit 8ef7cc3
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 61 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 7.5.5

* Fixed server crash

# 7.5.4

* Removed size requirements of blueprint buildings
Expand Down
23 changes: 0 additions & 23 deletions common/src/main/java/net/mca/mixin/MixinPlayerEntity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Float> 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());
}
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -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<? extends LivingEntity> 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<Float> 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());
}
}
});
}
}
}
77 changes: 39 additions & 38 deletions common/src/main/resources/mca.mixin.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 8ef7cc3

Please sign in to comment.