Commits

DerFrZocker authored and md_5 committed 6866aab59a3
SPIGOT-2420: Can't set exp drops for EnderDragon death
No tags

nms-patches/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.patch

Modified
120 120 + nmsBlock.wasExploded(level, blockposition, explosionSource);
121 121 +
122 122 + this.level.removeBlock(blockposition, false);
123 123 + }
124 124 + }
125 125 + // CraftBukkit end
126 126 +
127 127 if (flag1) {
128 128 BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
129 129
130 +@@ -531,6 +603,21 @@
131 +
132 + }
133 +
134 ++ // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time.
135 ++ @Override
136 ++ public int getExpReward() {
137 ++ // CraftBukkit - Moved from #tickDeath method
138 ++ boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
139 ++ short short0 = 500;
140 ++
141 ++ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
142 ++ short0 = 12000;
143 ++ }
144 ++
145 ++ return flag ? short0 : 0;
146 ++ }
147 ++ // CraftBukkit end
148 ++
149 + @Override
150 + protected void tickDeath() {
151 + if (this.dragonFight != null) {
152 +@@ -546,15 +633,20 @@
153 + this.level.addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
154 + }
155 +
156 ++ // CraftBukkit start - SPIGOT-2420: Moved up to #getExpReward method
157 ++ /*
158 + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
159 + short short0 = 500;
160 +
161 + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
162 + short0 = 12000;
163 + }
164 ++ */
165 ++ int short0 = expToDrop;
166 ++ // CraftBukkit end
167 +
168 + if (this.level instanceof WorldServer) {
169 +- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) {
170 ++ if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
171 + EntityExperienceOrb.award((WorldServer) this.level, this.position(), MathHelper.floor((float) short0 * 0.08F));
172 + }
173 +
174 +@@ -567,7 +659,7 @@
175 + this.setYRot(this.getYRot() + 20.0F);
176 + this.yBodyRot = this.getYRot();
177 + if (this.dragonDeathTime == 200 && this.level instanceof WorldServer) {
178 +- if (flag) {
179 ++ if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
180 + EntityExperienceOrb.award((WorldServer) this.level, this.position(), MathHelper.floor((float) short0 * 0.2F));
181 + }
182 +
183 +@@ -788,6 +880,7 @@
184 + super.addAdditionalSaveData(nbttagcompound);
185 + nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
186 + nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime);
187 ++ nbttagcompound.putInt("Bukkit.expToDrop", expToDrop); // CraftBukkit - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts
188 + }
189 +
190 + @Override
191 +@@ -801,6 +894,11 @@
192 + this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime");
193 + }
194 +
195 ++ // CraftBukkit start - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts
196 ++ if (nbttagcompound.contains("Bukkit.expToDrop")) {
197 ++ this.expToDrop = nbttagcompound.getInt("Bukkit.expToDrop");
198 ++ }
199 ++ // CraftBukkit end
200 + }
201 +
202 + @Override

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut