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

26 lines
1.1 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.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;
@Mixin(PlayerEntity.class)
public class MixinPlayerEntity {
@Inject(at = @At("HEAD"), method = "attack", cancellable = true)
public void attack(Entity target, CallbackInfo info) {
if (SlightlyVanilla.getConfig().instantlyKillInCreative && target.isAttackable()) {
if (target instanceof EnderDragonPart) {
target = ((EnderDragonPart)target).owner;
}
//noinspection ConstantConditions
target.damage(DamageSource.player((PlayerEntity) (Object) this), Float.MAX_VALUE);
}
}
}