1.0.6
All checks were successful
SlightlyVanilla/pipeline/head This commit looks good

Improve Instant Kill
This commit is contained in:
TheBrokenRail 2020-03-20 19:18:56 -04:00
parent c85c8798f1
commit 003726ef22
3 changed files with 12 additions and 13 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**1.0.6**
* Improve Instant Kill
**1.0.5** **1.0.5**
* Crying Obsidian Nether Portal * Crying Obsidian Nether Portal

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.7.8+build.189 fabric_loader_version = 0.7.8+build.189
# Mod Properties # Mod Properties
mod_version = 1.0.5 mod_version = 1.0.6
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
archives_base_name = slightlyvanilla archives_base_name = slightlyvanilla

View File

@ -1,26 +1,22 @@
package com.thebrokenrail.slightlyvanilla.mixin; package com.thebrokenrail.slightlyvanilla.mixin;
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla; 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.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Mixin(PlayerEntity.class) @Mixin(PlayerEntity.class)
public class MixinPlayerEntity { public class MixinPlayerEntity {
@Inject(at = @At("HEAD"), method = "attack", cancellable = true) @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z"), method = "attack", index = 1)
public void attack(Entity target, CallbackInfo info) { public float changeDamage(DamageSource source, float amount) {
if (SlightlyVanilla.getConfig().instantKillInCreative && target.isAttackable()) {
if (target instanceof EnderDragonPart) {
target = ((EnderDragonPart)target).owner;
}
//noinspection ConstantConditions //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;
} }
} }
} }