aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0575-Fix-invulnerable-end-crystals.patch
blob: 468e11151c33eb504bffd4b777be599709c7b8c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
index e7e01effab5f727d9b84a0575d165127e3dfe4c9..036640d49a5e891e9a0f767abe33f1f51d6d4cde 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
@@ -30,6 +30,7 @@ public class EndCrystal extends Entity {
     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);
@@ -66,6 +67,17 @@ public class EndCrystal extends Entity {
                 }
                 // CraftBukkit end
             }
+            // Paper start - Fix invulnerable end crystals
+            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()) {
+                    this.setInvulnerable(false);
+                    this.setBeamTarget(null);
+                }
+            }
+            // Paper end - Fix invulnerable end crystals
         }
 
     }
@@ -77,6 +89,7 @@ public class EndCrystal extends Entity {
         }
 
         nbt.putBoolean("ShowBottom", this.showsBottom());
+        if (this.generatedByDragonFight) nbt.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals
     }
 
     @Override
@@ -88,6 +101,7 @@ public class EndCrystal extends Entity {
         if (nbt.contains("ShowBottom", 1)) {
             this.setShowBottom(nbt.getBoolean("ShowBottom"));
         }
+        if (nbt.contains("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = nbt.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals
 
     }
 
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
index de93988e6116d63ae29add32ee02ccca631f1d9e..ad31fc599288e46a69814268cd10148a5edb375a 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
@@ -111,6 +111,7 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
             endCrystal.setBeamTarget(config.getCrystalBeamTarget());
             endCrystal.setInvulnerable(config.isCrystalInvulnerable());
             endCrystal.moveTo(spike.getCenterX() + 0.5, spike.getHeight() + 1, spike.getCenterZ() + 0.5, random.nextFloat() * 360.0F, 0.0F);
+            endCrystal.generatedByDragonFight = true; // Paper - Fix invulnerable end crystals
             world.addFreshEntity(endCrystal);
             BlockPos blockPos2 = endCrystal.blockPosition();
             this.setBlock(world, blockPos2.below(), Blocks.BEDROCK.defaultBlockState());