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.
SlightlyVanilla/src/main/java/com/thebrokenrail/slightlyvanilla/mixin/MixinPlayerEntity.java

35 lines
1.5 KiB
Java
Raw Normal View History

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.PlayerAbilities;
2020-03-19 19:45:46 +00:00
import net.minecraft.entity.player.PlayerEntity;
import org.objectweb.asm.Opcodes;
2020-03-19 19:45:46 +00:00
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;
import org.spongepowered.asm.mixin.injection.Redirect;
2020-03-19 19:45:46 +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
}
}
@Redirect(at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/player/PlayerAbilities;invulnerable:Z"), method = "getMaxNetherPortalTime")
public boolean adjustMaxNetherPortalTime(PlayerAbilities playerAbilities) {
if (SlightlyVanilla.getConfig().disableInstantNetherPortalInCreative) {
return false;
} else {
return playerAbilities.invulnerable;
}
}
2020-03-19 19:45:46 +00:00
}