Better fix for invulnerable crystals and improve Origin API (#5761)

This commit is contained in:
Max Lee 2021-06-07 16:38:33 +01:00
parent 0437aeebb7
commit 513393d4cf
4 changed files with 51 additions and 34 deletions

View file

@ -50,6 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end // CraftBukkit end
+ // Paper start - Save the entity's origin location + // Paper start - Save the entity's origin location
+ if (this.origin != null) { + if (this.origin != null) {
+ nbttagcompound.setUUID("Paper.OriginWorld", origin.getWorld().getUID());
+ nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ())); + nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
+ } + }
+ // Paper end + // Paper end
@ -63,7 +64,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - Restore the entity's origin location + // Paper start - Restore the entity's origin location
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6); + NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
+ if (!originTag.isEmpty()) { + if (!originTag.isEmpty()) {
+ origin = new org.bukkit.Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2)); + org.bukkit.World originWorld = world.getWorld();
+ if (nbttagcompound.hasKey("Paper.OriginWorld")) {
+ originWorld = Bukkit.getWorld(nbttagcompound.getUUID("Paper.OriginWorld"));
+ }
+ origin = new org.bukkit.Location(originWorld, originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
+ } + }
+ // Paper end + // Paper end
+ +

View file

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void inactiveTick() { } public void inactiveTick() { }
// Spigot end // Spigot end
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
if (this.origin != null) { nbttagcompound.setUUID("Paper.OriginWorld", origin.getWorld().getUID());
nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ())); nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
} }
+ // Save entity's from mob spawner status + // Save entity's from mob spawner status
@ -28,8 +28,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return nbttagcompound; return nbttagcompound;
} catch (Throwable throwable) { } catch (Throwable throwable) {
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
if (!originTag.isEmpty()) { }
origin = new org.bukkit.Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2)); origin = new org.bukkit.Location(originWorld, originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
} }
+ +
+ spawnedViaMobSpawner = nbttagcompound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status + spawnedViaMobSpawner = nbttagcompound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status

View file

