mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Better fix for invulnerable crystals and improve Origin API (#5761)
This commit is contained in:
parent
0437aeebb7
commit
513393d4cf
4 changed files with 51 additions and 34 deletions
|
@ -50,6 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
// CraftBukkit end
|
||||
+ // Paper start - Save the entity's origin location
|
||||
+ if (this.origin != null) {
|
||||
+ nbttagcompound.setUUID("Paper.OriginWorld", origin.getWorld().getUID());
|
||||
+ nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
@ -63,7 +64,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ // Paper start - Restore the entity's origin location
|
||||
+ NBTTagList originTag = nbttagcompound.getList("Paper.Origin", 6);
|
||||
+ 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
|
||||
+
|
||||
|
|
|
@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
public void inactiveTick() { }
|
||||
// Spigot end
|
||||
@@ -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()));
|
||||
}
|
||||
+ // Save entity's from mob spawner status
|
||||
|
@ -28,8 +28,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
@@ -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
|
||||
|
|
|
@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
|
||||
@@ -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()));
|
||||
}
|
||||
+ if (spawnReason != null) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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
|
||||
Subject: [PATCH] Fix invulnerable end crystals
|
||||
|
||||
|
@ -19,32 +19,52 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ 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
|
||||
--- a/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java
|
||||
@@ -0,0 +0,0 @@ public class EnderDragonBattle {
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EntityEnderCrystal.java
|
||||
@@ -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()) {
|
||||
WorldGenEnder.Spike worldgenender_spike = (WorldGenEnder.Spike) iterator.next();
|
||||
+ if (!this.world.paperConfig.fixInvulnerableEndCrystalExploit || worldgenender_spike.crystal == null) { // Paper
|
||||
List<EntityEnderCrystal> list = this.world.a(EntityEnderCrystal.class, worldgenender_spike.f());
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
@@ -0,0 +0,0 @@ public class EnderDragonBattle {
|
||||
entityendercrystal.setInvulnerable(false);
|
||||
entityendercrystal.setBeamTarget((BlockPosition) null);
|
||||
public EntityEnderCrystal(EntityTypes<? extends EntityEnderCrystal> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -0,0 +0,0 @@ public class EntityEnderCrystal extends Entity {
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ // Paper start
|
||||
+ } else {
|
||||
+ worldgenender_spike.crystal.setInvulnerable(false);
|
||||
+ worldgenender_spike.crystal.setBeamTarget(null);
|
||||
+ worldgenender_spike.crystal = null;
|
||||
+ // Paper start - Fix invulnerable end crystals
|
||||
+ if (this.world.paperConfig.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) {
|
||||
+ if ((this.origin.getWorld() != null && !((WorldServer) this.world).uuid.equals(this.origin.getWorld().getUID()))
|
||||
+ || ((WorldServer) this.world).getDragonBattle() == 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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEnder.java
|
||||
|
@ -59,18 +79,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
if (list.isEmpty()) {
|
||||
@@ -0,0 +0,0 @@ public class WorldGenEnder extends WorldGenerator<WorldGenFeatureEndSpikeConfigu
|
||||
entityendercrystal.setBeamTarget(worldgenfeatureendspikeconfiguration.d());
|
||||
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.generatedByDragonFight = true;
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
|
Loading…
Reference in a new issue