tons of patches (#5835)

This commit is contained in:
Jake Potrebic 2021-06-14 19:59:31 -07:00
parent 2119f06b5a
commit b8cf7d380e
136 changed files with 814 additions and 1979 deletions

View file

@ -4,3 +4,15 @@
# This line would make the field public and remove the final modifier # This line would make the field public and remove the final modifier
#public-f net.minecraft.network.protocol.game.ClientboundChatPacket sender #public-f net.minecraft.network.protocol.game.ClientboundChatPacket sender
# Leave out the member and it will apply to the class itself # Leave out the member and it will apply to the class itself
# Item Rarity API
public net.minecraft.world.item.Item rarity
# More Enchantment API
public net.minecraft.world.item.enchantment.Enchantment slots;
# Fix and optimise world force upgrading
public net.minecraft.util.worldupdate.WorldUpgrader REGEX;
# More Lidded Block API
public net.minecraft.world.level.block.entity.EnderChestBlockEntity openersCounter

View file

@ -33,7 +33,7 @@ diff --git a/src/main/java/org/bukkit/entity/Skeleton.java b/src/main/java/org/b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Skeleton.java --- a/src/main/java/org/bukkit/entity/Skeleton.java
+++ b/src/main/java/org/bukkit/entity/Skeleton.java +++ b/src/main/java/org/bukkit/entity/Skeleton.java
@@ -0,0 +0,0 @@ public interface Skeleton extends Monster, RangedEntity { // Paper @@ -0,0 +0,0 @@ public interface Skeleton extends AbstractSkeleton, com.destroystokyo.paper.enti
*/ */
STRAY; STRAY;
} }

View file

@ -1,89 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com>
Date: Fri, 8 Jan 2021 20:31:13 +0100
Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent
diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/advancements/Advancement.java
+++ b/src/main/java/net/minecraft/advancements/Advancement.java
@@ -0,0 +0,0 @@ public class Advancement {
return this.parent;
}
+ public final @Nullable DisplayInfo getAdvancementDisplay() { return this.getDisplay(); } // Paper - OBFHELPER
@Nullable
public DisplayInfo getDisplay() {
return this.display;
@@ -0,0 +0,0 @@ public class Advancement {
return this.requirements;
}
+ public final Component getChatComponent() { return this.getChatComponent(); } // Paper - OBFHELPER
public Component getChatComponent() {
return this.chatComponent;
}
diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/advancements/DisplayInfo.java
+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java
@@ -0,0 +0,0 @@ public class DisplayInfo {
return this.description;
}
+ public final FrameType getFrameType() { return this.getFrame(); } // Paper - OBFHELPER
public FrameType getFrame() {
return this.frame;
}
+ public final boolean shouldAnnounceToChat() { return this.shouldAnnounceChat(); } // Paper - OBFHELPER
public boolean shouldAnnounceChat() {
return this.announceChat;
}
diff --git a/src/main/java/net/minecraft/advancements/FrameType.java b/src/main/java/net/minecraft/advancements/FrameType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/advancements/FrameType.java
+++ b/src/main/java/net/minecraft/advancements/FrameType.java
@@ -0,0 +0,0 @@ public enum FrameType {
this.displayName = new TranslatableComponent("advancements.toast." + s);
}
+ public final String getId() { return this.getName(); } // Paper - OBFHELPER
public String getName() {
return this.name;
}
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -0,0 +0,0 @@ import net.minecraft.util.datafix.DataFixTypes;
import net.minecraft.world.level.GameRules;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import io.papermc.paper.adventure.PaperAdventure; // Paper
public class PlayerAdvancements {
@@ -0,0 +0,0 @@ public class PlayerAdvancements {
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
- this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ boolean announceToChat = advancement.getAdvancementDisplay() != null && advancement.getAdvancementDisplay().shouldAnnounceToChat();
+ net.kyori.adventure.text.Component message = announceToChat ? PaperAdventure.asAdventure(new TranslatableComponent("chat.type.advancement." + advancement.getAdvancementDisplay().getFrameType().getId(), this.player.getDisplayName(), advancement.getChatComponent())) : null;
+ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message);
+ this.player.level.getCraftServer().getPluginManager().callEvent(event);
+ message = event.message();
+ // Paper end
advancement.getRewards().a(this.player);
- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
- this.playerList.broadcastMessage(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatType.SYSTEM, Util.NIL_UUID);
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ if (message != null && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
+ this.playerList.broadcastMessage(PaperAdventure.asVanilla(message), ChatType.SYSTEM, Util.getNullUUID());
+ // Paper end
}
}
}

View file