@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne @@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
if (this.origin != null) { nbttagcompound.setUUID("Paper.OriginWorld", origin.getWorld().getUID());
nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ())); nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
} }
+ if (spawnReason != null) { + if (spawnReason != null) {

View file

@ -1,5 +1,5 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com> From: Max Lee <max@themoep.de>
Date: Thu, 27 May 2021 14:52:30 -0700 Date: Thu, 27 May 2021 14:52:30 -0700
Subject: [PATCH] Fix invulnerable end crystals Subject: [PATCH] Fix invulnerable end crystals
@ -19,32 +19,52 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ fixInvulnerableEndCrystalExploit = getBoolean("unsupported-settings.fix-invulnerable-end-crystal-exploit", fixInvulnerableEndCrystalExploit); + fixInvulnerableEndCrystalExploit = getBoolean("unsupported-settings.fix-invulnerable-end-crystal-exploit", fixInvulnerableEndCrystalExploit);
+ } + }
} }
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java b/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
@@ -0,0 +0,0 @@ public class EnderDragonBattle { @@ -0,0 +0,0 @@ public class EntityEnderCrystal extends Entity {
private static final DataWatcherObject<Optional<BlockPosition>> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m);
private static final DataWatcherObject<Boolean> d = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.i);
public int b;
+ public boolean generatedByDragonFight = false; // Paper - Fix invulnerable end crystals
while (iterator.hasNext()) { public EntityEnderCrystal(EntityTypes<? extends EntityEnderCrystal> entitytypes, World world) {
WorldGenEnder.Spike worldgenender_spike = (WorldGenEnder.Spike) iterator.next(); super(entitytypes, world);
+ if (!this.world.paperConfig.fixInvulnerableEndCrystalExploit || worldgenender_spike.crystal == null) { // Paper @@ -0,0 +0,0 @@ public class EntityEnderCrystal extends Entity {
List<EntityEnderCrystal> list = this.world.a(EntityEnderCrystal.class, worldgenender_spike.f()); }
Iterator iterator1 = list.iterator(); // CraftBukkit end
@@ -0,0 +0,0 @@ public class EnderDragonBattle {
entityendercrystal.setInvulnerable(false);
entityendercrystal.setBeamTarget((BlockPosition) null);
} }
+ // Paper start + // Paper start - Fix invulnerable end crystals
+ } else { + if (this.world.paperConfig.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) {
+ worldgenender_spike.crystal.setInvulnerable(false); + if ((this.origin.getWorld() != null && !((WorldServer) this.world).uuid.equals(this.origin.getWorld().getUID()))
+ worldgenender_spike.crystal.setBeamTarget(null); + || ((WorldServer) this.world).getDragonBattle() == null
+ worldgenender_spike.crystal = null; + || ((WorldServer) this.world).getDragonBattle().respawnPhase == null
+ || ((WorldServer) this.world).getDragonBattle().respawnPhase.ordinal() > net.minecraft.world.level.dimension.end.EnumDragonRespawn.SUMMONING_DRAGON.ordinal()) {
+ this.setInvulnerable(false);
+ this.setBeamTarget(null);
+ }
+ } + }
+ // Paper end + // Paper end
} }
} }
@@ -0,0 +0,0 @@ public class EntityEnderCrystal extends Entity {
}
nbttagcompound.setBoolean("ShowBottom", this.isShowingBottom());
+ if (this.generatedByDragonFight) nbttagcompound.setBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals
}
@Override
@@ -0,0 +0,0 @@ public class EntityEnderCrystal extends Entity {
if (nbttagcompound.hasKeyOfType("ShowBottom", 1)) {
this.setShowingBottom(nbttagcompound.getBoolean("ShowBottom"));
}
+ if (nbttagcompound.hasKeyOfType("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = nbttagcompound.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals
}
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java b/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java b/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java --- a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java
@ -59,18 +79,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (list.isEmpty()) { if (list.isEmpty()) {
@@ -0,0 +0,0 @@ public class WorldGenEnder extends WorldGenerator<WorldGenFeatureEndSpikeConfigu @@ -0,0 +0,0 @@ public class WorldGenEnder extends WorldGenerator<WorldGenFeatureEndSpikeConfigu
entityendercrystal.setBeamTarget(worldgenfeatureendspikeconfiguration.d());
entityendercrystal.setInvulnerable(worldgenfeatureendspikeconfiguration.b()); entityendercrystal.setInvulnerable(worldgenfeatureendspikeconfiguration.b());
entityendercrystal.setPositionRotation((double) worldgenender_spike.a() + 0.5D, (double) (worldgenender_spike.d() + 1), (double) worldgenender_spike.b() + 0.5D, random.nextFloat() * 360.0F, 0.0F); entityendercrystal.setPositionRotation((double) worldgenender_spike.a() + 0.5D, (double) (worldgenender_spike.d() + 1), (double) worldgenender_spike.b() + 0.5D, random.nextFloat() * 360.0F, 0.0F);
+ entityendercrystal.generatedByDragonFight = true;
worldaccess.addEntity(entityendercrystal); worldaccess.addEntity(entityendercrystal);
+ worldgenender_spike.crystal = entityendercrystal; // Paper
this.a(worldaccess, new BlockPosition(worldgenender_spike.a(), worldgenender_spike.d(), worldgenender_spike.b()), Blocks.BEDROCK.getBlockData()); this.a(worldaccess, new BlockPosition(worldgenender_spike.a(), worldgenender_spike.d(), worldgenender_spike.b()), Blocks.BEDROCK.getBlockData());
} }
@@ -0,0 +0,0 @@ public class WorldGenEnder extends WorldGenerator<WorldGenFeatureEndSpikeConfigu
private final int e;
private final boolean f;
private final AxisAlignedBB g;
+ public EntityEnderCrystal crystal; // Paper
public Spike(int i, int j, int k, int l, boolean flag) {
this.b = i;