Improve Instant Kill
This commit is contained in:
parent
c85c8798f1
commit
003726ef22
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.6**
|
||||
* Improve Instant Kill
|
||||
|
||||
**1.0.5**
|
||||
* Crying Obsidian Nether Portal
|
||||
|
||||
|
@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
|
||||
fabric_loader_version = 0.7.8+build.189
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.5
|
||||
mod_version = 1.0.6
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = slightlyvanilla
|
||||
|
||||
|
@ -1,26 +1,22 @@
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@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;
|
||||
}
|
||||
@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
|
||||
target.damage(DamageSource.player((PlayerEntity) (Object) this), Float.MAX_VALUE);
|
||||
if (SlightlyVanilla.getConfig().instantKillInCreative && ((PlayerEntity) (Object) this).isCreative()) {
|
||||
return Float.MAX_VALUE;
|
||||
} else {
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user