parent
f9499a729a
commit
345f4669d3
@ -68,6 +68,7 @@ import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@ -83,6 +84,7 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SuppressWarnings({"ConstantConditions", "Guava"})
|
||||
@Mixin(LivingEntity.class)
|
||||
@ -679,6 +681,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
||||
final boolean human = (Object) this instanceof PlayerEntity;
|
||||
|
||||
f = net.minecraftforge.common.ForgeHooks.onLivingHurt((LivingEntity) (Object) this, damagesource, f);
|
||||
if (f <= 0) return true;
|
||||
|
||||
float originalDamage = f;
|
||||
Function<Double, Double> hardHat = f12 -> {
|
||||
@ -1019,6 +1022,11 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
||||
return drops == null ? livingEntity.captureDrops(value) : drops;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "spawnDrops", index = 0, at = @At(value = "INVOKE", remap = false, target = "Ljava/util/Collection;forEach(Ljava/util/function/Consumer;)V"))
|
||||
private Consumer<ItemEntity> arclight$cancelEvent(Consumer<ItemEntity> consumer) {
|
||||
return this instanceof ServerPlayerEntityBridge ? itemEntity -> {} : consumer;
|
||||
}
|
||||
|
||||
@Inject(method = "canEntityBeSeen", cancellable = true, at = @At("HEAD"))
|
||||
private void arclight$seeNoEvil(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (this.world != entityIn.world) {
|
||||
|
||||
@ -20,6 +20,7 @@ import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.passive.horse.AbstractHorseEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.SpawnLocationHelper;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@ -319,6 +320,13 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
||||
return;
|
||||
}
|
||||
boolean keepInventory = this.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY) || this.isSpectator();
|
||||
PlayerInventory copyInv;
|
||||
if (keepInventory) {
|
||||
copyInv = this.inventory;
|
||||
} else {
|
||||
copyInv = new PlayerInventory((ServerPlayerEntity) (Object) this);
|
||||
copyInv.copyInventory(this.inventory);
|
||||
}
|
||||
this.spawnDrops(damagesource);
|
||||
|
||||
ITextComponent defaultMessage = this.getCombatTracker().getDeathMessage();
|
||||
@ -328,6 +336,9 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
||||
CraftItemStack craftItemStack = CraftItemStack.asCraftMirror(entity.getItem());
|
||||
loot.add(craftItemStack);
|
||||
}
|
||||
if (!keepInventory) {
|
||||
this.inventory.copyInventory(copyInv);
|
||||
}
|
||||
PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent((ServerPlayerEntity) (Object) this, loot, deathmessage, keepInventory);
|
||||
if (this.openContainer != this.container) {
|
||||
this.closeScreen();
|
||||
|
||||
@ -26,7 +26,8 @@ public class EntityEventDispatcher {
|
||||
// recapture for ServerPlayerEntityMixin#onDeath
|
||||
event.getEntityLiving().captureDrops(event.getDrops());
|
||||
// handled at ServerPlayerEntityMixin
|
||||
event.setCanceled(true);
|
||||
// Cancelled at io.izzel.arclight.common.mixin.core.entity.LivingEntityMixin#arclight$cancelEvent
|
||||
// event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
LivingEntity livingEntity = event.getEntityLiving();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user