Skip to content

Commit

Permalink
feat: improve compatibility with another mod
Browse files Browse the repository at this point in the history
Works on $4165 an incompatibility found while testing AllTheMods10.
  • Loading branch information
gabizou committed Jan 20, 2025
1 parent f20987a commit 87fa34b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/spongepowered/common/util/NetworkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public final class NetworkUtil {
* @return The string representation of the host
*/
public static String getHostString(final SocketAddress address) {
if (address instanceof InetSocketAddress) {
return ((InetSocketAddress) address).getHostString();
if (address instanceof InetSocketAddress isa) {
return isa.getHostString();
} else if (address instanceof LocalAddress) {
return NetworkUtil.LOCAL_ADDRESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
*/
package org.spongepowered.common.mixin.core.world.entity;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.stats.Stats;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.CombatRules;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
Expand Down Expand Up @@ -279,14 +280,14 @@ public abstract class LivingEntityMixin_Attack_Impl extends EntityMixin implemen
/**
* Captures the damage protection as a function
*/
@Redirect(method = "getDamageAfterMagicAbsorb",
@WrapOperation(method = "getDamageAfterMagicAbsorb",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterMagicAbsorb(FF)F"))
protected float attackImpl$onDetDamageProtection(final float damage, final float protection) {
protected float attackImpl$onDetDamageProtection(float damage, float protection, Operation<Float> original) {
if (this.attackImpl$actuallyHurt != null) {
var func = DamageEventUtil.createEnchantmentModifiers(this.attackImpl$actuallyHurt.entity(), protection);
this.attackImpl$actuallyHurt.functions().add(func);
}
return CombatRules.getDamageAfterMagicAbsorb(damage, protection);
return original.call(damage, protection);
}

/**
Expand Down

0 comments on commit 87fa34b

Please sign in to comment.