@ -1,127 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Fri, 14 May 2021 13:42:17 -0500
Subject: [PATCH] Add Mob#lookAt API
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity {
protected void customServerAiStep() {}
+ public int getMaxHeadXRot() { return getMaxHeadXRot(); } // Paper - OBFHELPER
public int getMaxHeadXRot() {
return 40;
}
+ public int getMaxHeadYRot() { return getMaxHeadYRot(); } // Paper - OBFHELPER
public int getMaxHeadYRot() {
return 75;
}
+ public int getHeadRotSpeed() { return getHeadRotSpeed(); } // Paper - OBFHELPER
public int getHeadRotSpeed() {
return 10;
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java b/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java
+++ b/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java
@@ -0,0 +0,0 @@ public class LookControl {
this.mob = entity;
}
+ public void lookAt(Vec3 vec3d) { setLookAt(vec3d); } // Paper - OBFHELPER
public void setLookAt(Vec3 direction) {
this.setLookAt(direction.x, direction.y, direction.z);
}
+ // Paper start
+ public void lookAt(Entity entity) {
+ this.lookAt(entity.getX(), getWantedY(entity), entity.getZ());
+ }
+ // Paper end
+
+ public void lookAt(Entity entity, float f, float f1) { setLookAt(entity, f, f1); } // Paper - OBFHELPER
public void setLookAt(Entity entity, float yawSpeed, float pitchSpeed) {
this.setLookAt(entity.getX(), getWantedY(entity), entity.getZ(), yawSpeed, pitchSpeed);
}
+ public void lookAt(double d0, double d1, double d2) { setLookAt(d0, d1, d2); } // Paper - OBFHELPER
public void setLookAt(double x, double y, double z) {
this.setLookAt(x, y, z, (float) this.mob.getHeadRotSpeed(), (float) this.mob.getMaxHeadXRot());
}
+ public void lookAt(double d0, double d1, double d2, float f, float f1) { setLookAt(d0, d1, d2, f, f1); } // Paper - OBFHELPER
public void setLookAt(double x, double y, double z, float yawSpeed, float pitchSpeed) {
this.wantedX = x;
this.wantedY = y;
@@ -0,0 +0,0 @@ public class LookControl {
return from + f4;
}
+ public static double getWantedY(Entity entity) { return getWantedY(entity); } // Paper - OBFHELPER
private static double getWantedY(Entity entity) {
return entity instanceof LivingEntity ? entity.getEyeY() : (entity.getBoundingBox().minY + entity.getBoundingBox().maxY) / 2.0D;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
public boolean isInDaylight() {
return getHandle().isInDaylight();
}
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) {
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+ getHandle().getLookControl().lookAt(location.getX(), location.getY(), location.getZ());
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) {
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+ getHandle().getLookControl().lookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) {
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+ getHandle().getLookControl().lookAt(((CraftEntity) entity).getHandle());
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) {
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+ getHandle().getLookControl().lookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public void lookAt(double x, double y, double z) {
+ getHandle().getLookControl().lookAt(x, y, z);
+ }
+
+ @Override
+ public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) {
+ getHandle().getLookControl().lookAt(x, y, z, headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public int getHeadRotationSpeed() {
+ return getHandle().getHeadRotSpeed();
+ }
+
+ @Override
+ public int getMaxHeadPitch() {
+ return getHandle().getMaxHeadXRot();
+ }
// Paper end
}

View file

@ -1,40 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 26 Feb 2021 16:10:53 -0600
Subject: [PATCH] Clear SyncLoadInfo
This patch merely adds the extra argument "clear" after /paper syncloadinfo to clear currently stored syncload info.
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -0,0 +0,0 @@ public class PaperCommand extends Command {
sender.sendMessage(ChatColor.RED + "This command requires the server startup flag '-Dpaper.debug-sync-loads=true' to be set.");
return;
}
+
+ if (args.length > 1 && args[1].equals("clear")) {
+ SyncLoadFinder.clear();
+ sender.sendMessage(ChatColor.GRAY + "Sync load data cleared.");
+ return;
+ }
+
File file = new File(new File(new File("."), "debug"),
"sync-load-info" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + ".txt");
file.getParentFile().mkdirs();
diff --git a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java
+++ b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java
@@ -0,0 +0,0 @@ public class SyncLoadFinder {
public final Long2IntOpenHashMap coordinateTimes = new Long2IntOpenHashMap();
}
+ public static void clear() {
+ SYNC_LOADS.clear();
+ }
+
public static void logSyncLoad(final Level world, final int chunkX, final int chunkZ) {
if (!ENABLED) {
return;

View file

@ -1,53 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 26 Feb 2021 16:24:25 -0600
Subject: [PATCH] Expose Tracked Players
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
private CraftEntity bukkitEntity;
- ChunkMap.TrackedEntity tracker; // Paper
+ public ChunkMap.TrackedEntity tracker; // Paper package private -> public
public boolean collisionLoadChunks = false; // Paper
public Throwable addedToWorldStack; // Paper - entity debug
public CraftEntity getBukkitEntity() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections; // Paper
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
+ // Paper start
+ @Override
+ public Set<Player> getTrackedPlayers() {
+ if (entity.tracker == null) {
+ return Collections.emptySet();
+ }
+
+ Set<Player> set = new HashSet<>(entity.tracker.seenBy.size());
+ for (ServerPlayer entityPlayer : entity.tracker.seenBy) {
+ set.add(entityPlayer.getBukkitEntity().getPlayer());
+ }
+ return set;
+ }
+ // Paper end
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{

View file

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: SamB440 <sam@islandearth.net>
Date: Fri, 21 May 2021 00:22:09 +0100
Subject: [PATCH] Fix MC-148809: Increase structure block data length to 128
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java
@@ -0,0 +0,0 @@ public class ServerboundSetStructureBlockPacket implements Packet<ServerGamePack
this.size = new BlockPos(Mth.clamp(buf.readByte(), 0, 48), Mth.clamp(buf.readByte(), 0, 48), Mth.clamp(buf.readByte(), 0, 48));
this.mirror = (Mirror) buf.readEnum(Mirror.class);
this.rotation = (Rotation) buf.readEnum(Rotation.class);
- this.data = buf.readUtf(12);
+ this.data = buf.readUtf(128); // Paper - Fix MC-148809, increase max character input to 128
this.integrity = Mth.clamp(buf.readFloat(), 0.0F, 1.0F);
this.seed = buf.readVarLong();
byte b0 = buf.readByte();

View file

@ -1,91 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 10 May 2021 15:46:57 -0700
Subject: [PATCH] Fix incorrect status dataconverter for pre 1.13 chunks
Vanilla was setting non-populated OR non-lit chunks to empty, but
really this is just completely wrong. It should be set to "carved"
at minmum, because pre 1.13 chunks went through 3 distinct stages
of generation: carving, population, and lighting - in this order.
There is no "empty" status, because a chunk was simply carved
or it didn't exist. So mapping any chunk data to empty is simply
invalid.
If the chunk is terrain populated, then obviously it must be at
minmum "decorated." If the chunk is lit and populated, then it is marked
"mobs_spawned" (which is what Vanilla is doing, and this is the last
stage before moving to full so it looks correct).
So now here is a table representing the new status conversion:
Chunk is lit Chunk is populated Vanilla
F F empty
T F empty
F T empty
T T mobs_spawned
Chunk is lit Chunk is populated Paper
F F carved
T F carved
F T decorated
T T mobs_spawned
This should fix some problems converting old data, as the
changes here are going to prevent the chunk from being regenerated
incorrectly.
diff --git a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
+++ b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix {
return dynamic.asStreamOpt().result();
});
Dynamic<?> dynamic = (Dynamic) typed1.get(DSL.remainderFinder());
- boolean flag = dynamic.get("TerrainPopulated").asBoolean(false) && (!dynamic.get("LightPopulated").asNumber().result().isPresent() || dynamic.get("LightPopulated").asBoolean(false));
-
- dynamic = dynamic.set("Status", dynamic.createString(flag ? "mobs_spawned" : "empty"));
+ // Paper start - fix incorrect status conversion
+ // Vanilla is setting chunks to incorrect status here, they should be using at minimum carved.
+ // for populated chunks, it should be at minimum decorated
+ // and for lit and populated, mobs_spawned is correct (technically mobs_spawned should be for populated,
+ // but if it's not lit then it can't be set above lit)
+ final boolean terrainPopulated = dynamic.get("TerrainPopulated").asBoolean(false);
+ final boolean lightPopulated = dynamic.get("LightPopulated").asBoolean(false) || dynamic.get("LightPopulated").asNumber().result().isPresent();
+ final String newStatus = !terrainPopulated ? "carved" : (lightPopulated ? "mobs_spawned" : "decorated");
+
+ dynamic = dynamic.set("Status", dynamic.createString(newStatus));
dynamic = dynamic.set("hasLegacyStructureData", dynamic.createBoolean(true));
- Dynamic dynamic1;
+ // Paper end - fix incorrect status conversion
+ Dynamic<?> dynamic1; // Paper - decompile fix
- if (flag) {
+ if (true) { // Paper - fix incorrect status conversion
Optional<ByteBuffer> optional1 = dynamic.get("Biomes").asByteBufferOpt().result();
if (optional1.isPresent()) {
@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix {
}).collect(Collectors.toList());
if (optional.isPresent()) {
- ((Stream) optional.get()).forEach((dynamic2) -> {
+ optional.get().forEach((dynamic2) -> { // Paper - decompile fix
int j = dynamic2.get("x").asInt(0);
int k = dynamic2.get("y").asInt(0);
int l = dynamic2.get("z").asInt(0);
@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix {
((ShortList) list.get(k >> 4)).add(short0);
});
+ Dynamic<?> finalDynamic = dynamic; // Paper - decompile fix
dynamic = dynamic.set("ToBeTicked", dynamic.createList(list.stream().map((shortlist) -> {
- Stream stream = shortlist.stream();
+ Stream<Short> stream = shortlist.stream(); // Paper - decompile fix
- dynamic.getClass();
- return dynamic.createList(stream.map(dynamic::createShort));
+ return finalDynamic.createList(stream.map(finalDynamic::createShort));
})));
}

View file

@ -1,110 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 6 Jan 2021 00:34:04 -0800
Subject: [PATCH] Implement Keyed on World
diff --git a/src/main/java/net/minecraft/core/Registry.java b/src/main/java/net/minecraft/core/Registry.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/core/Registry.java
+++ b/src/main/java/net/minecraft/core/Registry.java
@@ -0,0 +0,0 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
public static final ResourceKey<Registry<LootItemFunctionType>> LOOT_FUNCTION_REGISTRY = createRegistryKey("loot_function_type");
public static final ResourceKey<Registry<LootItemConditionType>> LOOT_ITEM_REGISTRY = createRegistryKey("loot_condition_type");
public static final ResourceKey<Registry<DimensionType>> DIMENSION_TYPE_REGISTRY = createRegistryKey("dimension_type");
- public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY = createRegistryKey("dimension");
+ public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY = createRegistryKey("dimension"); public static final ResourceKey<Registry<Level>> getWorldRegistry() { return DIMENSION_REGISTRY; } // Paper - OBFHELPER
public static final ResourceKey<Registry<LevelStem>> LEVEL_STEM_REGISTRY = createRegistryKey("dimension");
public static final Registry<SoundEvent> SOUND_EVENT = registerSimple(Registry.SOUND_EVENT_REGISTRY, () -> {
return SoundEvents.ITEM_PICKUP;
@@ -0,0 +0,0 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
ResourceLocation minecraftkey = resourcekey.location();
Registry.LOADERS.put(minecraftkey, defaultEntry);
- WritableRegistry<R> iregistrywritable = Registry.WRITABLE_REGISTRY;
+ WritableRegistry iregistrywritable = Registry.WRITABLE_REGISTRY; // Paper - decompile fix
- return (WritableRegistry) iregistrywritable.register(resourcekey, (Object) registry, lifecycle);
+ return (R) iregistrywritable.register(resourcekey, (Object) registry, lifecycle); // Paper - decompile fix
}
protected Registry(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle) {
@@ -0,0 +0,0 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
}
public static <V, T extends V> T register(Registry<V> registry, ResourceLocation id, T entry) {
- return ((WritableRegistry) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable());
+ return ((WritableRegistry<V>) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable()); // Paper - decompile fix
}
public static <V, T extends V> T registerMapping(Registry<V> registry, int rawId, String id, T entry) {
- return ((WritableRegistry) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable());
+ return ((WritableRegistry<V>) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable()); // Paper - decompile fix
}
static {
diff --git a/src/main/java/net/minecraft/resources/ResourceKey.java b/src/main/java/net/minecraft/resources/ResourceKey.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/resources/ResourceKey.java
+++ b/src/main/java/net/minecraft/resources/ResourceKey.java
@@ -0,0 +0,0 @@ public class ResourceKey<T> {
private final ResourceLocation registryName;
private final ResourceLocation location;
+ public static <T> ResourceKey<T> newResourceKey(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation minecraftKey) { return create(registryKey, minecraftKey); } // Paper - OBFHELPER
public static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> registry, ResourceLocation value) {
return create(registry.location, value);
}
@@ -0,0 +0,0 @@ public class ResourceKey<T> {
return this.registryName.equals(registry.location());
}
+ public ResourceLocation getLocation() { return location(); } // Paper - OBFHELPER
public ResourceLocation location() {
return this.location;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
} else if (name.equals(levelName + "_the_end")) {
worldKey = net.minecraft.world.level.Level.END;
} else {
- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH)));
+ worldKey = ResourceKey.newResourceKey(Registry.getWorldRegistry(), new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
}
ServerLevel internal = (ServerLevel) new ServerLevel(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11),
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
return null;
}
+ // Paper start
+ @Override
+ public World getWorld(NamespacedKey worldKey) {
+ ServerLevel worldServer = console.getLevel(ResourceKey.newResourceKey(Registry.getWorldRegistry(), CraftNamespacedKey.toMinecraft(worldKey)));
+ if (worldServer == null) return null;
+ return worldServer.getWorld();
+ }
+ // Paper end
+
public void addWorld(World world) {
// Check if a World already exists with the UID.
if (getWorld(world.getUID()) != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
}, net.minecraft.server.MinecraftServer.getServer());
}
+
+ @Override
+ public org.bukkit.NamespacedKey getKey() {
+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().getLocation());
+ }
// Paper end
// Spigot start

View file

@ -1,45 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 29 Mar 2021 09:07:25 +0200
Subject: [PATCH] Make sure to remove correct TE during TE tick
This looks like it can cause premature TE removal.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
//this.tileEntityList.remove(tileentity); // Paper - remove unused list
// Paper - prevent double chunk lookups
LevelChunk chunk; if ((chunk = this.getChunkIfLoaded(tileentity.getBlockPos())) != null) { // inlined contents of this.isLoaded(BlockPosition). Reuse the returned chunk instead of looking it up again
- chunk.removeBlockEntity(tileentity.getBlockPos());
+ chunk.removeTileEntity(tileentity.getBlockPos(), tileentity); // Paper - remove correct TE
}
// Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
@Override
public void removeBlockEntity(BlockPos pos) {
+ // Paper start - remove correct TE
+ removeTileEntity(pos, null);
+ }
+ public void removeTileEntity(BlockPos blockposition, BlockEntity match) {
+ // Paper end
if (this.loaded || this.world.isClientSide()) {
- BlockEntity tileentity = (BlockEntity) this.blockEntities.remove(pos);
+ // Paper start
+ BlockEntity tileentity = (BlockEntity) this.blockEntities.get(blockposition);
- if (tileentity != null) {
+ if (tileentity != null && (match == null || match == tileentity)) {
+ this.blockEntities.remove(blockposition);
+ // Paper end
tileentity.setRemoved();
}
}

View file

@ -1,146 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 7 Jul 2020 10:52:34 -0700
Subject: [PATCH] More World API
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
return !this.worldDataServer.worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, feature, pos, radius, skipExistingChunks); // CraftBukkit
}
+ public BlockPos getNearestBiome(Biome biomeBase, BlockPos blockPosition, int radius, int step) { return this.findNearestBiome(biomeBase, blockPosition, radius, step); } // Paper - OBFHELPER
@Nullable
public BlockPos findNearestBiome(Biome biome, BlockPos pos, int radius, int j) {
return this.getChunkSource().getGenerator().getBiomeSource().findBiomeHorizontal(pos.getX(), pos.getY(), pos.getZ(), radius, j, (biomebase1) -> {
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
return this.noSave;
}
+ public RegistryAccess getWorldCustomRegistry() { return registryAccess(); } // Paper - OBFHELPER
@Override
public RegistryAccess registryAccess() {
return this.server.registryAccess();
diff --git a/src/main/java/net/minecraft/world/level/dimension/DimensionType.java b/src/main/java/net/minecraft/world/level/dimension/DimensionType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/dimension/DimensionType.java
+++ b/src/main/java/net/minecraft/world/level/dimension/DimensionType.java
@@ -0,0 +0,0 @@ public class DimensionType {
public static RegistryAccess.RegistryHolder registerBuiltin(RegistryAccess.RegistryHolder registryManager) {
WritableRegistry<DimensionType> iregistrywritable = registryManager.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
- iregistrywritable.register(DimensionType.OVERWORLD_LOCATION, (Object) DimensionType.DEFAULT_OVERWORLD, Lifecycle.stable());
- iregistrywritable.register(DimensionType.OVERWORLD_CAVES_LOCATION, (Object) DimensionType.DEFAULT_OVERWORLD_CAVES, Lifecycle.stable());
- iregistrywritable.register(DimensionType.NETHER_LOCATION, (Object) DimensionType.DEFAULT_NETHER, Lifecycle.stable());
- iregistrywritable.register(DimensionType.END_LOCATION, (Object) DimensionType.DEFAULT_END, Lifecycle.stable());
+ iregistrywritable.register(DimensionType.OVERWORLD_LOCATION, DimensionType.DEFAULT_OVERWORLD, Lifecycle.stable()); // Paper - decompile fix
+ iregistrywritable.register(DimensionType.OVERWORLD_CAVES_LOCATION, DimensionType.DEFAULT_OVERWORLD_CAVES, Lifecycle.stable()); // Paper - decompile fix
+ iregistrywritable.register(DimensionType.NETHER_LOCATION, DimensionType.DEFAULT_NETHER, Lifecycle.stable()); // Paper - decompile fix
+ iregistrywritable.register(DimensionType.END_LOCATION, DimensionType.DEFAULT_END, Lifecycle.stable()); // Paper - decompile fix
return registryManager;
}
@@ -0,0 +0,0 @@ public class DimensionType {
public static MappedRegistry<LevelStem> defaultDimensions(Registry<DimensionType> dimensionRegistry, Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> chunkGeneratorSettingsRegistry, long seed) {
MappedRegistry<LevelStem> registrymaterials = new MappedRegistry<>(Registry.LEVEL_STEM_REGISTRY, Lifecycle.experimental());
- registrymaterials.register(LevelStem.NETHER, (Object) (new LevelStem(() -> {
+ registrymaterials.register(LevelStem.NETHER, (new LevelStem(() -> { // Paper - decompile fix
return (DimensionType) dimensionRegistry.getOrThrow(DimensionType.NETHER_LOCATION);
}, defaultNetherGenerator(biomeRegistry, chunkGeneratorSettingsRegistry, seed))), Lifecycle.stable());
- registrymaterials.register(LevelStem.END, (Object) (new LevelStem(() -> {
+ registrymaterials.register(LevelStem.END, (new LevelStem(() -> { // Paper - decompile fix
return (DimensionType) dimensionRegistry.getOrThrow(DimensionType.END_LOCATION);
}, defaultEndGenerator(biomeRegistry, chunkGeneratorSettingsRegistry, seed))), Lifecycle.stable());
return registrymaterials;
@@ -0,0 +0,0 @@ public class DimensionType {
return this.brightnessRamp[i];
}
+ public Tag<Block> getInfiniburnTag() { return infiniburn(); } // Paper - OBFHELPER
public Tag<Block> infiniburn() {
Tag<Block> tag = BlockTags.getAllTags().getTag(this.infiniburn);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
}
+ // Paper start
+ @Override
+ public Location locateNearestBiome(Location origin, Biome biome, int radius) {
+ return this.locateNearestBiome(origin, biome, radius, 8);
+ }
+
+ @Override
+ public Location locateNearestBiome(Location origin, Biome biome, int radius, int step) {
+ BlockPos originPos = new BlockPos(origin.getX(), origin.getY(), origin.getZ());
+ BlockPos nearest = getHandle().getNearestBiome(CraftBlock.biomeToBiomeBase(getHandle().getWorldCustomRegistry().registryOrThrow(Registry.BIOME_REGISTRY), biome), originPos, radius, step);
+ return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
+ }
+
+ @Override
+ public boolean isUltrawarm() {
+ return getHandle().dimensionType().ultraWarm();
+ }
+
+ @Override
+ public boolean isNatural() {
+ return getHandle().dimensionType().natural();
+ }
+
+ @Override
+ public double getCoordinateScale() {
+ return getHandle().dimensionType().coordinateScale();
+ }
+
+ @Override
+ public boolean hasSkylight() {
+ return getHandle().dimensionType().hasSkyLight();
+ }
+
+ @Override
+ public boolean hasBedrockCeiling() {
+ return getHandle().dimensionType().hasSkyLight();
+ }
+
+ @Override
+ public boolean isPiglinSafe() {
+ return getHandle().dimensionType().piglinSafe();
+ }
+
+ @Override
+ public boolean doesBedWork() {
+ return getHandle().dimensionType().bedWorks();
+ }
+
+ @Override
+ public boolean doesRespawnAnchorWork() {
+ return getHandle().dimensionType().respawnAnchorWorks();
+ }
+
+ @Override
+ public boolean hasRaids() {
+ return getHandle().dimensionType().hasRaids();
+ }
+
+ @Override
+ public boolean isFixedTime() {
+ return getHandle().dimensionType().hasFixedTime();
+ }
+
+ @Override
+ public Collection<org.bukkit.Material> getInfiniburn() {
+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().dimensionType().getInfiniburnTag().getTagged().iterator(), CraftMagicNumbers::getMaterial));
+ }
+ // Paper end
+
@Override
public Raid locateNearestRaid(Location location, int radius) {
Validate.notNull(location, "Location cannot be null");

View file

@ -1,138 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 15 May 2021 10:04:43 -0700
Subject: [PATCH] additions to PlayerGameModeChangeEvent
diff --git a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java
+++ b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java
@@ -0,0 +0,0 @@ public class DefaultGameModeCommands {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
if (entityplayer.gameMode.getGameModeForPlayer() != defaultGameMode) {
- entityplayer.setGameMode(defaultGameMode);
+ // Paper start - handle event cancelling the change
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = entityplayer.setGamemode(defaultGameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.text("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'", net.kyori.adventure.text.format.NamedTextColor.RED));
+ if (event != null && event.isCancelled()) {
+ source.sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false);
+ continue;
+ }
+ // Paper end
++i;
}
}
diff --git a/src/main/java/net/minecraft/server/commands/GameModeCommand.java b/src/main/java/net/minecraft/server/commands/GameModeCommand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/commands/GameModeCommand.java
+++ b/src/main/java/net/minecraft/server/commands/GameModeCommand.java
@@ -0,0 +0,0 @@ public class GameModeCommand {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
if (entityplayer.gameMode.getGameModeForPlayer() != gameMode) {
- entityplayer.setGameMode(gameMode);
- // CraftBukkit start - handle event cancelling the change
- if (entityplayer.gameMode.getGameModeForPlayer() != gameMode) {
- context.getSource().sendFailure(new net.minecraft.network.chat.TextComponent("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'"));
+ // Paper start - handle event cancelling the change
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = entityplayer.setGamemode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.text("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'", net.kyori.adventure.text.format.NamedTextColor.RED));
+ if (event != null && event.isCancelled()) {
+ context.getSource().sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false);
continue;
}
- // CraftBukkit end
+ // Paper end
logGamemodeChange((CommandSourceStack) context.getSource(), entityplayer, gameMode);
++i;
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
if (this.getY() > 300) this.setPosRaw(getX(), 257, getZ()); // Paper - bring down to a saner Y level if out of world
if (tag.contains("playerGameType", 99)) {
if (this.getServer().getForceGameType()) {
+ // Paper start - call PlayerGameModeChangeEvent on join for players that do not have the correct gamemode
+ if (this.getServer().getDefaultGameType() != GameType.byId(tag.getInt("playerGameType"))) {
+ if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), GameMode.getByValue(this.getServer().getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
this.gameMode.setGameModeForPlayer(this.getServer().getDefaultGameType(), GameType.NOT_SET);
+ } else {
+ this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); // copied from below; if cancelled, set gamemode normally
+ }
+ } else {
+ this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); // copied from below; if no change needed, set gamemode normally
+ } // Paper end
} else {
this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET);
}
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
@Override
public void setGameMode(GameType gameMode) {
+ // Paper start - Add cause and nullable message to event
+ setGamemode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
+ }
+
+ public PlayerGameModeChangeEvent setGamemode(GameType enumgamemode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component message) {
+ // Paper end
// CraftBukkit start
- if (gameMode == this.gameMode.getGameModeForPlayer()) {
- return;
+ if (enumgamemode == this.gameMode.getGameModeForPlayer()) {
+ return null; // Paper
}
- PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(gameMode.getId()));
+ PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(enumgamemode.getId()), cause, message); // Paper
level.getCraftServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
- return;
+ return event; // Paper
}
// CraftBukkit end
- this.gameMode.setGameModeForPlayer(gameMode);
- this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId()));
- if (gameMode == GameType.SPECTATOR) {
+ this.gameMode.setGameModeForPlayer(enumgamemode);
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) enumgamemode.getId()));
+ if (enumgamemode == GameType.SPECTATOR) {
this.removeEntitiesOnShoulder();
this.stopRiding();
} else {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
this.onUpdateAbilities();
this.updateEffectVisibility();
+ return event; // Paper
}
@Override
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
this.player = this.server.getPlayerList().respawn(this.player, false);
if (this.server.isHardcore()) {
- this.player.setGameMode(GameType.SPECTATOR);
+ this.player.setGamemode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper
((GameRules.BooleanValue) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
throw new IllegalArgumentException("Mode cannot be null");
}
- getHandle().setGameMode(GameType.byId(mode.getValue()));
+ getHandle().setGamemode(GameType.byId(mode.getValue()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.PLUGIN, null); // Paper
}
@Override

View file

@ -1,239 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lukas81298 <lukas81298@gmail.com>
Date: Sun, 13 Dec 2020 13:42:55 +0100
Subject: [PATCH] do not create unnecessary copies of passenger list
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java
@@ -0,0 +0,0 @@ public class ClientboundSetPassengersPacket implements Packet<ClientGamePacketLi
public ClientboundSetPassengersPacket(Entity entity) {
this.vehicle = entity.getId();
- List<Entity> list = entity.getPassengers();
+ List<Entity> list = entity.passengers; // Paper - do not create a copy of the list
this.passengers = new int[list.size()];
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -0,0 +0,0 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
list.add(entity);
}
- if (!entity.getPassengers().isEmpty()) {
+ if (!entity.passengers.isEmpty()) { // Paper - do not copy list
list1.add(entity);
}
}
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -0,0 +0,0 @@ public class ServerEntity {
public final void tick() { this.sendChanges(); } // Paper - OBFHELPER
public void sendChanges() {
- List<Entity> list = this.entity.getPassengers();
+ List<Entity> list = this.entity.passengers; // Paper - do not copy list
if (!list.equals(this.lastPassengers)) {
- this.lastPassengers = list;
+ this.lastPassengers = com.google.common.collect.ImmutableList.copyOf(list); // Paper - only copy list if something has changed
this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit
}
@@ -0,0 +0,0 @@ public class ServerEntity {
}
}
- if (!this.entity.getPassengers().isEmpty()) {
+ if (!this.entity.passengers.isEmpty()) { // Paper - do not create copy of list
consumer.accept(new ClientboundSetPassengersPacket(this.entity));
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
protected boolean canAddPassenger(Entity passenger) {
- return this.getPassengers().size() < 1;
+ return this.passengers.size() < 1; // Paper - do not copy list
}
public final float getCollisionBorderSize() { return getPickRadius(); } // Paper - OBFHELPER
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
public boolean isVehicle() {
- return !this.getPassengers().isEmpty();
+ return !this.passengers.isEmpty(); // Paper - do not copy list
}
public boolean rideableUnderWater() {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
public boolean hasPassenger(Entity passenger) {
- Iterator iterator = this.getPassengers().iterator();
+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list
Entity entity1;
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
public boolean hasPassenger(Class<? extends Entity> clazz) {
- Iterator iterator = this.getPassengers().iterator();
+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list
Entity entity;
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
public Collection<Entity> getIndirectPassengers() {
Set<Entity> set = Sets.newHashSet();
- Iterator iterator = this.getPassengers().iterator();
+ Iterator iterator = this.passengers.iterator(); // Paper - do not copy list
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
private void fillIndirectPassengers(boolean playersOnly, Set<Entity> output) {
Entity entity;
- for (Iterator iterator = this.getPassengers().iterator(); iterator.hasNext(); entity.fillIndirectPassengers(playersOnly, output)) {
+ for (Iterator iterator = this.passengers.iterator(); iterator.hasNext(); entity.fillIndirectPassengers(playersOnly, output)) { // Paper - do not copy list
entity = (Entity) iterator.next();
if (!playersOnly || ServerPlayer.class.isAssignableFrom(entity.getClass())) {
output.add(entity);
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java
@@ -0,0 +0,0 @@ public class RunAroundLikeCrazyGoal extends Goal {
@Override
public void tick() {
if (!this.horse.isTamed() && this.horse.getRandom().nextInt(50) == 0) {
- Entity entity = (Entity) this.horse.getPassengers().get(0);
+ Entity entity = this.horse.passengers.isEmpty() ? null : this.horse.passengers.get(0); // Paper - do not copy list, fixed array out of bounds exception as well
if (entity == null) {
return;
diff --git a/src/main/java/net/minecraft/world/entity/animal/Pig.java b/src/main/java/net/minecraft/world/entity/animal/Pig.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Pig.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Pig.java
@@ -0,0 +0,0 @@ public class Pig extends Animal implements ItemSteerable, Saddleable {
@Nullable
@Override
public Entity getControllingPassenger() {
- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
}
@Override
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
@@ -0,0 +0,0 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
@Nullable
@Override
public Entity getControllingPassenger() {
- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
}
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
@@ -0,0 +0,0 @@ public class Ravager extends Raider {
@Nullable
@Override
public Entity getControllingPassenger() {
- return this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
+ return this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
}
@Override
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -0,0 +0,0 @@ public abstract class AbstractMinecart extends Entity {
vec3d1 = new Vec3(d8 * d4 / d6, vec3d1.y, d8 * d5 / d6);
this.setDeltaMovement(vec3d1);
- Entity entity = this.getPassengers().isEmpty() ? null : (Entity) this.getPassengers().get(0);
+ Entity entity = this.passengers.isEmpty() ? null : (Entity) this.passengers.get(0); // Paper - do not copy list
if (entity instanceof Player) {
Vec3 vec3d2 = entity.getDeltaMovement();
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -0,0 +0,0 @@ public class Boat extends Entity {
super.tick();
this.tickLerp();
if (this.isControlledByLocalInstance()) {
- if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof Player)) {
+ if (this.passengers.isEmpty() || !(this.passengers.get(0) instanceof Player)) { // Paper - do not copy list
this.setPaddleState(false, false);
}
@@ -0,0 +0,0 @@ public class Boat extends Entity {
Entity entity = (Entity) list.get(j);
if (!entity.hasPassenger(this)) {
- if (flag && this.getPassengers().size() < 2 && !entity.isPassenger() && entity.getBbWidth() < this.getBbWidth() && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) {
+ if (flag && this.passengers.size() < 2 && !entity.isPassenger() && entity.getBbWidth() < this.getBbWidth() && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { // Paper - do not copy passenger list
entity.startRiding(this);
} else {
this.push(entity);
@@ -0,0 +0,0 @@ public class Boat extends Entity {
float f = 0.0F;
float f1 = (float) ((this.removed ? 0.009999999776482582D : this.getPassengersRidingOffset()) + passenger.getMyRidingOffset());
- if (this.getPassengers().size() > 1) {
- int i = this.getPassengers().indexOf(passenger);
+ if (this.passengers.size() > 1) { // Paper - do not copy list
+ int i = this.passengers.indexOf(passenger); // Paper - do not copy list
if (i == 0) {
f = 0.2F;
@@ -0,0 +0,0 @@ public class Boat extends Entity {
passenger.yRot += this.deltaRotation;
passenger.setYHeadRot(passenger.getYHeadRot() + this.deltaRotation);
this.clampRotation(passenger);
- if (passenger instanceof Animal && this.getPassengers().size() > 1) {
+ if (passenger instanceof Animal && this.passengers.size() > 1) { // Paper - do not copy list
int j = passenger.getId() % 2 == 0 ? 90 : 270;
passenger.setYBodyRot(((Animal) passenger).yBodyRot + (float) j);
@@ -0,0 +0,0 @@ public class Boat extends Entity {
@Override
protected boolean canAddPassenger(Entity passenger) {
- return this.getPassengers().size() < 2 && !this.isEyeInFluid((Tag) FluidTags.WATER);
+ return this.passengers.size() < 2 && !this.isEyeInFluid((Tag) FluidTags.WATER); // Paper - do not copy list
}
@Nullable
@Override
public Entity getControllingPassenger() {
- List<Entity> list = this.getPassengers();
+ List<Entity> list = this.passengers; // Paper - do not copy list
return list.isEmpty() ? null : (Entity) list.get(0);
}

View file

@ -1,33 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 20 Apr 2021 01:15:04 +0100
Subject: [PATCH] don't throw when loading invalid TEs
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -0,0 +0,0 @@ package net.minecraft.world.level.block.entity;
import javax.annotation.Nullable;
import net.minecraft.CrashReportCategory;
+import net.minecraft.ResourceLocationException;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
@@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
public static BlockEntity loadStatic(BlockState state, CompoundTag tag) {
String s = tag.getString("id");
- return (BlockEntity) Registry.BLOCK_ENTITY_TYPE.getOptional(new ResourceLocation(s)).map((tileentitytypes) -> {
+ // Paper
+ ResourceLocation minecraftKey = null;
+ try {
+ minecraftKey = new ResourceLocation(s);
+ } catch (ResourceLocationException ex) {}
+ // Paper end
+ return (BlockEntity) Registry.BLOCK_ENTITY_TYPE.getOptional(minecraftKey).map((tileentitytypes) -> {
try {
return tileentitytypes.create();
} catch (Throwable throwable) {

View file

@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Thu, 22 Apr 2021 19:02:07 -0700
Subject: [PATCH] fix PlayerItemHeldEvent firing twice
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
@@ -0,0 +0,0 @@ public class ServerboundSetCarriedItemPacket implements Packet<ServerGamePacketL
listener.handleSetCarriedItem(this);
}
+ public int getItemInHandIndex() { return getSlot(); } // Paper - OBFHELPER
public int getSlot() {
return this.slot;
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (this.player.isImmobile()) return; // CraftBukkit
if (packet.getSlot() >= 0 && packet.getSlot() < Inventory.getSelectionSize()) {
+ if (packet.getItemInHandIndex() == this.player.inventory.selected) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.selected, packet.getSlot());
this.craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {

View file

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com>
Date: Fri, 8 Jan 2021 20:31:13 +0100
Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -0,0 +0,0 @@ public class PlayerAdvancements {
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
- this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ boolean announceToChat = advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat();
+ net.kyori.adventure.text.Component message = announceToChat ? io.papermc.paper.adventure.PaperAdventure.asAdventure(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent())) : null;
+ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message);
+ this.player.level.getCraftServer().getPluginManager().callEvent(event);
+ message = event.message();
+ // Paper end
advancement.getRewards().grant(this.player);
- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
- this.playerList.broadcastMessage(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatType.SYSTEM, Util.NIL_UUID);
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ if (message != null && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
+ this.playerList.broadcastMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), ChatType.SYSTEM, Util.NIL_UUID);
+ // Paper end
}
}
}

View file

@ -110,7 +110,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java +++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
@@ -0,0 +0,0 @@ public class ServerConnectionListener { @@ -0,0 +0,0 @@ public class ServerConnectionListener {
pending.add((Connection) object); // Paper ServerConnectionListener.this.connections.add((Connection) object); // CraftBukkit - decompile error
channel.pipeline().addLast("packet_handler", (ChannelHandler) object); channel.pipeline().addLast("packet_handler", (ChannelHandler) object);
((Connection) object).setListener(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, (Connection) object)); ((Connection) object).setListener(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, (Connection) object));
+ io.papermc.paper.network.ChannelInitializeListenerHolder.callListeners(channel); // Paper + io.papermc.paper.network.ChannelInitializeListenerHolder.callListeners(channel); // Paper

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEn
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
@@ -0,0 +0,0 @@ public class BeehiveBlockEntity extends BlockEntity implements TickableBlockEnti @@ -0,0 +0,0 @@ public class BeehiveBlockEntity extends BlockEntity {
return this.stored.size(); return this.stored.size();
} }

View file

@ -37,9 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
BlockState iblockdata1 = world.getBlockState(pos.above()); BlockState blockState = world.getBlockState(pos.above());
if (blockState.isAir()) {
if (iblockdata1.isAir()) { entity.onAboveBubbleCol(state.getValue(DRAG_DOWN));
diff --git a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java b/src/main/java/net/minecraft/world/level/block/ButtonBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java b/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java --- a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
@ -76,18 +76,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!entity.fireImmune() && (Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { if (!entity.fireImmune() && (Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) {
entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage); entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CauldronBlock.java
@@ -0,0 +0,0 @@ public class CauldronBlock extends Block {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
int i = (Integer) state.getValue(CauldronBlock.LEVEL);
float f = (float) pos.getY() + (6.0F + (float) (3 * i)) / 16.0F;
diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java --- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
@ -145,9 +133,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
BlockEntity tileentity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof HopperBlockEntity) {
HopperBlockEntity.entityInside(world, pos, state, entity, (HopperBlockEntity)blockEntity);
diff --git a/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java
@@ -0,0 +0,0 @@ public class LavaCauldronBlock extends AbstractCauldronBlock {
if (tileentity instanceof HopperBlockEntity) { @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
if (this.isEntityInsideContent(state, pos, entity)) {
entity.lavaHurt();
}
diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
@@ -0,0 +0,0 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(state, pos, entity)) {
// CraftBukkit start
if (entity.mayInteract(world, pos)) {
diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java --- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
@ -160,6 +172,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) { if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) {
// CraftBukkit start - Entity in portal // CraftBukkit start - Entity in portal
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ())); EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
diff --git a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java
@@ -0,0 +0,0 @@ public class PowderSnowBlock extends Block implements BucketPickup {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
if (!(entity instanceof LivingEntity) || entity.getFeetBlockState().is((Block) this)) {
entity.makeStuckInBlock(state, new Vec3(0.8999999761581421D, 1.5D, 0.8999999761581421D));
if (world.isClientSide) {
diff --git a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java --- a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java
@ -205,7 +229,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
entity.makeStuckInBlock(state, new Vec3(0.25D, 0.05000000074505806D, 0.25D)); entity.makeStuckInBlock(state, new Vec3(0.25D, (double)0.05F, 0.25D));
} }
} }
diff --git a/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java b/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java b/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java

View file

@ -0,0 +1,64 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Fri, 14 May 2021 13:42:17 -0500
Subject: [PATCH] Add Mob#lookAt API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
public boolean isInDaylight() {
return getHandle().isSunBurnTick();
}
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) {
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+ getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ());
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) {
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+ getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) {
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+ getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle());
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) {
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+ getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public void lookAt(double x, double y, double z) {
+ getHandle().getLookControl().setLookAt(x, y, z);
+ }
+
+ @Override
+ public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) {
+ getHandle().getLookControl().setLookAt(x, y, z, headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public int getHeadRotationSpeed() {
+ return getHandle().getHeadRotSpeed();
+ }
+
+ @Override
+ public int getMaxHeadPitch() {
+ return getHandle().getMaxHeadXRot();
+ }
// Paper end
}

View file

@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist); this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
// this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
+ // Paper start - Unix domain socket support + // Paper start - Unix domain socket support
+ java.net.SocketAddress bindAddress; + java.net.SocketAddress bindAddress;
@ -129,11 +129,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL @@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
//if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! //if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
String[] split = packet.hostName.split("\00"); String[] split = packet.hostName.split("\00");
if ( ( split.length == 3 || split.length == 4 ) && ( BYPASS_HOSTCHECK || HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper
+ // Paper start - Unix domain socket support + // Paper start - Unix domain socket support
+ java.net.SocketAddress socketAddress = connection.getRemoteAddress(); + java.net.SocketAddress socketAddress = connection.getRemoteAddress();
packet.hostName = split[0]; packet.hostName = split[0];
- connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort()); - connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort());
+ connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0); + connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0);
+ // Paper end + // Paper end
connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] ); connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] );

View file

@ -27,17 +27,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (flag) { if (flag) {
ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
@@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo @@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
public void readAdditionalSaveData(CompoundTag tag) { public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(tag); super.readAdditionalSaveData(nbt);
this.reassessWeaponGoal(); this.reassessWeaponGoal();
+ this.shouldBurnInDay = tag.getBoolean("Paper.ShouldBurnInDay"); // Paper + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); // Paper
+ } + }
+ +
+ // Paper start + // Paper start
+ @Override + @Override
+ public void addAdditionalSaveData(CompoundTag tag) { + public void addAdditionalSaveData(CompoundTag nbt) {
+ super.addAdditionalSaveData(tag); + super.addAdditionalSaveData(nbt);
+ tag.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); + nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
} }
+ // Paper end + // Paper end
@ -57,18 +57,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
@@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy {
if (tag.hasUUID("Paper.SpawningEntity")) { if (nbt.hasUUID("Paper.SpawningEntity")) {
this.spawningEntity = tag.getUUID("Paper.SpawningEntity"); this.spawningEntity = nbt.getUUID("Paper.SpawningEntity");
} }
+ this.shouldBurnInDay = tag.getBoolean("Paper.ShouldBurnInDay"); + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
// Paper end // Paper end
} }
@@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy {
if (this.spawningEntity != null) { if (this.spawningEntity != null) {
tag.setUUID("Paper.SpawningEntity", this.spawningEntity); nbt.setUUID("Paper.SpawningEntity", this.spawningEntity);
} }
+ tag.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); + nbt.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay);
// Paper end // Paper end
} }
@ -81,8 +81,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public boolean shouldBurnInDay() { return shouldBurnInDay; } + public boolean shouldBurnInDay() { return shouldBurnInDay; }
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; } + public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; }
// Paper end // Paper end
private static enum AttackPhase {
class PhantomAttackPlayerTargetGoal extends Goal {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
@ -107,9 +107,9 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/sr
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
@@ -0,0 +0,0 @@ public class CraftSkeleton extends CraftMonster implements Skeleton, com.destroy @@ -0,0 +0,0 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton, co
public void setSkeletonType(SkeletonType type) { public SkeletonType getSkeletonType() {
throw new UnsupportedOperationException("Not supported."); return SkeletonType.NORMAL;
} }
+ +
+ // Paper start + // Paper start

View file

@ -12,7 +12,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.datapack; +package io.papermc.paper.datapack;
+ +
+import Compatibility;
+import io.papermc.paper.event.server.ServerResourcesReloadedEvent; +import io.papermc.paper.event.server.ServerResourcesReloadedEvent;
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.Pack;
@ -25,8 +24,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final boolean enabled; + private final boolean enabled;
+ +
+ PaperDatapack(Pack loader, boolean enabled) { + PaperDatapack(Pack loader, boolean enabled) {
+ this.name = loader.getName(); + this.name = loader.getId();
+ this.compatibility = Compatibility.valueOf(loader.getVersion().name()); + this.compatibility = Compatibility.valueOf(loader.getCompatibility().name());
+ this.enabled = enabled; + this.enabled = enabled;
+ } + }
+ +
@ -52,13 +51,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ MinecraftServer server = MinecraftServer.getServer(); + MinecraftServer server = MinecraftServer.getServer();
+ List<String> enabledKeys = server.getPackRepository().getEnabledPacks().stream().map(Pack::getName).collect(Collectors.toList()); + List<String> enabledKeys = server.getPackRepository().getSelectedPacks().stream().map(Pack::getId).collect(Collectors.toList());
+ if (enabled) { + if (enabled) {
+ enabledKeys.add(this.name); + enabledKeys.add(this.name);
+ } else { + } else {
+ enabledKeys.remove(this.name); + enabledKeys.remove(this.name);
+ } + }
+ server.reloadServerResources(enabledKeys, ServerResourcesReloadedEvent.Cause.PLUGIN); + server.reloadResources(enabledKeys, ServerResourcesReloadedEvent.Cause.PLUGIN);
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java b/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java diff --git a/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java b/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java
@ -83,80 +82,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Override + @Override
+ public Collection<Datapack> getPacks() { + public Collection<Datapack> getPacks() {
+ Collection<Pack> enabledPacks = repository.getEnabledPacks(); + Collection<Pack> enabledPacks = repository.getSelectedPacks();
+ return repository.getPacks().stream().map(loader -> new PaperDatapack(loader, enabledPacks.contains(loader))).collect(Collectors.toList()); + return repository.getAvailablePacks().stream().map(loader -> new PaperDatapack(loader, enabledPacks.contains(loader))).collect(Collectors.toList());
+ } + }
+ +
+ @Override + @Override
+ public Collection<Datapack> getEnabledPacks() { + public Collection<Datapack> getEnabledPacks() {
+ return repository.getEnabledPacks().stream().map(loader -> new PaperDatapack(loader, true)).collect(Collectors.toList()); + return repository.getSelectedPacks().stream().map(loader -> new PaperDatapack(loader, true)).collect(Collectors.toList());
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/packs/repository/Pack.java b/src/main/java/net/minecraft/server/packs/repository/Pack.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/packs/repository/Pack.java
+++ b/src/main/java/net/minecraft/server/packs/repository/Pack.java
@@ -0,0 +0,0 @@ public class Pack implements AutoCloseable {
});
}
+ public final PackCompatibility getVersion() { return this.getCompatibility(); } // Paper - OBFHELPER
public PackCompatibility getCompatibility() {
return this.compatibility;
}
@@ -0,0 +0,0 @@ public class Pack implements AutoCloseable {
return (PackResources) this.supplier.get();
}
+ public final String getName() { return this.getId(); } // Paper - OBFHELPER
public String getId() {
return this.id;
}
diff --git a/src/main/java/net/minecraft/server/packs/repository/PackRepository.java b/src/main/java/net/minecraft/server/packs/repository/PackRepository.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/packs/repository/PackRepository.java
+++ b/src/main/java/net/minecraft/server/packs/repository/PackRepository.java
@@ -0,0 +0,0 @@ public class PackRepository implements AutoCloseable {
return this.available.keySet();
}
+ public final Collection<Pack> getPacks() { return this.getAvailablePacks(); } // Paper - OBFHELPER
public Collection<Pack> getAvailablePacks() {
return this.available.values();
}
@@ -0,0 +0,0 @@ public class PackRepository implements AutoCloseable {
return (Collection) this.selected.stream().map(Pack::getId).collect(ImmutableSet.toImmutableSet());
}
+ public final Collection<Pack> getEnabledPacks() { return this.getSelectedPacks(); } // Paper - OBFHELPER
public Collection<Pack> getSelectedPacks() {
return this.selected;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ import com.mojang.serialization.Lifecycle;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
+import io.papermc.paper.datapack.PaperDatapackManager; // Paper
import io.papermc.paper.util.TraceUtil;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import java.awt.image.BufferedImage;
@@ -0,0 +0,0 @@ public final class CraftServer implements Server { @@ -0,0 +0,0 @@ public final class CraftServer implements Server {
public boolean ignoreVanillaPermissions = false; public boolean ignoreVanillaPermissions = false;
private final List<CraftPlayer> playerView; private final List<CraftPlayer> playerView;
public int reloadCount; public int reloadCount;
+ private final PaperDatapackManager datapackManager; // Paper + private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
public static Exception excessiveVelEx; // Paper - Velocity warnings public static Exception excessiveVelEx; // Paper - Velocity warnings
static { static {
@@ -0,0 +0,0 @@ public final class CraftServer implements Server { @@ -0,0 +0,0 @@ public final class CraftServer implements Server {
TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second TicketType.PLUGIN.timeout = Math.min(20, this.configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
minimumAPI = configuration.getString("settings.minimum-api"); this.minimumAPI = this.configuration.getString("settings.minimum-api");
loadIcon(); this.loadIcon();
+ datapackManager = new PaperDatapackManager(console.getPackRepository()); // Paper + datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
} }
public boolean getCommandBlockOverride(String command) { public boolean getCommandBlockOverride(String command) {
@ -166,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ +
+ @Override + @Override
+ public PaperDatapackManager getDatapackManager() { + public io.papermc.paper.datapack.PaperDatapackManager getDatapackManager() {
+ return datapackManager; + return datapackManager;
+ } + }
+ +

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL @@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
private static final Component IGNORE_STATUS_REASON = new TextComponent("Ignoring status request"); private static final Component IGNORE_STATUS_REASON = new TextComponent("Ignoring status request");
private final MinecraftServer server; private final MinecraftServer server;
private final Connection connection; final Connection getNetworkManager() { return this.connection; } // Paper - OBFHELPER private final Connection connection;
+ private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper + private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper
public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) { public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) {
@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Spigot Start // Spigot Start
//if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! //if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
String[] split = packet.hostName.split("\00"); String[] split = packet.hostName.split("\00");
- if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) { - if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) {
+ if ( ( split.length == 3 || split.length == 4 ) && ( BYPASS_HOSTCHECK || HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper + if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper
packet.hostName = split[0]; packet.hostName = split[0];
connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) connection.getRemoteAddress()).getPort()); connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort());
connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] ); connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] );

View file

@ -9,24 +9,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl @@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
this.worldDataServer.setClearWeatherTime(clearDuration); this.serverLevelData.setClearWeatherTime(clearDuration);
this.worldDataServer.setRainTime(rainDuration); this.serverLevelData.setRainTime(rainDuration);
this.worldDataServer.setThunderTime(rainDuration); this.serverLevelData.setThunderTime(rainDuration);
- this.worldDataServer.setRaining(raining); - this.serverLevelData.setRaining(raining);
- this.worldDataServer.setThundering(thundering); - this.serverLevelData.setThundering(thundering);
+ this.worldDataServer.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper + this.serverLevelData.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper
+ this.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper + this.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper
} }
public Biome getBiomeBySeed(int i, int j, int k) { return getUncachedNoiseBiome(i, j, k); } // Paper - OBFHELPER @Override
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl @@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
this.worldDataServer.setThunderTime(j); this.serverLevelData.setThunderTime(j);
this.worldDataServer.setRainTime(k); this.serverLevelData.setRainTime(k);
this.worldDataServer.setClearWeatherTime(i); this.serverLevelData.setClearWeatherTime(i);
- this.worldDataServer.setThundering(flag1); - this.serverLevelData.setThundering(flag1);
- this.worldDataServer.setRaining(flag2); - this.serverLevelData.setRaining(flag2);
+ this.worldDataServer.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper + this.serverLevelData.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper
+ this.worldDataServer.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper + this.serverLevelData.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper
} }
this.oThunderLevel = this.thunderLevel; this.oThunderLevel = this.thunderLevel;
@ -34,16 +34,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private void stopWeather() { private void stopWeather() {
// CraftBukkit start // CraftBukkit start
- this.worldDataServer.setRaining(false); - this.serverLevelData.setRaining(false);
+ this.worldDataServer.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night + this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night
// If we stop due to everyone sleeping we should reset the weather duration to some other random value. // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
// Not that everyone ever manages to get the whole server to sleep at the same time.... // Not that everyone ever manages to get the whole server to sleep at the same time....
if (!this.worldDataServer.isRaining()) { if (!this.serverLevelData.isRaining()) {
this.worldDataServer.setRainTime(0); this.serverLevelData.setRainTime(0);
} }
// CraftBukkit end // CraftBukkit end
- this.worldDataServer.setThundering(false); - this.serverLevelData.setThundering(false);
+ this.worldDataServer.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night + this.serverLevelData.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night
// CraftBukkit start // CraftBukkit start
// If we stop due to everyone sleeping we should reset the weather duration to some other random value. // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
// Not that everyone ever manages to get the whole server to sleep at the same time.... // Not that everyone ever manages to get the whole server to sleep at the same time....
@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return; return;
} }
org.bukkit.World world = Bukkit.getWorld(getLevelName()); org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
if (world != null) { if (world != null) {
- ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering); - ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering);
+ ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag, cause); // Paper + ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag, cause); // Paper
@ -89,29 +89,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.UNKNOWN); + this.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.UNKNOWN);
+ } + }
+ +
+ public void setStorm(boolean flag, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) { + public void setRaining(boolean raining, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) {
+ // Paper end + // Paper end
// CraftBukkit start // CraftBukkit start
- if (this.raining == raining) { if (this.raining == raining) {
+ if (this.raining == flag) {
return; return;
} @@ -0,0 +0,0 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
org.bukkit.World world = Bukkit.getWorld(getLevelName()); org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
if (world != null) { if (world != null) {
- WeatherChangeEvent weather = new WeatherChangeEvent(world, raining); - WeatherChangeEvent weather = new WeatherChangeEvent(world, raining);
+ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag, cause); // Paper + WeatherChangeEvent weather = new WeatherChangeEvent(world, raining, cause); // Paper
Bukkit.getServer().getPluginManager().callEvent(weather); Bukkit.getServer().getPluginManager().callEvent(weather);
if (weather.isCancelled()) { if (weather.isCancelled()) {
return; return;
}
}
// CraftBukkit end
- this.raining = raining;
+ this.raining = flag;
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@ -121,16 +112,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void setStorm(boolean hasStorm) { public void setStorm(boolean hasStorm) {
- world.levelData.setRaining(hasStorm); - world.levelData.setRaining(hasStorm);
+ world.worldDataServer.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper + world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper
setWeatherDuration(0); // Reset weather duration (legacy behaviour) this.setWeatherDuration(0); // Reset weather duration (legacy behaviour)
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
} }
@@ -0,0 +0,0 @@ public class CraftWorld implements World { @@ -0,0 +0,0 @@ public class CraftWorld implements World {
@Override @Override
public void setThundering(boolean thundering) { public void setThundering(boolean thundering) {
- world.worldDataServer.setThundering(thundering); - world.serverLevelData.setThundering(thundering);
+ world.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper + world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper
setThunderDuration(0); // Reset weather duration (legacy behaviour) this.setThunderDuration(0); // Reset weather duration (legacy behaviour)
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
} }

View file

@ -15,13 +15,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
File pluginFolder = (File) console.options.valueOf("plugins"); File pluginFolder = (File) console.options.valueOf("plugins");
- if (pluginFolder.exists()) { - if (pluginFolder.exists()) {
- Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); - Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder);
+ // Paper start + // Paper start
+ if (true || pluginFolder.exists()) { + if (true || pluginFolder.exists()) {
+ if (!pluginFolder.exists()) { + if (!pluginFolder.exists()) {
+ pluginFolder.mkdirs(); + pluginFolder.mkdirs();
+ } + }
+ Plugin[] plugins = pluginManager.loadPlugins(pluginFolder, this.extraPluginJars()); + Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, this.extraPluginJars());
+ // Paper end + // Paper end
for (Plugin plugin : plugins) { for (Plugin plugin : plugins) {
try { try {
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
public void enablePlugins(PluginLoadOrder type) { public void enablePlugins(PluginLoadOrder type) {
if (type == PluginLoadOrder.STARTUP) { if (type == PluginLoadOrder.STARTUP) {
helpMap.clear(); this.helpMap.clear();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java --- a/src/main/java/org/bukkit/craftbukkit/Main.java

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Irmo van den Berge <irmo.vandenberge@ziggo.nl> From: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
Date: Wed, 10 Mar 2021 21:26:31 +0100 Date: Wed, 10 Mar 2021 21:26:31 +0100
Subject: [PATCH] Add fast alternative constructor for Vector3f Subject: [PATCH] Add fast alternative constructor for Rotations
Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl> Signed-off-by: Irmo van den Berge <irmo.vandenberge@ziggo.nl>
@ -26,5 +26,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end + // Paper end
+ +
public ListTag save() { public ListTag save() {
ListTag nbttaglist = new ListTag(); ListTag listTag = new ListTag();
listTag.add(FloatTag.valueOf(this.x));

View file

@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void registerGoals() { protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this)); this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(0, new UseItemGoal<>(this, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> { this.goalSelector.addGoal(0, new UseItemGoal<>(this, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> {
- return this.world.isNight() && !entityvillagertrader.isInvisible(); - return this.level.isNight() && !entityvillagertrader.isInvisible();
+ return canDrinkPotion && this.world.isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API + return this.canDrinkPotion && this.level.isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
})); }));
this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> { this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> {
- return this.level.isDay() && entityvillagertrader.isInvisible(); - return this.level.isDay() && entityvillagertrader.isInvisible();
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
@@ -0,0 +0,0 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande @@ -0,0 +0,0 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande
public void setDespawnDelay(int despawnDelay) { public void setDespawnDelay(int despawnDelay) {
getHandle().setDespawnDelay(despawnDelay); this.getHandle().setDespawnDelay(despawnDelay);
} }
+ +
+ // Paper start - Add more WanderingTrader API + // Paper start - Add more WanderingTrader API

View file

@ -9,15 +9,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
// Paper end // Paper end
String playerName = gameProfile.getName(); String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress(); java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
+ java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) connection.getRawAddress()).getAddress(); // Paper + java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) connection.getRawAddress()).getAddress(); // Paper
java.util.UUID uniqueId = gameProfile.getId(); java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId();
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;
// Paper start // Paper start
PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(getGameProfile()); PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile);
server.getPluginManager().callEvent(asyncEvent); server.getPluginManager().callEvent(asyncEvent);

View file

@ -12,33 +12,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
- FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()), source, result); - FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result);
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()), source, result, (org.bukkit.inventory.CookingRecipe<?>) recipe.toBukkitRecipe()); // Paper + FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result, (org.bukkit.inventory.CookingRecipe<?>) irecipe.toBukkitRecipe()); // Paper
this.level.getCraftServer().getPluginManager().callEvent(furnaceSmeltEvent); world.getCraftServer().getPluginManager().callEvent(furnaceSmeltEvent);
if (furnaceSmeltEvent.isCancelled()) { if (furnaceSmeltEvent.isCancelled()) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable, Ticka @@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
if (this.cookingProgress[i] >= this.cookingTime[i]) { if (campfire.cookingProgress[i] >= campfire.cookingTime[i]) {
SimpleContainer inventorysubcontainer = new SimpleContainer(new ItemStack[]{itemstack}); SimpleContainer inventorysubcontainer = new SimpleContainer(new ItemStack[]{itemstack});
- ItemStack itemstack1 = (ItemStack) this.level.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, this.level).map((recipecampfire) -> { - ItemStack itemstack1 = (ItemStack) world.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, world).map((recipecampfire) -> {
+ // Paper start + // Paper start
+ Optional<CampfireCookingRecipe> recipe = this.level.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, this.level); + Optional<CampfireCookingRecipe> recipe = world.getRecipeManager().getRecipeFor(RecipeType.CAMPFIRE_COOKING, inventorysubcontainer, world);
+ ItemStack itemstack1 = (ItemStack) recipe.map((recipecampfire) -> { + ItemStack itemstack1 = (ItemStack) recipe.map((recipecampfire) -> {
+ // Paper end + // Paper end
return recipecampfire.assemble(inventorysubcontainer); return recipecampfire.assemble(inventorysubcontainer);
}).orElse(itemstack); }).orElse(itemstack);
BlockPos blockposition = this.getBlockPos();
@@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable, Ticka @@ -0,0 +0,0 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
- BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.level, this.worldPosition), source, result); - BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result);
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.level, this.worldPosition), source, result, (org.bukkit.inventory.CookingRecipe<?>) recipe.map(CampfireCookingRecipe::toBukkitRecipe).orElse(null)); // Paper + BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, pos), source, result, (org.bukkit.inventory.CookingRecipe<?>) recipe.map(CampfireCookingRecipe::toBukkitRecipe).orElse(null)); // Paper
this.level.getCraftServer().getPluginManager().callEvent(blockCookEvent); world.getCraftServer().getPluginManager().callEvent(blockCookEvent);
if (blockCookEvent.isCancelled()) { if (blockCookEvent.isCancelled()) {

View file

@ -5,6 +5,18 @@ Subject: [PATCH] Add support for hex color codes in console
Converts upstream's hex color code legacy format into actual hex color codes in the console. Converts upstream's hex color code legacy format into actual hex color codes in the console.
diff --git a/build.gradle.kts b/build.gradle.kts
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -0,0 +0,0 @@ dependencies {
Scanning takes about 1-2 seconds so adding this speeds up the server start.
*/
implementation("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - implementation
+ annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for out hex color converter plugin
// Paper end
implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper
implementation("org.apache.logging.log4j:log4j-api:2.14.1") // Paper
diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

View file

@ -8,16 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/s
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java --- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java
+++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java +++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
+import io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent; // Paper
+import io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent; // Paper
+import io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent; // Paper
public class WorldBorder {
@@ -0,0 +0,0 @@ public class WorldBorder { @@ -0,0 +0,0 @@ public class WorldBorder {
} }
@ -25,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.centerX = x; - this.centerX = x;
- this.centerZ = z; - this.centerZ = z;
+ // Paper start + // Paper start
+ WorldBorderCenterChangeEvent event = new WorldBorderCenterChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), new org.bukkit.Location(world.getWorld(), this.getCenterX(), 0, this.getCenterZ()), new org.bukkit.Location(world.getWorld(), x, 0, z)); + io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), new org.bukkit.Location(world.getWorld(), this.getCenterX(), 0, this.getCenterZ()), new org.bukkit.Location(world.getWorld(), x, 0, z));
+ if (!event.callEvent()) return; + if (!event.callEvent()) return;
+ this.centerX = event.getNewCenter().getX(); + this.centerX = event.getNewCenter().getX();
+ this.centerZ = event.getNewCenter().getZ(); + this.centerZ = event.getNewCenter().getZ();
@ -47,9 +37,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void setSize(double size) { public void setSize(double size) {
- this.extent = new WorldBorder.StaticBorderExtent(size); - this.extent = new WorldBorder.StaticBorderExtent(size);
+ // Paper start + // Paper start
+ WorldBorderBoundsChangeEvent event = new WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE, getSize(), size, 0); + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE, getSize(), size, 0);
+ if (!event.callEvent()) return; + if (!event.callEvent()) return;
+ if (event.getType() == WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDuration() > 0) { // If changed to a timed transition + if (event.getType() == io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && event.getDuration() > 0) { // If changed to a timed transition
+ lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDuration()); + lerpSizeBetween(event.getOldSize(), event.getNewSize(), event.getDuration());
+ return; + return;
+ } + }
@ -69,13 +59,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void lerpSizeBetween(double fromSize, double toSize, long time) { public void lerpSizeBetween(double fromSize, double toSize, long time) {
- this.extent = (WorldBorder.BorderExtent) (fromSize == toSize ? new WorldBorder.StaticBorderExtent(toSize) : new WorldBorder.MovingBorderExtent(fromSize, toSize, time)); - this.extent = (WorldBorder.BorderExtent) (fromSize == toSize ? new WorldBorder.StaticBorderExtent(toSize) : new WorldBorder.MovingBorderExtent(fromSize, toSize, time));
+ // Paper start + // Paper start
+ WorldBorderBoundsChangeEvent.Type type; + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type type;
+ if (fromSize == toSize) { // new size = old size + if (fromSize == toSize) { // new size = old size
+ type = WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE; // Use INSTANT_MOVE because below it creates a Static border if they are equal. + type = io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE; // Use INSTANT_MOVE because below it creates a Static border if they are equal.
+ } else { + } else {
+ type = WorldBorderBoundsChangeEvent.Type.STARTED_MOVE; + type = io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent.Type.STARTED_MOVE;
+ } + }
+ WorldBorderBoundsChangeEvent event = new WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), type, fromSize, toSize, time); + io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent event = new io.papermc.paper.event.world.border.WorldBorderBoundsChangeEvent(world.getWorld(), world.getWorld().getWorldBorder(), type, fromSize, toSize, time);
+ if (!event.callEvent()) return; + if (!event.callEvent()) return;
+ this.extent = (WorldBorder.BorderExtent) (fromSize == event.getNewSize() ? new WorldBorder.StaticBorderExtent(event.getNewSize()) : new WorldBorder.MovingBorderExtent(fromSize, event.getNewSize(), event.getDuration())); + this.extent = (WorldBorder.BorderExtent) (fromSize == event.getNewSize() ? new WorldBorder.StaticBorderExtent(event.getNewSize()) : new WorldBorder.MovingBorderExtent(fromSize, event.getNewSize(), event.getDuration()));
+ // Paper end + // Paper end
@ -91,32 +81,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
@@ -0,0 +0,0 @@ public class WorldBorder { @@ -0,0 +0,0 @@ public class WorldBorder {
class MovingBorderExtent implements WorldBorder.BorderExtent {
- private final double from;
- private final double to;
+ private final double from; public final double getOldSize() { return this.from; } // Paper - OBFHELPER
+ private final double to; public final double getNewSize() { return this.to; } // Paper - OBFHELPER
private final long lerpEnd;
private final long lerpBegin;
- private final double lerpDuration;
+ private final double lerpDuration; public final double getDuration() { return this.lerpDuration; } // Paper - OBFHELPER
private MovingBorderExtent(double d0, double d1, long i) {
this.from = d0;
@@ -0,0 +0,0 @@ public class WorldBorder {
@Override @Override
public WorldBorder.BorderExtent update() { public WorldBorder.BorderExtent update() {
+ if (this.getLerpTimeRemaining() <= 0L) new WorldBorderBoundsChangeFinishEvent(world.getWorld(), world.getWorld().getWorldBorder(), getOldSize(), getNewSize(), getDuration()).callEvent(); // Paper + if (this.getLerpRemainingTime() <= 0L) new io.papermc.paper.event.world.border.WorldBorderBoundsChangeFinishEvent(world.getWorld(), world.getWorld().getWorldBorder(), this.from, this.to, this.lerpDuration).callEvent(); // Paper
return (WorldBorder.BorderExtent) (this.getLerpRemainingTime() <= 0L ? WorldBorder.this.new StaticBorderExtent(this.to) : this); return (WorldBorder.BorderExtent) (this.getLerpRemainingTime() <= 0L ? WorldBorder.this.new StaticBorderExtent(this.to) : this);
} }
@@ -0,0 +0,0 @@ public class WorldBorder {
double getSize();
+ default long getLerpTimeRemaining() { return getLerpRemainingTime(); } // Paper - OBFHELPER
long getLerpRemainingTime();
double getLerpTarget();

View file

@ -4,38 +4,17 @@ Date: Thu, 24 Dec 2020 12:27:41 -0800
Subject: [PATCH] Added PlayerBedFailEnterEvent Subject: [PATCH] Added PlayerBedFailEnterEvent
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
this.message = ichatbasecomponent;
}
+ public @Nullable Component getChatComponent() { return this.getMessage(); }; // Paper - OBFHELPER
@Nullable
public Component getMessage() {
return this.message;
diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BedBlock.java --- a/src/main/java/net/minecraft/world/level/block/BedBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.apache.commons.lang3.ArrayUtils;
+import io.papermc.paper.event.player.PlayerBedFailEnterEvent; // Paper
+import io.papermc.paper.adventure.PaperAdventure; // Paper
public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock {
@@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock @@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
BlockPos finalblockposition = pos; BlockPos finalblockposition = pos;
// CraftBukkit end // CraftBukkit end
player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> { player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
+ // Paper start - PlayerBedFailEnterEvent + // Paper start - PlayerBedFailEnterEvent
+ if (entityhuman_enumbedresult != null) { + if (entityhuman_enumbedresult != null) {
+ PlayerBedFailEnterEvent event = new PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE, PaperAdventure.asAdventure(entityhuman_enumbedresult.getChatComponent())); + io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE, io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage()));
+ if (!event.callEvent()) { + if (!event.callEvent()) {
+ return; + return;
+ } + }
@ -49,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entityhuman_enumbedresult != null) { if (entityhuman_enumbedresult != null) {
- player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); - player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true);
+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper + final net.kyori.adventure.text.Component message = event.getMessage(); // Paper
+ if(message != null) player.displayClientMessage(PaperAdventure.asVanilla(message), true); // Paper + if(message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper
} }
+ } // Paper + } // Paper

View file

@ -9,14 +9,14 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
// Paper start - async tab completion // Paper start - async tab completion
com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event; com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event;
- java.util.List<String> completions = new java.util.ArrayList<>(); - java.util.List<String> completions = new java.util.ArrayList<>();
String buffer = packet.getCommand(); String buffer = packet.getCommand();
- event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getPlayer(), completions, - event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), completions,
+ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getPlayer(), + event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(),
buffer, true, null); buffer, true, null);
event.callEvent(); event.callEvent();
- completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions(); - completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions();
@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// If the event isn't handled, we can assume that we have no completions, and so we'll ask the server // If the event isn't handled, we can assume that we have no completions, and so we'll ask the server
if (!event.isHandled()) { if (!event.isHandled()) {
if (!event.isCancelled()) { if (!event.isCancelled()) {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}); });
} }
} else if (!completions.isEmpty()) { } else if (!completions.isEmpty()) {
@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ }); + });
com.mojang.brigadier.suggestion.Suggestions suggestions = builder.buildFuture().join(); com.mojang.brigadier.suggestion.Suggestions suggestions = builder.buildFuture().join();
com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent suggestEvent = new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent(this.getPlayer(), suggestions, buffer); com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent suggestEvent = new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent(this.getCraftPlayer(), suggestions, buffer);
suggestEvent.setCancelled(suggestions.isEmpty()); suggestEvent.setCancelled(suggestions.isEmpty());
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -18,24 +18,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ allowUsingSignsInsideSpawnProtection = getBoolean("allow-using-signs-inside-spawn-protection", allowUsingSignsInsideSpawnProtection); + allowUsingSignsInsideSpawnProtection = getBoolean("allow-using-signs-inside-spawn-protection", allowUsingSignsInsideSpawnProtection);
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ import net.minecraft.world.level.Level; @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
import net.minecraft.world.level.LevelReader; int i = this.player.level.getMaxBuildHeight();
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.CommandBlock;
+import net.minecraft.world.level.block.SignBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.CommandBlockEntity;
import net.minecraft.world.level.block.entity.JigsawBlockEntity;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
this.player.resetLastActionTime(); if (blockposition.getY() < i) {
if (blockposition.getY() < this.server.getMaxBuildHeight()) {
- if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition)) { - if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition)) {
+ if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && (worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition) || (worldserver.paperConfig.allowUsingSignsInsideSpawnProtection && worldserver.getBlockState(blockposition).getBlock() instanceof SignBlock))) { // Paper + if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && (worldserver.mayInteract((net.minecraft.world.entity.player.Player) this.player, blockposition) || (worldserver.paperConfig.allowUsingSignsInsideSpawnProtection && worldserver.getBlockState(blockposition).getBlock() instanceof net.minecraft.world.level.block.SignBlock))) { // Paper
// CraftBukkit start - Check if we can actually do something over this large a distance // CraftBukkit start - Check if we can actually do something over this large a distance
// Paper - move check up // Paper - move check up
this.player.stopUsingItem(); // SPIGOT-4706 this.player.stopUsingItem(); // SPIGOT-4706

View file

@ -4,34 +4,22 @@ Date: Sat, 8 May 2021 15:01:54 -0700
Subject: [PATCH] Attributes API for item defaults Subject: [PATCH] Attributes API for item defaults
diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/Item.java
+++ b/src/main/java/net/minecraft/world/item/Item.java
@@ -0,0 +0,0 @@ public class Item implements ItemLike {
return false;
}
+ public Multimap<Attribute, AttributeModifier> getAttributesForSlot(EquipmentSlot enumItemSlot) { return getDefaultAttributeModifiers(enumItemSlot); } // Paper - OBFHELPER
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot slot) {
return ImmutableMultimap.of();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
return this.getItem(itemToBeRepaired.getType()).canRepair(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial)); return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial));
} }
+ @Override + @Override
+ public com.google.common.collect.Multimap<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> getItemAttributes(org.bukkit.Material material, org.bukkit.inventory.EquipmentSlot equipmentSlot) { + public com.google.common.collect.Multimap<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> getItemAttributes(org.bukkit.Material material, org.bukkit.inventory.EquipmentSlot equipmentSlot) {
+ Item item = this.getItem(material); + Item item = CraftMagicNumbers.getItem(material);
+ if (item == null) { + if (item == null) {
+ throw new IllegalArgumentException(material + " is not an item and therefore does not have attributes"); + throw new IllegalArgumentException(material + " is not an item and therefore does not have attributes");
+ } + }
+ com.google.common.collect.ImmutableMultimap.Builder<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> attributeMapBuilder = com.google.common.collect.ImmutableMultimap.builder(); + com.google.common.collect.ImmutableMultimap.Builder<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> attributeMapBuilder = com.google.common.collect.ImmutableMultimap.builder();
+ item.getAttributesForSlot(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> { + item.getDefaultAttributeModifiers(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> {
+ attributeMapBuilder.put(org.bukkit.Registry.ATTRIBUTE.get(CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.ATTRIBUTE.getKey(attributeBase))), org.bukkit.craftbukkit.attribute.CraftAttributeInstance.convert(attributeModifier)); + attributeMapBuilder.put(org.bukkit.Registry.ATTRIBUTE.get(CraftNamespacedKey.fromMinecraft(net.minecraft.core.Registry.ATTRIBUTE.getKey(attributeBase))), org.bukkit.craftbukkit.attribute.CraftAttributeInstance.convert(attributeModifier));
+ }); + });
+ return attributeMapBuilder.build(); + return attributeMapBuilder.build();

View file

@ -8,12 +8,12 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
list.stream().map(StringTag::valueOf).forEach(nbttaglist::add);
ItemStack old = itemstack.copy(); // CraftBukkit
itemstack.addTagElement("pages", (Tag) nbttaglist);
- CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit
+ this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
} }
itemstack.addTagElement("pages", (Tag) nbttaglist);
- CraftEventFactory.handleEditBookEvent(player, slot, old, itemstack); // CraftBukkit
+ this.player.containerMenu.setItem(slot, CraftEventFactory.handleEditBookEvent(player, slot, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
} }
@Override

View file

@ -10,22 +10,14 @@ diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/ma
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -0,0 +0,0 @@ import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.npc.AbstractVillager;
+import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
@@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -0,0 +0,0 @@ public abstract class PlayerList {
} }
// Paper end // Paper end
+ // Paper - Drop carried item when player has disconnected + // Paper - Drop carried item when player has disconnected
+ if (!entityplayer.inventory.getCarried().isEmpty()) { + if (!entityplayer.containerMenu.getCarried().isEmpty()) {
+ ItemStack carried = entityplayer.inventory.getCarried(); + net.minecraft.world.item.ItemStack carried = entityplayer.containerMenu.getCarried();
+ entityplayer.inventory.setCarried(ItemStack.NULL_ITEM); + entityplayer.containerMenu.setCarried(net.minecraft.world.item.ItemStack.EMPTY);
+ entityplayer.drop(carried, false); + entityplayer.drop(carried, false);
+ } + }
+ // Paper end + // Paper end

View file

@ -24,14 +24,6 @@ diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/s
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java --- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java +++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
@@ -0,0 +0,0 @@
package com.destroystokyo.paper.console;
+import com.destroystokyo.paper.PaperConfig;
+import io.papermc.paper.console.BrigadierCommandHighlighter;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.bukkit.craftbukkit.command.ConsoleCommandCompleter;
@@ -0,0 +0,0 @@ public final class PaperConsole extends SimpleTerminalConsole { @@ -0,0 +0,0 @@ public final class PaperConsole extends SimpleTerminalConsole {
@Override @Override
@ -43,8 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
.completer(new ConsoleCommandCompleter(this.server)) .completer(new ConsoleCommandCompleter(this.server))
- ); - );
+ .option(LineReader.Option.COMPLETE_IN_WORD, true); + .option(LineReader.Option.COMPLETE_IN_WORD, true);
+ if (PaperConfig.enableBrigadierConsoleHighlighting) { + if (com.destroystokyo.paper.PaperConfig.enableBrigadierConsoleHighlighting) {
+ builder.highlighter(new BrigadierCommandHighlighter(this.server, this.server.createCommandSourceStack())); + builder.highlighter(new io.papermc.paper.console.BrigadierCommandHighlighter(this.server, this.server.createCommandSourceStack()));
+ } + }
+ return super.buildReader(builder); + return super.buildReader(builder);
} }
@ -92,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.addCandidates(candidates, Collections.emptyList(), existing); + this.addCandidates(candidates, Collections.emptyList(), existing);
+ return; + return;
+ } + }
+ final CommandDispatcher<CommandSourceStack> dispatcher = this.server.getCommands().dispatcher(); + final CommandDispatcher<CommandSourceStack> dispatcher = this.server.getCommands().getDispatcher();
+ final ParseResults<CommandSourceStack> results = dispatcher.parse(prepareStringReader(line.line()), this.commandSourceStack); + final ParseResults<CommandSourceStack> results = dispatcher.parse(prepareStringReader(line.line()), this.commandSourceStack);
+ this.addCandidates( + this.addCandidates(
+ candidates, + candidates,
@ -184,7 +176,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Override + @Override
+ public AttributedString highlight(final @NonNull LineReader reader, final @NonNull String buffer) { + public AttributedString highlight(final @NonNull LineReader reader, final @NonNull String buffer) {
+ final AttributedStringBuilder builder = new AttributedStringBuilder(); + final AttributedStringBuilder builder = new AttributedStringBuilder();
+ final ParseResults<CommandSourceStack> results = this.server.getCommands().dispatcher().parse(BrigadierCommandCompleter.prepareStringReader(buffer), this.commandSourceStack); + final ParseResults<CommandSourceStack> results = this.server.getCommands().getDispatcher().parse(BrigadierCommandCompleter.prepareStringReader(buffer), this.commandSourceStack);
+ int pos = 0; + int pos = 0;
+ if (buffer.startsWith("/")) { + if (buffer.startsWith("/")) {
+ builder.append("/", AttributedStyle.DEFAULT); + builder.append("/", AttributedStyle.DEFAULT);
@ -214,41 +206,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return builder.toAttributedString(); + return builder.toAttributedString();
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -0,0 +0,0 @@ public class Commands {
};
}
- public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> getDispatcher() {
+ public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> getDispatcher() { return this.dispatcher(); } public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher() { // Paper - OBFHELPER
return this.dispatcher;
}
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
@@ -0,0 +0,0 @@ public class ComponentUtils {
TextComponent chatcomponenttext = new TextComponent("");
boolean flag = true;
- for (Iterator iterator = elements.iterator(); iterator.hasNext(); flag = false) {
+ for (Iterator<T> iterator = elements.iterator(); iterator.hasNext(); flag = false) { // Paper - decompile fix
T t0 = iterator.next();
if (!flag) {
@@ -0,0 +0,0 @@ public class ComponentUtils {
return new TranslatableComponent("chat.square_brackets", new Object[]{text});
}
- public static Component fromMessage(Message message) {
+ public static Component fromMessage(Message message) { return fromMessage(message); } public static Component fromMessage(final @org.checkerframework.checker.nullness.qual.NonNull Message message) { // Paper - OBFHELPER
return (Component) (message instanceof Component ? (Component) message : new TextComponent(message.getString()));
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java

View file

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 26 Feb 2021 16:24:25 -0600
Subject: [PATCH] Expose Tracked Players
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
+ // Paper start
+ @Override
+ public Set<Player> getTrackedPlayers() {
+ if (entity.tracker == null) {
+ return java.util.Collections.emptySet();
+ }
+
+ Set<Player> set = new HashSet<>(entity.tracker.seenBy.size());
+ for (net.minecraft.server.network.ServerPlayerConnection connection : entity.tracker.seenBy) {
+ set.add(connection.getPlayer().getBukkitEntity().getPlayer());
+ }
+ return set;
+ }
+ // Paper end
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{

View file

@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) { public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getItemStackRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
} }
+ +
+ @Override + @Override

View file

@ -17,15 +17,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public Collection<PotionEffect> getEffects(PotionType damage, boolean upgraded, boolean extended) { public Collection<PotionEffect> getEffects(PotionType damage, boolean upgraded, boolean extended) {
- if (cache.containsKey(damage)) - if (CraftPotionBrewer.cache.containsKey(damage))
- return cache.get(damage); - return CraftPotionBrewer.cache.get(damage);
+ // Paper start + // Paper start
+ int key = damage.ordinal() << 2; + int key = damage.ordinal() << 2;
+ key |= (upgraded ? 1 : 0) << 1; + key |= (upgraded ? 1 : 0) << 1;
+ key |= extended ? 1 : 0; + key |= extended ? 1 : 0;
+ +
+ if (cache.containsKey(key)) + if (CraftPotionBrewer.cache.containsKey(key))
+ return cache.get(key); + return CraftPotionBrewer.cache.get(key);
+ // Paper end + // Paper end
List<MobEffectInstance> mcEffects = Potion.byName(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).getEffects(); List<MobEffectInstance> mcEffects = Potion.byName(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).getEffects();
@ -34,11 +34,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
builder.add(CraftPotionUtil.toBukkit(effect)); builder.add(CraftPotionUtil.toBukkit(effect));
} }
- cache.put(damage, builder.build()); - CraftPotionBrewer.cache.put(damage, builder.build());
+ cache.put(key, builder.build()); // Paper + CraftPotionBrewer.cache.put(key, builder.build()); // Paper
- return cache.get(damage); - return CraftPotionBrewer.cache.get(damage);
+ return cache.get(key); // Paper + return CraftPotionBrewer.cache.get(key); // Paper
} }
@Override @Override

View file

@ -27,9 +27,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
- this.player.absMoveTo(d0, d1, d2, f, f1); - this.player.absMoveTo(d0, d1, d2, f, f1);
+ this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper setPositionRotation for teleportation + this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper setPositionRotation for teleportation
this.player.forceCheckHighPriority(); // Paper
this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
} }
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java

View file

@ -28,9 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -0,0 +0,0 @@ public abstract class PlayerList {
} }
Player respawnPlayer = cserver.getPlayer(entityplayer1); Player respawnPlayer = this.cserver.getPlayer(entityplayer1);
- PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2); - PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2);
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn); // Paper - Fix anchor respawn acting as a bed respawn from the end portal + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn); // Paper - Fix anchor respawn acting as a bed respawn from the end portal
cserver.getPluginManager().callEvent(respawnEvent); this.cserver.getPluginManager().callEvent(respawnEvent);
// Spigot Start // Spigot Start
if (entityplayer.connection.isDisconnected()) { if (entityplayer.connection.isDisconnected()) {

View file

@ -104,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ LOGGER.info("Force upgrading " + this.worldName); + LOGGER.info("Force upgrading " + this.worldName);
+ LOGGER.info("Counting regionfiles for " + this.worldName); + LOGGER.info("Counting regionfiles for " + this.worldName);
+ final File[] regionFiles = regionFolder.listFiles((final File dir, final String name) -> { + final File[] regionFiles = regionFolder.listFiles((final File dir, final String name) -> {
+ return WorldUpgrader.getRegionfileRegex().matcher(name).matches(); + return WorldUpgrader.REGEX.matcher(name).matches();
+ }); + });
+ if (regionFiles == null) { + if (regionFiles == null) {
+ LOGGER.info("Found no regionfiles to convert for world " + this.worldName); + LOGGER.info("Found no regionfiles to convert for world " + this.worldName);
@ -270,8 +270,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
worlddata = new PrimaryLevelData(worldsettings, generatorsettings, Lifecycle.stable()); worlddata = new PrimaryLevelData(worldsettings, generatorsettings, Lifecycle.stable());
} }
worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
- if (options.has("forceUpgrade")) { - if (this.options.has("forceUpgrade")) {
- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), options.has("eraseCache"), () -> { - net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), this.options.has("eraseCache"), () -> {
- return true; - return true;
- }, worlddata.worldGenSettings().dimensions().entrySet().stream().map((entry1) -> { - }, worlddata.worldGenSettings().dimensions().entrySet().stream().map((entry1) -> {
- return ResourceKey.create(Registry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).location()); - return ResourceKey.create(Registry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).location());
@ -296,57 +296,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ResourceKey<Level> worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, dimensionKey.location()); ResourceKey<Level> worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, dimensionKey.location());
if (dimensionKey == LevelStem.OVERWORLD) { if (dimensionKey == LevelStem.OVERWORLD) {
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -0,0 +0,0 @@ public class WorldUpgrader {
private volatile int skipped;
private final Object2FloatMap<ResourceKey<DimensionType>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(Util.identityStrategy())); // CraftBukkit
private volatile Component status = new TranslatableComponent("optimizeWorld.stage.counting");
- private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); public static final Pattern getRegionfileRegex() { return REGEX; } // Paper - OBFHELPER
private final DimensionDataStorage overworldDataStorage;
public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, ImmutableSet<ResourceKey<DimensionType>> worlds, boolean eraseCache) { // CraftBukkit
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return typeKey; return this.typeKey;
} }
+ // Paper start - fix and optimise world upgrading + // Paper start - fix and optimise world upgrading
+ // copied from below + // copied from below
+ public static ResourceKey<DimensionType> getDimensionKey(DimensionType manager) { + public static ResourceKey<DimensionType> getDimensionKey(DimensionType manager) {
+ return ((org.bukkit.craftbukkit.CraftServer)org.bukkit.Bukkit.getServer()).getHandle().getServer().registryHolder.dimensionTypes().getResourceKey(manager).orElseThrow(() -> { + return ((org.bukkit.craftbukkit.CraftServer)org.bukkit.Bukkit.getServer()).getHandle().getServer().registryHolder.ownedRegistryOrThrow(net.minecraft.core.Registry.DIMENSION_TYPE_REGISTRY).getResourceKey(manager).orElseThrow(() -> {
+ return new IllegalStateException("Unregistered dimension type: " + manager); + return new IllegalStateException("Unregistered dimension type: " + manager);
+ }); + });
+ } + }
+ // Paper end - fix and optimise world upgrading + // Paper end - fix and optimise world upgrading
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) {
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), this.spigotConfig); // Paper this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), this.spigotConfig); // Paper
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable {
return nbttagcompound;
}
+ public static int getVersion(CompoundTag nbttagcompound) { return getVersion(nbttagcompound); } // Paper - OBFHELPER
public static int getVersion(CompoundTag tag) {
return tag.contains("DataVersion", 99) ? tag.getInt("DataVersion") : -1;
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { // Paper - no final @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { // Paper - no final
}
// Paper start // Paper start
+ public static ChunkPos getRegionFileCoordinates(File file) { + public static ChunkPos getRegionFileCoordinates(File file) {
@ -371,7 +345,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ +
public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // Paper - synchronize for async io public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) {
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ())); return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@ -381,7 +355,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public final class CraftServer implements Server { @@ -0,0 +0,0 @@ public final class CraftServer implements Server {
} }
worlddata.checkName(name); worlddata.checkName(name);
worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().isPresent()); worlddata.setModdedInfo(this.console.getServerModName(), this.console.getModdedStatus().isPresent());
- -
- if (console.options.has("forceUpgrade")) { - if (console.options.has("forceUpgrade")) {
- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache"), () -> { - net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache"), () -> {

View file

@ -33,14 +33,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/commands/GiveCommand.java --- a/src/main/java/net/minecraft/server/commands/GiveCommand.java
+++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java +++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java
@@ -0,0 +0,0 @@ public class GiveCommand { @@ -0,0 +0,0 @@ public class GiveCommand {
boolean bl = serverPlayer.getInventory().add(itemStack);
if (flag && itemstack.isEmpty()) { if (bl && itemStack.isEmpty()) {
itemstack.setCount(1); itemStack.setCount(1);
- entityitem = entityplayer.drop(itemstack, false); - ItemEntity itemEntity2 = serverPlayer.drop(itemStack, false);
+ entityitem = entityplayer.drop(itemstack, false, false, true); // Paper - Fix duplicating /give items on item drop cancel + ItemEntity itemEntity2 = serverPlayer.drop(itemStack, false, false, true); // Paper - Fix duplicating /give items on item drop cancel
if (entityitem != null) { if (itemEntity2 != null) {
entityitem.makeFakeItem(); itemEntity2.makeFakeItem();
} }
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
@ -49,39 +49,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable @Nullable
public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) { public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) {
- if (stack.isEmpty()) {
+ // Paper start - Fix duplicating /give items on item drop cancel + // Paper start - Fix duplicating /give items on item drop cancel
+ return this.drop(stack, throwRandomly, retainOwnership, false); + return this.drop(stack, throwRandomly, retainOwnership, false);
+ } + }
+ +
+ @Nullable + @Nullable
+ public ItemEntity drop(ItemStack itemstack, boolean flag, boolean flag1, boolean alwaysSucceed) { + public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, boolean alwaysSucceed) {
+ // Paper end + // Paper end
+ if (itemstack.isEmpty()) { if (stack.isEmpty()) {
return null; return null;
} else { } else {
if (this.level.isClientSide) {
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
}
double d0 = this.getEyeY() - 0.30000001192092896D;
- ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), stack);
+ ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), itemstack);
entityitem.setPickUpDelay(40);
- if (retainOwnership) {
+ if (flag1) {
entityitem.setThrower(this.getUUID());
}
float f;
float f1;
- if (throwRandomly) {
+ if (flag) {
f = this.random.nextFloat() * 0.5F;
f1 = this.random.nextFloat() * 6.2831855F;
entityitem.setDeltaMovement((double) (-Mth.sin(f1) * f), 0.20000000298023224D, (double) (Mth.cos(f1) * f));
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
this.level.getCraftServer().getPluginManager().callEvent(event); this.level.getCraftServer().getPluginManager().callEvent(event);
@ -89,25 +66,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (event.isCancelled()) { - if (event.isCancelled()) {
+ if (event.isCancelled() && !alwaysSucceed) { // Paper - Fix duplicating /give items on item drop cancel + if (event.isCancelled() && !alwaysSucceed) { // Paper - Fix duplicating /give items on item drop cancel
org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
- if (retainOwnership && (cur == null || cur.getAmount() == 0)) { if (retainOwnership && (cur == null || cur.getAmount() == 0)) {
+ if (flag1 && (cur == null || cur.getAmount() == 0)) {
// The complete stack was dropped // The complete stack was dropped
player.getInventory().setItemInHand(drop.getItemStack());
- } else if (retainOwnership && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
// Only one item is dropped
cur.setAmount(cur.getAmount() + 1);
player.getInventory().setItemInHand(cur);
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
}
// CraftBukkit end
// Paper start - remove player from map on drop
- if (stack.getItem() == Items.FILLED_MAP) {
- MapItemSavedData worldmap = MapItem.getOrCreateSavedData(stack, this.level);
- worldmap.updateSeenPlayers(this, stack);
+ if (itemstack.getItem() == Items.FILLED_MAP) {
+ MapItemSavedData worldmap = MapItem.getOrCreateSavedData(itemstack, this.level);
+ worldmap.updateSeenPlayers(this, itemstack);
}
// Paper end

View file

@ -4,19 +4,6 @@ Date: Thu, 6 May 2021 13:01:25 +0100
Subject: [PATCH] Have CraftMerchantCustom emit PlayerPurchaseEvent Subject: [PATCH] Have CraftMerchantCustom emit PlayerPurchaseEvent
diff --git a/src/main/java/net/minecraft/world/item/trading/Merchant.java b/src/main/java/net/minecraft/world/item/trading/Merchant.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/trading/Merchant.java
+++ b/src/main/java/net/minecraft/world/item/trading/Merchant.java
@@ -0,0 +0,0 @@ public interface Merchant {
MerchantOffers getOffers();
- void notifyTrade(MerchantOffer offer);
+ void notifyTrade(MerchantOffer offer); default void handlePurchase(MerchantOffer merchantRecipe) { notifyTrade(merchantRecipe); } // Paper - OBFHELPER
void notifyTradeUpdated(ItemStack stack);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java

View file

@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 6 Jan 2021 00:34:04 -0800
Subject: [PATCH] Implement Keyed on World
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
} else if (name.equals(levelName + "_the_end")) {
worldKey = net.minecraft.world.level.Level.END;
} else {
- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH)));
+ worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
}
ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, this.getServer().progressListenerFactory.create(11),
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
return null;
}
+ // Paper start
+ @Override
+ public World getWorld(NamespacedKey worldKey) {
+ ServerLevel worldServer = console.getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, CraftNamespacedKey.toMinecraft(worldKey)));
+ if (worldServer == null) return null;
+ return worldServer.getWorld();
+ }
+ // Paper end
+
public void addWorld(World world) {
// Check if a World already exists with the UID.
if (this.getWorld(world.getUID()) != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
return java.util.concurrent.CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
}, net.minecraft.server.MinecraftServer.getServer());
}
+
+ @Override
+ public org.bukkit.NamespacedKey getKey() {
+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().location());
+ }
// Paper end
// Spigot start

View file

@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)"); vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)");
vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb"); vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb");
vector.add("Avg tick: " + DECIMAL_FORMAT.format(getAverage(server.getTickTimes())) + " ms"); vector.add("Avg tick: " + DECIMAL_FORMAT.format(getAverage(server.tickTimes)) + " ms");
+ vector.add("TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg)); + vector.add("TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg));
+ +
setListData(vector); setListData(vector);
@ -34,8 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return ((double) total / (double) tickTimes.length) * 1.0E-6D; return ((double) total / (double) tickTimes.length) * 1.0E-6D;
} }
+ +
+ private static String format(double tps) + private static String format(double tps) {
+ {
+ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); + return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
+ } + }
} }
@ -76,18 +75,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/gui/StatsComponent.java --- a/src/main/java/net/minecraft/server/gui/StatsComponent.java
+++ b/src/main/java/net/minecraft/server/gui/StatsComponent.java +++ b/src/main/java/net/minecraft/server/gui/StatsComponent.java
@@ -0,0 +0,0 @@ public class StatsComponent extends JComponent { @@ -0,0 +0,0 @@ public class StatsComponent extends JComponent {
});
private final int[] values = new int[256];
private int vp;
- private final String[] msgs = new String[11];
+ private final String[] msgs = new String[12]; public String[] getStatEntries() { return this.msgs; } // Paper - change size, OBFHELPER
private final MinecraftServer server;
private final Timer timer;
@@ -0,0 +0,0 @@ public class StatsComponent extends JComponent {
private void tick() { private void tick() {
long i = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+ // Paper start - Add tps entry + // Paper start - Add tps entry
+ double[] tps = org.bukkit.Bukkit.getTPS(); + double[] tps = org.bukkit.Bukkit.getTPS();
+ String[] tpsAvg = new String[tps.length]; + String[] tpsAvg = new String[tps.length];
@ -95,12 +85,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ for ( int g = 0; g < tps.length; g++) { + for ( int g = 0; g < tps.length; g++) {
+ tpsAvg[g] = format( tps[g] ); + tpsAvg[g] = format( tps[g] );
+ } + }
this.msgs[0] = "Memory use: " + i / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)";
this.msgs[1] = "Avg tick: " + StatsComponent.DECIMAL_FORMAT.format(this.getAverage(this.server.tickTimes) * 1.0E-6D) + " ms"; this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format(this.getAverage(this.server.tickTimes) * 1.0E-6D) + " ms";
+ getStatEntries()[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg); + this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg);
+ // Paper end + // Paper end
+ this.values[this.vp++ & 255] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
this.values[this.vp++ & 255] = (int) (i * 100L / Runtime.getRuntime().maxMemory());
this.repaint(); this.repaint();
} }
@@ -0,0 +0,0 @@ public class StatsComponent extends JComponent { @@ -0,0 +0,0 @@ public class StatsComponent extends JComponent {
@ -110,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ // Paper - start Add tps entry + // Paper - start Add tps entry
+ private static String format(double tps) { + private static String format(double tps) {
+ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise + return (( tps > 21.0 ) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
+ } + }
+ // Paper end + // Paper end
} }

Some files were not shown because too many files have changed in this diff Show more