This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
2020-03-19 19:45:46 +00:00
|
|
|
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;
|
2020-03-20 23:18:56 +00:00
|
|
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
2020-03-19 19:45:46 +00:00
|
|
|
|
2020-03-19 21:33:44 +00:00
|
|
|
@SuppressWarnings("unused")
|
2020-03-19 19:45:46 +00:00
|
|
|
@Mixin(PlayerEntity.class)
|
|
|
|
public class MixinPlayerEntity {
|
2020-03-20 23:18:56 +00:00
|
|
|
@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;
|
2020-03-19 19:45:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|