More more more (more ??) more work

This commit is contained in:
Bjarne Koll 2023-09-22 15:15:57 +02:00
parent 662b6c5ca8
commit 74094edf08
No known key found for this signature in database
GPG Key ID: 27F6CCCF55D2EE62
7 changed files with 48 additions and 71 deletions

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add back EntityPortalExitEvent
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 7802d3d9274c9083a89b9f62441194e8a0d8975b..f7a97ac4eb851f35275cfeb4717f0f69dda4336e 100644
index ef29f13cd146862e2b6e8be3300065ffaaaf1e08..bcc316a8d0de827e59198ddee086d3c21b3ef7ea 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3329,6 +3329,28 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3281,6 +3281,28 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
} else {
// CraftBukkit start
worldserver = shapedetectorshape.world;
@ -37,7 +37,7 @@ index 7802d3d9274c9083a89b9f62441194e8a0d8975b..f7a97ac4eb851f35275cfeb4717f0f69
if (worldserver == this.level) {
// SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in
this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
@@ -3348,8 +3370,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3300,8 +3322,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (entity != null) {
entity.restoreFrom(this);

View File

@ -7,10 +7,10 @@ Subject: [PATCH] Add methods to find targets for lightning strikes
public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index bc7daf89e30152a3bcb215e91b30c9680be5c343..e809a959d69197ecdec768a2d4f348c73c0d5b9a 100644
index a81f77b6d057182a716549940f40052fe27e845c..7ad3942b39f071c23c10310d71bd259df445e0da 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -974,6 +974,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -744,6 +744,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
protected BlockPos findLightningTargetAround(BlockPos pos) {
@ -22,7 +22,7 @@ index bc7daf89e30152a3bcb215e91b30c9680be5c343..e809a959d69197ecdec768a2d4f348c7
BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
Optional<BlockPos> optional = this.findLightningRod(blockposition1);
@@ -988,6 +993,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -758,6 +763,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (!list.isEmpty()) {
return ((LivingEntity) list.get(this.random.nextInt(list.size()))).blockPosition();
} else {
@ -31,10 +31,10 @@ index bc7daf89e30152a3bcb215e91b30c9680be5c343..e809a959d69197ecdec768a2d4f348c7
blockposition1 = blockposition1.above(2);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 78ba220b74c1cca26e3b1243622a317eb1e4e78b..e5eb25bb1b29b8fa7b97da935a9189ac43c21c71 100644
index d3489601ec89c9deea6beb3153bef9b30be85366..8f235460f24a7ac2e8d478bf14a3c83b8fef35df 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -698,6 +698,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -703,6 +703,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
return (LightningStrike) lightning.getBukkitEntity();
}

View File

@ -81,10 +81,10 @@ index 0000000000000000000000000000000000000000..cf9d28ea97d93cec05c9fb768d59e283
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 7f870317139db136103cb72b2aa57bcba9f6e793..53e40ab7d37ef707151c165831b24737a9f3683c 100644
index 1123bba2af7c707e8237fb1336f0b958861c4119..ffd94f9af2e39f1fdb076835c32cc7287329f6dd 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -568,6 +568,18 @@ public final class CraftMagicNumbers implements UnsafeValues {
@@ -569,6 +569,18 @@ public final class CraftMagicNumbers implements UnsafeValues {
public int getProtocolVersion() {
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
}

View File

@ -3,6 +3,9 @@ From: syldium <syldium@mailo.com>
Date: Fri, 9 Jul 2021 18:50:40 +0200
Subject: [PATCH] Add more advancement API
== AT ==
public net.minecraft.advancements.Advancement decorateName(Lnet/minecraft/advancements/DisplayInfo;)Lnet/minecraft/network/chat/Component;
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java b/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java
@ -80,43 +83,11 @@ index 0000000000000000000000000000000000000000..b9c24b8d83b96d8c66cdf879650027f4
+ };
+ }
+}
diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java
index 72e09d3472af376b1b7aa50c3d9ab3d837a2bed3..81359be381fc9bcb56a9cc83e70a6afa6e838c6a 100644
--- a/src/main/java/net/minecraft/advancements/Advancement.java
+++ b/src/main/java/net/minecraft/advancements/Advancement.java
@@ -55,8 +55,16 @@ public class Advancement {
parent.addChild(this);
}
- if (display == null) {
- this.chatComponent = Component.literal(id.toString());
+ // Paper start - moved to static method
+ this.chatComponent = constructDisplayComponent(this.id, this.display);
+ }
+
+ public static Component constructDisplayComponent(final @Nullable ResourceLocation id, final @Nullable DisplayInfo display) {
+ if (id == null && display == null) {
+ throw new IllegalArgumentException("can't both be null");
+ } else if (display == null) {
+ return Component.literal(id.toString());
+ // Paper end
} else {
Component ichatbasecomponent = display.getTitle();
ChatFormatting enumchatformat = display.getFrame().getChatColor();
@@ -65,7 +73,7 @@ public class Advancement {
return chatmodifier.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ichatmutablecomponent));
});
- this.chatComponent = ComponentUtils.wrapInSquareBrackets(ichatmutablecomponent1).withStyle(enumchatformat);
+ return ComponentUtils.wrapInSquareBrackets(ichatmutablecomponent1).withStyle(enumchatformat); // Paper
}
}
diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java
index 2e9e8b1f391a223cfb0fed9a100ae78004ad2f48..7909ba26bb7a883c74eda1ffd2d3e2bad286bc8b 100644
index a6ea13198a2de14d57472681b5a2b30baf3c4280..11b26d14b863075d776884544629cdd23f219298 100644
--- a/src/main/java/net/minecraft/advancements/DisplayInfo.java
+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java
@@ -28,6 +28,7 @@ public class DisplayInfo {
@@ -29,6 +29,7 @@ public class DisplayInfo {
private final boolean hidden;
private float x;
private float y;
@ -125,54 +96,60 @@ index 2e9e8b1f391a223cfb0fed9a100ae78004ad2f48..7909ba26bb7a883c74eda1ffd2d3e2ba
public DisplayInfo(ItemStack icon, Component title, Component description, @Nullable ResourceLocation background, FrameType frame, boolean showToast, boolean announceToChat, boolean hidden) {
this.title = title;
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
index c47cae84f3b6970247d78382f48ae8ddbc202b59..1435251a4fb721b800e6a1f07b50c5f743e04081 100644
index 52baf818579a6841b77ff80e42f4f1b9f635ea08..3321445645514769ff494f90090f22241fffbc44 100644
--- a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
+++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
@@ -29,12 +29,43 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
return Collections.unmodifiableCollection(this.handle.getCriteria().keySet());
@@ -29,12 +29,49 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
return Collections.unmodifiableCollection(this.handle.value().criteria().keySet());
}
+ // Paper start
@Override
- public AdvancementDisplay getDisplay() {
- if (this.handle.getDisplay() == null) {
- if (this.handle.value().display().isEmpty()) {
- return null;
+ public io.papermc.paper.advancement.AdvancementDisplay getDisplay() {
+ return this.handle.getDisplay() == null ? null : this.handle.getDisplay().paper;
+ return this.handle.value().display().map(d -> d.paper).orElse(null);
+ }
+
+ @Deprecated @io.papermc.paper.annotation.DoNotUse
+ @Deprecated
+ @io.papermc.paper.annotation.DoNotUse
+ public AdvancementDisplay getDisplay0() { // May be called by plugins via Commodore
+ return this.handle.getDisplay() == null ? null : new CraftAdvancementDisplay(this.handle.getDisplay());
+ return this.handle.value().display().map(CraftAdvancementDisplay::new).orElse(null);
+ }
+
+ @Override
+ public net.kyori.adventure.text.Component displayName() {
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(Advancement.constructDisplayComponent(this.handle.getId(), this.handle.getDisplay()));
+ return this.handle.value().display()
+ .map(d -> io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.advancements.Advancement.decorateName(d)))
+ .orElseGet(() -> net.kyori.adventure.text.Component.text(this.handle.id().toString()));
+ }
+
+ @Override
+ public org.bukkit.advancement.Advancement getParent() {
+ return this.handle.getParent() == null ? null : this.handle.getParent().bukkit;
+ return this.handle.value().parent()
+ .map(net.minecraft.server.MinecraftServer.getServer().getAdvancements()::get)
+ .map(AdvancementHolder::toBukkit)
+ .orElse(null);
+ }
+
+ @Override
+ public Collection<org.bukkit.advancement.Advancement> getChildren() {
+ final var children = com.google.common.collect.ImmutableList.<org.bukkit.advancement.Advancement>builder();
+ for (Advancement advancement : this.handle.getChildren()) {
+ children.add(advancement.bukkit);
+ final var advancementNode = net.minecraft.server.MinecraftServer.getServer().getAdvancements().tree().get(this.handle);
+ if (advancementNode != null) {
+ for (final var child : advancementNode.children()) {
+ children.add(child.holder().toBukkit());
+ }
}
+ return children.build();
+ }
- return new CraftAdvancementDisplay(this.handle.getDisplay());
- return new CraftAdvancementDisplay(this.handle.value().display().get());
+ @Override
+ public org.bukkit.advancement.Advancement getRoot() {
+ Advancement advancement = this.handle;
+ while (advancement.getParent() != null) {
+ advancement = advancement.getParent();
+ }
+ return advancement.bukkit;
+ final var advancementNode = net.minecraft.server.MinecraftServer.getServer().getAdvancements().tree().get(this.handle);
+ return java.util.Objects.requireNonNull(advancementNode, "could not find internal advancement node for advancement " + this.handle.id()).root().holder().toBukkit();
}
+ // Paper end
}

View File

@ -28,10 +28,10 @@ index df8c88bfa749e02f633350446101dcce05db7ac1..1a0f86b5a632469942e33c237c247d2d
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 8f604924b47ed4027f4212007530b6d0c39f73a9..fd39c81ab54e07630fa12e9e451dcd9b529db446 100644
index 786ef24e97cfb96ddee2be9e02272e6f572cd64d..39f011a3c5e0eaa24ab95738329ba98aa07a5f36 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1262,7 +1262,7 @@ public abstract class Player extends LivingEntity {
@@ -1268,7 +1268,7 @@ public abstract class Player extends LivingEntity {
flag1 = true;
}
@ -40,7 +40,7 @@ index 8f604924b47ed4027f4212007530b6d0c39f73a9..fd39c81ab54e07630fa12e9e451dcd9b
flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper
flag2 = flag2 && !this.isSprinting();
@@ -1302,7 +1302,7 @@ public abstract class Player extends LivingEntity {
@@ -1308,7 +1308,7 @@ public abstract class Player extends LivingEntity {
}
Vec3 vec3d = target.getDeltaMovement();
@ -49,7 +49,7 @@ index 8f604924b47ed4027f4212007530b6d0c39f73a9..fd39c81ab54e07630fa12e9e451dcd9b
if (flag5) {
if (i > 0) {
@@ -1330,7 +1330,7 @@ public abstract class Player extends LivingEntity {
@@ -1336,7 +1336,7 @@ public abstract class Player extends LivingEntity {
if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
// CraftBukkit start - Only apply knockback if the damage hits
@ -59,7 +59,7 @@ index 8f604924b47ed4027f4212007530b6d0c39f73a9..fd39c81ab54e07630fa12e9e451dcd9b
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
index a0d688128a1268fa1acf7c339cde15df5dce1c82..372b9ec0c8eddf4a01b4b8203a88401db22affbf 100644
index f70f0764d9743dbfa2ead4c90d0df3dbc107672d..02574c777047b8e1375aa91e0cd75c7325837643 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -372,6 +372,7 @@ public abstract class AbstractArrow extends Projectile {
@ -71,10 +71,10 @@ index a0d688128a1268fa1acf7c339cde15df5dce1c82..372b9ec0c8eddf4a01b4b8203a88401d
int k = entity.getRemainingFireTicks();
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index ecf0a23435532cc6a771ef04787bbef190699edb..b46a37bab1ddab70dc0567df26668e28d5844469 100644
index 5bb610230e5686dd8a35c5c14c506ffacd5868c9..f171124710b5e731652df0074fe24360239225b2 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1016,7 +1016,7 @@ public class CraftEventFactory {
@@ -1018,7 +1018,7 @@ public class CraftEventFactory {
} else {
damageCause = DamageCause.ENTITY_EXPLOSION;
}
@ -83,7 +83,7 @@ index ecf0a23435532cc6a771ef04787bbef190699edb..b46a37bab1ddab70dc0567df26668e28
}
event.setCancelled(cancelled);
@@ -1048,7 +1048,7 @@ public class CraftEventFactory {
@@ -1050,7 +1050,7 @@ public class CraftEventFactory {
cause = DamageCause.SONIC_BOOM;
}
@ -92,7 +92,7 @@ index ecf0a23435532cc6a771ef04787bbef190699edb..b46a37bab1ddab70dc0567df26668e28
} else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) {
EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions);
event.setCancelled(cancelled);
@@ -1118,7 +1118,7 @@ public class CraftEventFactory {
@@ -1120,7 +1120,7 @@ public class CraftEventFactory {
} else {
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.getMsgId()));
}
@ -101,7 +101,7 @@ index ecf0a23435532cc6a771ef04787bbef190699edb..b46a37bab1ddab70dc0567df26668e28
event.setCancelled(cancelled);
CraftEventFactory.callEvent(event);
if (!event.isCancelled()) {
@@ -1167,20 +1167,28 @@ public class CraftEventFactory {
@@ -1169,20 +1169,28 @@ public class CraftEventFactory {
}
if (cause != null) {