27 lines
1.1 KiB
Java
27 lines
1.1 KiB
Java
package com.thebrokenrail.slightlyvanilla.mixin;
|
|
|
|
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.boss.dragon.EnderDragonPart;
|
|
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.Inject;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
@SuppressWarnings("unused")
|
|
@Mixin(PlayerEntity.class)
|
|
public class MixinPlayerEntity {
|
|
@Inject(at = @At("HEAD"), method = "attack", cancellable = true)
|
|
public void attack(Entity target, CallbackInfo info) {
|
|
if (SlightlyVanilla.getConfig().instantKillInCreative && target.isAttackable()) {
|
|
if (target instanceof EnderDragonPart) {
|
|
target = ((EnderDragonPart)target).owner;
|
|
}
|
|
//noinspection ConstantConditions
|
|
target.damage(DamageSource.player((PlayerEntity) (Object) this), Float.MAX_VALUE);
|
|
}
|
|
}
|
|
}
|