2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Max Lee <max@themoep.de>
Date: Thu, 27 May 2021 14:52:30 -0700
Subject: [PATCH] Fix invulnerable end crystals
MC-108513
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
2024-10-23 20:15:25 +02:00
index 671e8aa7ecc2b3fcc98af62356ff690a2604bcb0..7cb3d69a69e0e3ef4b7f9f9c8b1eb67edb5d116d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -30,6 +30,7 @@ public class EndCrystal extends Entity {
2021-06-11 14:02:28 +02:00
private static final EntityDataAccessor<Optional<BlockPos>> DATA_BEAM_TARGET = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.OPTIONAL_BLOCK_POS);
private static final EntityDataAccessor<Boolean> DATA_SHOW_BOTTOM = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.BOOLEAN);
public int time;
+ public boolean generatedByDragonFight = false; // Paper - Fix invulnerable end crystals
public EndCrystal(EntityType<? extends EndCrystal> type, Level world) {
super(type, world);
2024-06-14 01:32:45 +02:00
@@ -68,6 +69,17 @@ public class EndCrystal extends Entity {
2021-06-11 14:02:28 +02:00
}
// CraftBukkit end
}
+ // Paper start - Fix invulnerable end crystals
2023-06-08 22:56:13 +02:00
+ if (this.level().paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) {
+ if (!java.util.Objects.equals(((ServerLevel) this.level()).uuid, this.getOriginWorld())
+ || ((ServerLevel) this.level()).getDragonFight() == null
+ || ((ServerLevel) this.level()).getDragonFight().respawnStage == null
+ || ((ServerLevel) this.level()).getDragonFight().respawnStage.ordinal() > net.minecraft.world.level.dimension.end.DragonRespawnAnimation.SUMMONING_DRAGON.ordinal()) {
2021-06-11 14:02:28 +02:00
+ this.setInvulnerable(false);
+ this.setBeamTarget(null);
+ }
+ }
2024-01-19 13:22:30 +01:00
+ // Paper end - Fix invulnerable end crystals
2021-06-11 14:02:28 +02:00
}
2021-06-15 06:16:18 +02:00
}
2024-06-14 01:32:45 +02:00
@@ -79,6 +91,7 @@ public class EndCrystal extends Entity {
2021-06-15 06:16:18 +02:00
}
nbt.putBoolean("ShowBottom", this.showsBottom());
+ if (this.generatedByDragonFight) nbt.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals
2021-06-11 14:02:28 +02:00
}
@Override
2024-06-14 01:32:45 +02:00
@@ -87,6 +100,7 @@ public class EndCrystal extends Entity {
2021-06-15 05:50:26 +02:00
if (nbt.contains("ShowBottom", 1)) {
this.setShowBottom(nbt.getBoolean("ShowBottom"));
2021-06-11 14:02:28 +02:00
}
2021-06-15 06:16:18 +02:00
+ if (nbt.contains("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = nbt.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals
2021-06-11 14:02:28 +02:00
}
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
2024-10-23 20:15:25 +02:00
index 6f0cd7121bf191d8fd01baf4c9b87df7f4f44564..fe5b2bcfaa243c3089f3df83ec1ae0948a63d1eb 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
2024-10-23 20:15:25 +02:00
@@ -115,6 +115,7 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
2024-04-16 21:44:59 +02:00
endCrystal.moveTo(
(double)spike.getCenterX() + 0.5, (double)(spike.getHeight() + 1), (double)spike.getCenterZ() + 0.5, random.nextFloat() * 360.0F, 0.0F
);
2024-01-19 13:22:30 +01:00
+ endCrystal.generatedByDragonFight = true; // Paper - Fix invulnerable end crystals
2022-12-07 21:16:54 +01:00
world.addFreshEntity(endCrystal);
2023-09-22 09:24:44 +02:00
BlockPos blockPos2 = endCrystal.blockPosition();
this.setBlock(world, blockPos2.below(), Blocks.BEDROCK.defaultBlockState());