testserver/patches/server/0645-Fix-invulnerable-end-c...

66 lines
3.8 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
index 78b0456a3f9e3f66d467386c3e5f68d07adf1977..6a08ab40e60b80f8f5c4d3f02da121be9da05111 100644
2021-06-11 12:02:28 +00: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
2021-11-24 23:26:29 +00:00
@@ -30,6 +30,7 @@ public class EndCrystal extends Entity {
2021-06-11 12:02:28 +00: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);
2021-11-24 23:26:29 +00:00
@@ -66,6 +67,17 @@ public class EndCrystal extends Entity {
2021-06-11 12:02:28 +00:00
}
// 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())
2021-06-11 12:02:28 +00:00
+ || ((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
}
2021-06-15 04:16:18 +00:00
}
2021-11-24 23:26:29 +00:00
@@ -77,6 +89,7 @@ public class EndCrystal extends Entity {
2021-06-15 04:16:18 +00:00
}
nbt.putBoolean("ShowBottom", this.showsBottom());
+ if (this.generatedByDragonFight) nbt.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals
2021-06-11 12:02:28 +00:00
}
@Override
2021-11-24 23:26:29 +00:00
@@ -88,6 +101,7 @@ public class EndCrystal extends Entity {
2021-06-15 03:50:26 +00:00
if (nbt.contains("ShowBottom", 1)) {
this.setShowBottom(nbt.getBoolean("ShowBottom"));
2021-06-11 12:02:28 +00:00
}
2021-06-15 04:16:18 +00:00
+ if (nbt.contains("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = nbt.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals
2021-06-11 12:02:28 +00: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
2022-06-08 09:31:06 +00:00
index 8e51c2bc6dc6483b2c670348daf793ca4d59e5b9..94209f8c02656c113b537093cbbfaba1b9871045 100644
2021-06-11 12:02:28 +00: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
2021-06-15 03:50:26 +00:00
@@ -99,6 +99,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);
2021-06-11 12:02:28 +00:00
this.setBlock(world, new BlockPos(spike.getCenterX(), spike.getHeight(), spike.getCenterZ()), Blocks.BEDROCK.defaultBlockState());
}