mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Re-added the patch for LivingExperienceDropEvent and enable it for dragons (#8388)
This commit is contained in:
1 parent
f19f7e4670
commit
82a20911cb
3 files changed
+51
-3
No files matched your search
@@ -228,6 +228,16 @@
|
||||
}
|
||||
|
||||
protected void m_5907_() {
|
||||
@@ -1306,7 +_,8 @@
|
||||
|
||||
protected void m_21226_() {
|
||||
if (this.f_19853_ instanceof ServerLevel && (this.m_6124_() || this.f_20889_ > 0 && this.m_6149_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46135_))) {
|
||||
- ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), this.m_6552_(this.f_20888_));
|
||||
+ int reward = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.f_20888_, this.m_6552_(this.f_20888_));
|
||||
+ ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), reward);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1322,7 +_,8 @@
|
||||
ResourceLocation resourcelocation = this.m_5743_();
|
||||
LootTable loottable = this.f_19853_.m_142572_().m_129898_().m_79217_(resourcelocation);
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
@@ -150,7 +_,11 @@
|
||||
return adouble;
|
||||
}
|
||||
|
||||
+ @javax.annotation.Nullable private Player unlimitedLastHurtByPlayer = null;
|
||||
public void m_8107_() {
|
||||
+ // lastHurtByPlayer is cleared after 100 ticks, capture it indefinitely in unlimitedLastHurtByPlayer for LivingExperienceDropEvent
|
||||
+ if (this.f_20888_ != null) this.unlimitedLastHurtByPlayer = f_20888_;
|
||||
+ if (this.unlimitedLastHurtByPlayer != null && this.unlimitedLastHurtByPlayer.m_146910_()) this.unlimitedLastHurtByPlayer = null;
|
||||
this.m_146874_();
|
||||
if (this.f_19853_.f_46443_) {
|
||||
this.m_21153_(this.m_21223_());
|
||||
@@ -420,7 +_,7 @@
|
||||
BlockPos blockpos = new BlockPos(k1, l1, i2);
|
||||
BlockState blockstate = this.f_19853_.m_8055_(blockpos);
|
||||
@@ -9,6 +21,26 @@
|
||||
flag1 = this.f_19853_.m_7471_(blockpos, false) || flag1;
|
||||
} else {
|
||||
flag = true;
|
||||
@@ -514,7 +_,8 @@
|
||||
|
||||
if (this.f_19853_ instanceof ServerLevel) {
|
||||
if (this.f_31084_ > 150 && this.f_31084_ % 5 == 0 && flag) {
|
||||
- ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), Mth.m_14143_((float)i * 0.08F));
|
||||
+ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.m_14143_((float)i * 0.08F));
|
||||
+ ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), award);
|
||||
}
|
||||
|
||||
if (this.f_31084_ == 1 && !this.m_20067_()) {
|
||||
@@ -527,7 +_,8 @@
|
||||
this.f_20883_ = this.m_146908_();
|
||||
if (this.f_31084_ == 200 && this.f_19853_ instanceof ServerLevel) {
|
||||
if (flag) {
|
||||
- ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), Mth.m_14143_((float)i * 0.2F));
|
||||
+ int award = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.unlimitedLastHurtByPlayer, Mth.m_14143_((float)i * 0.2F));
|
||||
+ ExperienceOrb.m_147082_((ServerLevel)this.f_19853_, this.m_20182_(), award);
|
||||
}
|
||||
|
||||
if (this.f_31073_ != null) {
|
||||
@@ -847,6 +_,16 @@
|
||||
|
||||
public boolean m_6072_() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
* Copyright (c) 2016-2022.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -23,6 +23,8 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Event for when an entity drops experience on its death, can be used to change
|
||||
* the amount of experience points dropped or completely prevent dropping of experience
|
||||
@@ -31,12 +33,12 @@ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@Cancelable
|
||||
public class LivingExperienceDropEvent extends LivingEvent
|
||||
{
|
||||
private final Player attackingPlayer;
|
||||
@Nullable private final Player attackingPlayer;
|
||||
private final int originalExperiencePoints;
|
||||
|
||||
private int droppedExperiencePoints;
|
||||
|
||||
public LivingExperienceDropEvent(LivingEntity entity, Player attackingPlayer, int originalExperience)
|
||||
public LivingExperienceDropEvent(LivingEntity entity, @Nullable Player attackingPlayer, int originalExperience)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
@@ -54,6 +56,10 @@ public class LivingExperienceDropEvent extends LivingEvent
|
||||
this.droppedExperiencePoints = droppedExperience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The player that last attacked the entity and thus caused the experience. This can be null, in case the player has since logged out.
|
||||
*/
|
||||
@Nullable
|
||||
public Player getAttackingPlayer()
|
||||
{
|
||||
return attackingPlayer;
|
||||
|
||||
Reference in new issue
Block a user