Skip to content

Commit

Permalink
fix: dedicated server launch
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Jan 24, 2025
1 parent dae046d commit f7658ec
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,29 @@
package com.ishland.raknetify.fabric.mixin.common.quirks;

import com.ishland.raknetify.fabric.common.quirks.ClientHungerManager;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.HungerManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
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.CallbackInfo;

@Mixin(PlayerEntity.class)
public class MixinPlayerEntity {
public abstract class MixinPlayerEntity extends LivingEntity {

@Shadow protected HungerManager hungerManager;

protected MixinPlayerEntity(EntityType<? extends LivingEntity> entityType, World world) {
super(entityType, world);
}

@Inject(method = "<init>", at = @At("RETURN"), remap = false)
private void replaceHungerManager(CallbackInfo ci) {
if ((Object) this instanceof ClientPlayerEntity) {
if (this.getWorld().isClient) {
this.hungerManager = ClientHungerManager.from(this.hungerManager);
}
}
Expand Down

0 comments on commit f7658ec

Please sign in to comment.