mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
net/minecraft/world/level/dimension/end
This commit is contained in:
parent
92aec10cc4
commit
773f7aada7
1 changed files with 67 additions and 84 deletions
|
@ -1,63 +1,52 @@
|
||||||
--- a/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
--- a/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||||
+++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
+++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||||
@@ -74,6 +74,7 @@
|
@@ -70,8 +_,9 @@
|
||||||
private static final int GATEWAY_DISTANCE = 96;
|
private static final int GATEWAY_DISTANCE = 96;
|
||||||
public static final int DRAGON_SPAWN_Y = 128;
|
public static final int DRAGON_SPAWN_Y = 128;
|
||||||
private final Predicate<Entity> validPlayer;
|
private final Predicate<Entity> validPlayer;
|
||||||
+ private static final Component DEFAULT_BOSS_EVENT_NAME = Component.translatable("entity.minecraft.ender_dragon"); // Paper - ensure reset EnderDragon boss event name
|
+ private static final Component DEFAULT_BOSS_EVENT_NAME = Component.translatable("entity.minecraft.ender_dragon"); // Paper - ensure reset EnderDragon boss event name
|
||||||
public final ServerBossEvent dragonEvent;
|
public final ServerBossEvent dragonEvent = (ServerBossEvent)new ServerBossEvent(
|
||||||
public final ServerLevel level;
|
- Component.translatable("entity.minecraft.ender_dragon"), BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS
|
||||||
private final BlockPos origin;
|
+ DEFAULT_BOSS_EVENT_NAME, BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS // Paper
|
||||||
@@ -102,7 +103,7 @@
|
)
|
||||||
}
|
.setPlayBossMusic(true)
|
||||||
|
.setCreateWorldFog(true);
|
||||||
public EndDragonFight(ServerLevel world, long gatewaysSeed, EndDragonFight.Data data, BlockPos origin) {
|
@@ -112,7 +_,12 @@
|
||||||
- this.dragonEvent = (ServerBossEvent) (new ServerBossEvent(Component.translatable("entity.minecraft.ender_dragon"), BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS)).setPlayBossMusic(true).setCreateWorldFog(true);
|
|
||||||
+ this.dragonEvent = (ServerBossEvent) (new ServerBossEvent(DEFAULT_BOSS_EVENT_NAME, BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS)).setPlayBossMusic(true).setCreateWorldFog(true); // Paper - ensure reset EnderDragon boss event name
|
|
||||||
this.gateways = new ObjectArrayList();
|
|
||||||
this.ticksSinceLastPlayerScan = 21;
|
|
||||||
this.skipArenaLoadedCheck = false;
|
|
||||||
@@ -111,14 +112,20 @@
|
|
||||||
this.origin = origin;
|
|
||||||
this.validPlayer = EntitySelector.ENTITY_STILL_ALIVE.and(EntitySelector.withinDistance((double) origin.getX(), (double) (128 + origin.getY()), (double) origin.getZ(), 192.0D));
|
|
||||||
this.needsStateScanning = data.needsStateScanning;
|
|
||||||
- this.dragonUUID = (UUID) data.dragonUUID.orElse((Object) null);
|
|
||||||
+ this.dragonUUID = (UUID) data.dragonUUID.orElse(null); // CraftBukkit - decompile error
|
|
||||||
this.dragonKilled = data.dragonKilled;
|
|
||||||
this.previouslyKilled = data.previouslyKilled;
|
|
||||||
if (data.isRespawning) {
|
if (data.isRespawning) {
|
||||||
this.respawnStage = DragonRespawnAnimation.START;
|
this.respawnStage = DragonRespawnAnimation.START;
|
||||||
}
|
}
|
||||||
|
-
|
||||||
+ // Paper start - Add config to disable ender dragon legacy check
|
+ // Paper start - Add config to disable ender dragon legacy check
|
||||||
+ if (data == EndDragonFight.Data.DEFAULT && !world.paperConfig().entities.spawning.scanForLegacyEnderDragon) {
|
+ if (data == EndDragonFight.Data.DEFAULT && !level.paperConfig().entities.spawning.scanForLegacyEnderDragon) {
|
||||||
+ this.needsStateScanning = false;
|
+ this.needsStateScanning = false;
|
||||||
+ this.dragonKilled = true;
|
+ this.dragonKilled = true;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Add config to disable ender dragon legacy check
|
+ // Paper end - Add config to disable ender dragon legacy check
|
||||||
|
this.portalLocation = data.exitPortalLocation.orElse(null);
|
||||||
- this.portalLocation = (BlockPos) data.exitPortalLocation.orElse((Object) null);
|
this.gateways.addAll(data.gateways.orElseGet(() -> {
|
||||||
+ this.portalLocation = (BlockPos) data.exitPortalLocation.orElse(null); // CraftBukkit - decompile error
|
ObjectArrayList<Integer> list = new ObjectArrayList<>(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers()));
|
||||||
this.gateways.addAll((Collection) data.gateways.orElseGet(() -> {
|
@@ -209,9 +_,9 @@
|
||||||
ObjectArrayList<Integer> objectarraylist = new ObjectArrayList(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers()));
|
this.dragonUUID = enderDragon.getUUID();
|
||||||
|
LOGGER.info("Found that there's a dragon still alive ({})", enderDragon);
|
||||||
@@ -206,9 +213,9 @@
|
|
||||||
this.dragonUUID = entityenderdragon.getUUID();
|
|
||||||
EndDragonFight.LOGGER.info("Found that there's a dragon still alive ({})", entityenderdragon);
|
|
||||||
this.dragonKilled = false;
|
this.dragonKilled = false;
|
||||||
- if (!flag) {
|
- if (!hasActiveExitPortal) {
|
||||||
+ if (!flag && this.level.paperConfig().entities.behavior.shouldRemoveDragon) { // Paper - Toggle for removing existing dragon
|
+ if (!hasActiveExitPortal && this.level.paperConfig().entities.behavior.shouldRemoveDragon) { // Paper - Toggle for removing existing dragon
|
||||||
EndDragonFight.LOGGER.info("But we didn't have a portal, let's remove it.");
|
LOGGER.info("But we didn't have a portal, let's remove it.");
|
||||||
- entityenderdragon.discard();
|
- enderDragon.discard();
|
||||||
+ entityenderdragon.discard(null); // CraftBukkit - add Bukkit remove cause
|
+ enderDragon.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||||
this.dragonUUID = null;
|
this.dragonUUID = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,9 +411,23 @@
|
@@ -366,12 +_,22 @@
|
||||||
this.dragonEvent.setVisible(false);
|
this.dragonEvent.setVisible(false);
|
||||||
this.spawnExitPortal(true);
|
this.spawnExitPortal(true);
|
||||||
this.spawnNewGateway();
|
this.spawnNewGateway();
|
||||||
- if (!this.previouslyKilled) {
|
- if (!this.previouslyKilled) {
|
||||||
- this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.origin)), Blocks.DRAGON_EGG.defaultBlockState());
|
- this.level
|
||||||
|
- .setBlockAndUpdate(
|
||||||
|
- this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.origin)),
|
||||||
|
- Blocks.DRAGON_EGG.defaultBlockState()
|
||||||
|
- );
|
||||||
+ // Paper start - Add DragonEggFormEvent
|
+ // Paper start - Add DragonEggFormEvent
|
||||||
+ BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.origin));
|
+ BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.origin));
|
||||||
+ org.bukkit.craftbukkit.block.CraftBlockState eggState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.level, eggPosition);
|
+ org.bukkit.craftbukkit.block.CraftBlockState eggState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.level, eggPosition);
|
||||||
|
@ -70,20 +59,17 @@
|
||||||
+ // this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.origin)), Blocks.DRAGON_EGG.defaultBlockState());
|
+ // this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.origin)), Blocks.DRAGON_EGG.defaultBlockState());
|
||||||
+ } else {
|
+ } else {
|
||||||
+ eggEvent.setCancelled(true);
|
+ eggEvent.setCancelled(true);
|
||||||
}
|
+ }
|
||||||
+ if (eggEvent.callEvent()) {
|
+ if (eggEvent.callEvent()) {
|
||||||
+ eggEvent.getNewState().update(true);
|
+ eggEvent.getNewState().update(true);
|
||||||
+ // Paper end - Add DragonEggFormEvent
|
+ // Paper end - Add DragonEggFormEvent
|
||||||
+ }
|
}
|
||||||
|
|
||||||
this.previouslyKilled = true;
|
this.previouslyKilled = true;
|
||||||
this.dragonKilled = true;
|
@@ -385,6 +_,24 @@
|
||||||
@@ -419,7 +440,25 @@
|
|
||||||
@VisibleForTesting
|
|
||||||
public void removeAllGateways() {
|
|
||||||
this.gateways.clear();
|
this.gateways.clear();
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ // Paper start - More DragonBattle API
|
+ // Paper start - More DragonBattle API
|
||||||
+ public boolean spawnNewGatewayIfPossible() {
|
+ public boolean spawnNewGatewayIfPossible() {
|
||||||
+ if (!this.gateways.isEmpty()) {
|
+ if (!this.gateways.isEmpty()) {
|
||||||
|
@ -99,12 +85,13 @@
|
||||||
+ endCrystals.addAll(this.level.getEntitiesOfClass(EndCrystal.class, spike.getTopBoundingBox()));
|
+ endCrystals.addAll(this.level.getEntitiesOfClass(EndCrystal.class, spike.getTopBoundingBox()));
|
||||||
+ }
|
+ }
|
||||||
+ return endCrystals;
|
+ return endCrystals;
|
||||||
}
|
+ }
|
||||||
+ // Paper end - More DragonBattle API
|
+ // Paper end - More DragonBattle API
|
||||||
|
+
|
||||||
private void spawnNewGateway() {
|
private void spawnNewGateway() {
|
||||||
if (!this.gateways.isEmpty()) {
|
if (!this.gateways.isEmpty()) {
|
||||||
@@ -449,6 +488,11 @@
|
int i = this.gateways.remove(this.gateways.size() - 1);
|
||||||
|
@@ -413,6 +_,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,18 +100,18 @@
|
||||||
+ this.portalLocation = this.portalLocation.atY(this.level.getMinY() + 1);
|
+ this.portalLocation = this.portalLocation.atY(this.level.getMinY() + 1);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Prevent "softlocked" exit portal generation
|
+ // Paper end - Prevent "softlocked" exit portal generation
|
||||||
if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation)) {
|
if (endPodiumFeature.place(
|
||||||
int i = Mth.positiveCeilDiv(4, 16);
|
FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation
|
||||||
|
)) {
|
||||||
@@ -469,6 +513,7 @@
|
@@ -432,6 +_,7 @@
|
||||||
entityenderdragon.moveTo((double) this.origin.getX(), (double) (128 + this.origin.getY()), (double) this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F);
|
enderDragon.moveTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F);
|
||||||
this.level.addFreshEntity(entityenderdragon);
|
this.level.addFreshEntity(enderDragon);
|
||||||
this.dragonUUID = entityenderdragon.getUUID();
|
this.dragonUUID = enderDragon.getUUID();
|
||||||
+ this.resetSpikeCrystals(); // Paper - Reset ender crystals on dragon spawn
|
+ this.resetSpikeCrystals(); // Paper - Reset ender crystals on dragon spawn
|
||||||
}
|
}
|
||||||
|
|
||||||
return entityenderdragon;
|
return enderDragon;
|
||||||
@@ -480,6 +525,10 @@
|
@@ -443,6 +_,10 @@
|
||||||
this.ticksSinceDragonSeen = 0;
|
this.ticksSinceDragonSeen = 0;
|
||||||
if (dragon.hasCustomName()) {
|
if (dragon.hasCustomName()) {
|
||||||
this.dragonEvent.setName(dragon.getDisplayName());
|
this.dragonEvent.setName(dragon.getDisplayName());
|
||||||
|
@ -134,8 +121,8 @@
|
||||||
+ // Paper end - ensure reset EnderDragon boss event name
|
+ // Paper end - ensure reset EnderDragon boss event name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -513,7 +562,13 @@
|
@@ -470,7 +_,13 @@
|
||||||
return this.previouslyKilled;
|
return this.previouslyKilled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,64 +135,60 @@
|
||||||
+ public boolean tryRespawn(@Nullable BlockPos placedEndCrystalPos) { // placedEndCrystalPos is null if the tryRespawn() call was not caused by a placed end crystal
|
+ public boolean tryRespawn(@Nullable BlockPos placedEndCrystalPos) { // placedEndCrystalPos is null if the tryRespawn() call was not caused by a placed end crystal
|
||||||
+ // Paper end - Perf: Do crystal-portal proximity check before entity lookup
|
+ // Paper end - Perf: Do crystal-portal proximity check before entity lookup
|
||||||
if (this.dragonKilled && this.respawnStage == null) {
|
if (this.dragonKilled && this.respawnStage == null) {
|
||||||
BlockPos blockposition = this.portalLocation;
|
BlockPos blockPos = this.portalLocation;
|
||||||
|
if (blockPos == null) {
|
||||||
|
@@ -485,6 +_,22 @@
|
||||||
|
|
||||||
@@ -531,6 +586,22 @@
|
blockPos = this.portalLocation;
|
||||||
blockposition = this.portalLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start - Perf: Do crystal-portal proximity check before entity lookup
|
+ // Paper start - Perf: Do crystal-portal proximity check before entity lookup
|
||||||
+ if (placedEndCrystalPos != null) {
|
+ if (placedEndCrystalPos != null) {
|
||||||
+ // The end crystal must be 0 or 1 higher than the portal origin
|
+ // The end crystal must be 0 or 1 higher than the portal origin
|
||||||
+ int dy = placedEndCrystalPos.getY() - blockposition.getY();
|
+ int dy = placedEndCrystalPos.getY() - blockPos.getY();
|
||||||
+ if (dy != 0 && dy != 1) {
|
+ if (dy != 0 && dy != 1) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ // The end crystal must be within a distance of 1 in one planar direction, and 3 in the other
|
+ // The end crystal must be within a distance of 1 in one planar direction, and 3 in the other
|
||||||
+ int dx = placedEndCrystalPos.getX() - blockposition.getX();
|
+ int dx = placedEndCrystalPos.getX() - blockPos.getX();
|
||||||
+ int dz = placedEndCrystalPos.getZ() - blockposition.getZ();
|
+ int dz = placedEndCrystalPos.getZ() - blockPos.getZ();
|
||||||
+ if (!((dx >= -1 && dx <= 1 && dz >= -3 && dz <= 3) || (dx >= -3 && dx <= 3 && dz >= -1 && dz <= 1))) {
|
+ if (!((dx >= -1 && dx <= 1 && dz >= -3 && dz <= 3) || (dx >= -3 && dx <= 3 && dz >= -1 && dz <= 1))) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Perf: Do crystal-portal proximity check before entity lookup
|
+ // Paper end - Perf: Do crystal-portal proximity check before entity lookup
|
||||||
+
|
+
|
||||||
List<EndCrystal> list = Lists.newArrayList();
|
|
||||||
BlockPos blockposition1 = blockposition.above(1);
|
|
||||||
Iterator iterator = Direction.Plane.HORIZONTAL.iterator();
|
|
||||||
@@ -540,19 +611,19 @@
|
|
||||||
List<EndCrystal> list1 = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(blockposition1.relative(enumdirection, 2)));
|
|
||||||
|
|
||||||
if (list1.isEmpty()) {
|
List<EndCrystal> list = Lists.newArrayList();
|
||||||
|
BlockPos blockPos1 = blockPos.above(1);
|
||||||
|
@@ -492,18 +_,19 @@
|
||||||
|
for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||||
|
List<EndCrystal> entitiesOfClass = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(blockPos1.relative(direction, 2)));
|
||||||
|
if (entitiesOfClass.isEmpty()) {
|
||||||
- return;
|
- return;
|
||||||
+ return false; // CraftBukkit - return value
|
+ return false; // CraftBukkit - return value
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(list1);
|
list.addAll(entitiesOfClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndDragonFight.LOGGER.debug("Found all crystals, respawning dragon.");
|
LOGGER.debug("Found all crystals, respawning dragon.");
|
||||||
- this.respawnDragon(list);
|
- this.respawnDragon(list);
|
||||||
+ return this.respawnDragon(list); // CraftBukkit - return value
|
+ return this.respawnDragon(list); // CraftBukkit - return value
|
||||||
}
|
}
|
||||||
-
|
|
||||||
+ return false; // CraftBukkit - return value
|
+ return false; // CraftBukkit - return value
|
||||||
}
|
}
|
||||||
|
|
||||||
- public void respawnDragon(List<EndCrystal> crystals) {
|
- public void respawnDragon(List<EndCrystal> crystals) {
|
||||||
+ public boolean respawnDragon(List<EndCrystal> list) { // CraftBukkit - return boolean
|
+ public boolean respawnDragon(List<EndCrystal> crystals) { // CraftBukkit - return boolean
|
||||||
if (this.dragonKilled && this.respawnStage == null) {
|
if (this.dragonKilled && this.respawnStage == null) {
|
||||||
for (BlockPattern.BlockPatternMatch shapedetector_shapedetectorcollection = this.findExitPortal(); shapedetector_shapedetectorcollection != null; shapedetector_shapedetectorcollection = this.findExitPortal()) {
|
for (BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); blockPatternMatch != null; blockPatternMatch = this.findExitPortal()) {
|
||||||
for (int i = 0; i < this.exitPortalPattern.getWidth(); ++i) {
|
for (int i = 0; i < this.exitPortalPattern.getWidth(); i++) {
|
||||||
@@ -571,9 +642,10 @@
|
@@ -522,7 +_,9 @@
|
||||||
this.respawnStage = DragonRespawnAnimation.START;
|
|
||||||
this.respawnTime = 0;
|
this.respawnTime = 0;
|
||||||
this.spawnExitPortal(false);
|
this.spawnExitPortal(false);
|
||||||
- this.respawnCrystals = crystals;
|
this.respawnCrystals = crystals;
|
||||||
+ this.respawnCrystals = list;
|
|
||||||
+ return true; // CraftBukkit - return value
|
+ return true; // CraftBukkit - return value
|
||||||
}
|
}
|
||||||
-
|
|
||||||
+ return false; // CraftBukkit - return value
|
+ return false; // CraftBukkit - return value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue