1.0.6
SlightlyVanilla/pipeline/head This commit looks good Details

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
**1.0.6**
* Improve Instant Kill
**1.0.5**
* Crying Obsidian Nether Portal

View File

@ -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

View File

@ -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;
}
//noinspection ConstantConditions
target.damage(DamageSource.player((PlayerEntity) (Object) this), Float.MAX_VALUE);
@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;
}
}
}