23 lines
928 B
Java
23 lines
928 B
Java
package com.thebrokenrail.slightlyvanilla.mixin;
|
|
|
|
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
|
import net.minecraft.entity.damage.DamageSource;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
|
|
|
@SuppressWarnings("unused")
|
|
@Mixin(PlayerEntity.class)
|
|
public class MixinPlayerEntity {
|
|
@ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z"), method = "attack", index = 1)
|
|
public float changeDamage(DamageSource source, float amount) {
|
|
//noinspection ConstantConditions
|
|
if (SlightlyVanilla.getConfig().instantKillInCreative && ((PlayerEntity) (Object) this).isCreative()) {
|
|
return Float.MAX_VALUE;
|
|
} else {
|
|
return amount;
|
|
}
|
|
}
|
|
}
|