Paper/patches/server/0639-Fix-invulnerable-end-crystals.patch
Nassim Jahnke d5f1ffc2e6
Remove somewhat broken patch
With the new chunk system it doesn't hurt too much to (temporarily) remove this until implemented in a safer manner
2022-12-19 11:46:55 +01:00

66 lines
3.9 KiB
Diff

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 7f195640bd8299c1ecd12ea1892c6d8d20e4fcec..500500468c12d1d44ea6b83a9176b470a954f59a 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
@@ -28,6 +28,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);
@@ -64,6 +65,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).dragonFight() == null
+ || ((ServerLevel) this.level).dragonFight().respawnStage == null
+ || ((ServerLevel) this.level).dragonFight().respawnStage.ordinal() > net.minecraft.world.level.dimension.end.DragonRespawnAnimation.SUMMONING_DRAGON.ordinal()) {
+ this.setInvulnerable(false);
+ this.setBeamTarget(null);
+ }
+ }
+ // Paper end
}
}
@@ -75,6 +87,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
@@ -86,6 +99,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 32903759e94e43328de38a985cc121252c81f481..570c0646e245a1527b3a569f2c8a6fae5b18b373 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
@@ -100,6 +100,7 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
endCrystal.setBeamTarget(config.getCrystalBeamTarget());
endCrystal.setInvulnerable(config.isCrystalInvulnerable());
endCrystal.moveTo((double)spike.getCenterX() + 0.5D, (double)(spike.getHeight() + 1), (double)spike.getCenterZ() + 0.5D, random.nextFloat() * 360.0F, 0.0F);
+ endCrystal.generatedByDragonFight = true; // Paper
world.addFreshEntity(endCrystal);
this.setBlock(world, new BlockPos(spike.getCenterX(), spike.getHeight(), spike.getCenterZ()), Blocks.BEDROCK.defaultBlockState());
}