mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
bunch of fixes and improvements
This commit is contained in:
parent
77e87218b9
commit
cafa0f3267
@ -28,22 +28,6 @@ diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/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 static final int LEVEL_ADMINS = 3;
|
||||
public static final int LEVEL_OWNERS = 4;
|
||||
private final com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher = new com.mojang.brigadier.CommandDispatcher();
|
||||
+ public final java.util.List<CommandNode<CommandSourceStack>> vanillaCommandNodes = new java.util.ArrayList<>(); // Paper - Add UnknownCommandEvent
|
||||
|
||||
public Commands(Commands.CommandSelection environment, CommandBuildContext commandRegistryAccess) {
|
||||
this(); // CraftBukkit
|
||||
@@ -0,0 +0,0 @@ public class Commands {
|
||||
if (environment.includeIntegrated) {
|
||||
PublishCommand.register(this.dispatcher);
|
||||
}
|
||||
+ this.vanillaCommandNodes.addAll(this.dispatcher.getRoot().getChildren()); // Paper - Add UnknownCommandEvent
|
||||
|
||||
// CraftBukkit start
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class Commands {
|
||||
commandlistenerwrapper.getServer().getProfiler().push(() -> {
|
||||
return "/" + s;
|
||||
@ -68,14 +52,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- commandlistenerwrapper.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage()));
|
||||
+ // Paper start - Add UnknownCommandEvent
|
||||
+ final net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text();
|
||||
+ if ((parseresults.getContext().getNodes().isEmpty() || !this.vanillaCommandNodes.contains(parseresults.getContext().getNodes().get(0).getNode()))) {
|
||||
+ if (!org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty()) {
|
||||
+ builder.append(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.unknownCommandMessage));
|
||||
+ }
|
||||
+ } else {
|
||||
+ // commandlistenerwrapper.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage()));
|
||||
+ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.brigadier.PaperBrigadier.componentFromMessage(commandsyntaxexception.getRawMessage()));
|
||||
+ // Paper end - Add UnknownCommandEvent
|
||||
+ // commandlistenerwrapper.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage()));
|
||||
+ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.brigadier.PaperBrigadier.componentFromMessage(commandsyntaxexception.getRawMessage()));
|
||||
+ // Paper end - Add UnknownCommandEvent
|
||||
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
|
||||
int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
|
||||
MutableComponent ichatmutablecomponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((chatmodifier) -> {
|
||||
@ -90,7 +69,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ .append(net.kyori.adventure.text.Component.newline())
|
||||
+ .append(io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent));
|
||||
+ }
|
||||
+ }
|
||||
+ org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(commandlistenerwrapper.getBukkitSender(), s, org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty() ? null : builder.build());
|
||||
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.message() != null) {
|
||||
@ -103,14 +81,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/ja
|
||||
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 {
|
||||
}
|
||||
node = clone;
|
||||
}
|
||||
+ dispatcher.vanillaCommandNodes.add(node); // Paper
|
||||
|
||||
dispatcher.getDispatcher().getRoot().addChild(node);
|
||||
} else {
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
|
||||
// Spigot start
|
||||
|
218
patches/server/Add-experimental-improved-give-command.patch
Normal file
218
patches/server/Add-experimental-improved-give-command.patch
Normal file
@ -0,0 +1,218 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 26 Apr 2024 23:15:27 -0700
|
||||
Subject: [PATCH] Add experimental improved give command
|
||||
|
||||
Supports removing data components from itemstacks
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/item/ItemArgument.java b/src/main/java/net/minecraft/commands/arguments/item/ItemArgument.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/item/ItemArgument.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/item/ItemArgument.java
|
||||
@@ -0,0 +0,0 @@ public class ItemArgument implements ArgumentType<ItemInput> {
|
||||
private final ItemParser parser;
|
||||
|
||||
public ItemArgument(CommandBuildContext commandRegistryAccess) {
|
||||
- this.parser = new ItemParser(commandRegistryAccess);
|
||||
+ // Paper start - support component removals
|
||||
+ this(commandRegistryAccess, false);
|
||||
+ }
|
||||
+ public ItemArgument(CommandBuildContext commandRegistryAccess, boolean allowRemovals) {
|
||||
+ this.parser = new ItemParser(commandRegistryAccess, allowRemovals);
|
||||
+ // Paper end - support component removals
|
||||
}
|
||||
|
||||
public static ItemArgument item(CommandBuildContext commandRegistryAccess) {
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java b/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
@@ -0,0 +0,0 @@ public class ItemInput {
|
||||
);
|
||||
private final Holder<Item> item;
|
||||
private final DataComponentMap components;
|
||||
+ @javax.annotation.Nullable private final net.minecraft.core.component.DataComponentPatch patch; // Paper
|
||||
|
||||
public ItemInput(Holder<Item> item, DataComponentMap components) {
|
||||
+ // Paper start
|
||||
+ this(item, components, null);
|
||||
+ }
|
||||
+ public ItemInput(Holder<Item> item, DataComponentMap components, @javax.annotation.Nullable final net.minecraft.core.component.DataComponentPatch patch) {
|
||||
+ this.patch = patch;
|
||||
+ // Paper end
|
||||
this.item = item;
|
||||
this.components = components;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ItemInput {
|
||||
|
||||
public ItemStack createItemStack(int amount, boolean checkOverstack) throws CommandSyntaxException {
|
||||
ItemStack itemStack = new ItemStack(this.item, amount);
|
||||
- itemStack.applyComponents(this.components);
|
||||
+ // Paper start - support component removals
|
||||
+ if (this.patch != null) {
|
||||
+ itemStack.applyComponents(this.patch);
|
||||
+ } else {
|
||||
+ itemStack.applyComponents(this.components);
|
||||
+ }
|
||||
+ // Paper end - support component removals
|
||||
if (checkOverstack && amount > itemStack.getMaxStackSize()) {
|
||||
throw ERROR_STACK_TOO_BIG.create(this.getItemName(), itemStack.getMaxStackSize());
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/item/ItemParser.java b/src/main/java/net/minecraft/commands/arguments/item/ItemParser.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/item/ItemParser.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/item/ItemParser.java
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
static final Function<SuggestionsBuilder, CompletableFuture<Suggestions>> SUGGEST_NOTHING = SuggestionsBuilder::buildFuture;
|
||||
final HolderLookup.RegistryLookup<Item> items;
|
||||
final DynamicOps<Tag> registryOps;
|
||||
+ final boolean allowRemoves; // Paper - support component removals
|
||||
|
||||
public ItemParser(HolderLookup.Provider registriesLookup) {
|
||||
+ // Paper start - support component removals
|
||||
+ this(registriesLookup, false);
|
||||
+ }
|
||||
+ public ItemParser(HolderLookup.Provider registriesLookup, boolean allowRemoves) {
|
||||
+ this.allowRemoves = allowRemoves;
|
||||
+ // Paper end - support component removals
|
||||
this.items = registriesLookup.lookupOrThrow(Registries.ITEM);
|
||||
this.registryOps = registriesLookup.createSerializationContext(NbtOps.INSTANCE);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
public ItemParser.ItemResult parse(StringReader reader) throws CommandSyntaxException {
|
||||
final MutableObject<Holder<Item>> mutableObject = new MutableObject<>();
|
||||
final DataComponentMap.Builder builder = DataComponentMap.builder();
|
||||
+ final net.minecraft.core.component.DataComponentPatch.Builder patchBuilder = net.minecraft.core.component.DataComponentPatch.builder(); // Paper - support component removals
|
||||
this.parse(reader, new ItemParser.Visitor() {
|
||||
@Override
|
||||
public void visitItem(Holder<Item> item) {
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
@Override
|
||||
public <T> void visitComponent(DataComponentType<T> type, T value) {
|
||||
builder.set(type, value);
|
||||
+ // Paper start - support component removals
|
||||
+ patchBuilder.set(type, value);
|
||||
+ }
|
||||
+ @Override
|
||||
+ public <T> void visitComponentRemove(final DataComponentType<T> type) {
|
||||
+ patchBuilder.remove(type);
|
||||
+ // Paper end - support component removals
|
||||
}
|
||||
});
|
||||
Holder<Item> holder = Objects.requireNonNull(mutableObject.getValue(), "Parser gave no item");
|
||||
DataComponentMap dataComponentMap = builder.build();
|
||||
validateComponents(reader, holder, dataComponentMap);
|
||||
- return new ItemParser.ItemResult(holder, dataComponentMap);
|
||||
+ return new ItemParser.ItemResult(holder, dataComponentMap, this.allowRemoves ? patchBuilder.build() : null); // Paper - support component removals
|
||||
}
|
||||
|
||||
private static void validateComponents(StringReader reader, Holder<Item> item, DataComponentMap components) throws CommandSyntaxException {
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
return suggestionsVisitor.resolveSuggestions(builder, stringReader);
|
||||
}
|
||||
|
||||
- public static record ItemResult(Holder<Item> item, DataComponentMap components) {
|
||||
+ public static record ItemResult(Holder<Item> item, DataComponentMap components, @javax.annotation.Nullable net.minecraft.core.component.DataComponentPatch patch) { // Paper
|
||||
}
|
||||
|
||||
class State {
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
|
||||
while (this.reader.canRead() && this.reader.peek() != ']') {
|
||||
this.reader.skipWhitespace();
|
||||
+ boolean removing = ItemParser.this.allowRemoves && this.reader.canRead() && this.reader.peek() == '!';
|
||||
+ if (removing) {
|
||||
+ this.reader.skip();
|
||||
+ this.visitor.visitSuggestions(builder -> this.suggestComponentAssignment(builder, false));
|
||||
+ }
|
||||
DataComponentType<?> dataComponentType = readComponentType(this.reader);
|
||||
if (!set.add(dataComponentType)) {
|
||||
throw ItemParser.ERROR_REPEATED_COMPONENT.create(dataComponentType);
|
||||
}
|
||||
|
||||
+ // Paper start - support component removals
|
||||
+ if (removing) {
|
||||
+ this.visitor.visitComponentRemove(dataComponentType);
|
||||
+ } else {
|
||||
+ // Paper end - support component removals
|
||||
this.visitor.visitSuggestions(this::suggestAssignment);
|
||||
this.reader.skipWhitespace();
|
||||
this.reader.expect('=');
|
||||
this.visitor.visitSuggestions(ItemParser.SUGGEST_NOTHING);
|
||||
this.reader.skipWhitespace();
|
||||
this.readComponent(dataComponentType);
|
||||
+ } // Paper - support component removals
|
||||
this.reader.skipWhitespace();
|
||||
this.visitor.visitSuggestions(this::suggestNextOrEndComponents);
|
||||
if (!this.reader.canRead() || this.reader.peek() != ',') {
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
}
|
||||
|
||||
private CompletableFuture<Suggestions> suggestComponentAssignment(SuggestionsBuilder builder) {
|
||||
+ // Paper start - support component removals
|
||||
+ return this.suggestComponentAssignment(builder, true);
|
||||
+ }
|
||||
+ private CompletableFuture<Suggestions> suggestComponentAssignment(SuggestionsBuilder builder, boolean suggestRemove) {
|
||||
+ if (suggestRemove) builder.suggest("!", Component.literal("Remove a data component"));
|
||||
+ // Paper end - support component removals
|
||||
String string = builder.getRemaining().toLowerCase(Locale.ROOT);
|
||||
SharedSuggestionProvider.filterResources(BuiltInRegistries.DATA_COMPONENT_TYPE.entrySet(), string, entry -> entry.getKey().location(), entry -> {
|
||||
DataComponentType<?> dataComponentType = entry.getValue();
|
||||
if (dataComponentType.codec() != null) {
|
||||
ResourceLocation resourceLocation = entry.getKey().location();
|
||||
- builder.suggest(resourceLocation.toString() + "=");
|
||||
+ builder.suggest(resourceLocation.toString() + (suggestRemove ? "=" : "")); // Paper - support component removals
|
||||
}
|
||||
});
|
||||
return builder.buildFuture();
|
||||
@@ -0,0 +0,0 @@ public class ItemParser {
|
||||
|
||||
default <T> void visitComponent(DataComponentType<T> type, T value) {
|
||||
}
|
||||
+ default <T> void visitComponentRemove(DataComponentType<T> type) {} // Paper
|
||||
|
||||
default void visitSuggestions(Function<SuggestionsBuilder, CompletableFuture<Suggestions>> suggestor) {
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/GiveCommand.java b/src/main/java/net/minecraft/server/commands/GiveCommand.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/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 {
|
||||
})).then(net.minecraft.commands.Commands.argument("count", IntegerArgumentType.integer(1)).executes((commandcontext) -> {
|
||||
return GiveCommand.giveItem((CommandSourceStack) commandcontext.getSource(), ItemArgument.getItem(commandcontext, "item"), EntityArgument.getPlayers(commandcontext, "targets"), IntegerArgumentType.getInteger(commandcontext, "count"));
|
||||
})))));
|
||||
+ // Paper start - support component removals with a custom pgive command
|
||||
+ final com.mojang.brigadier.tree.CommandNode<net.minecraft.commands.CommandSourceStack> node = net.minecraft.commands.Commands
|
||||
+ .literal("pgive").requires((commandlistenerwrapper) -> commandlistenerwrapper.hasPermission(2))
|
||||
+ .then(net.minecraft.commands.Commands.argument("targets", EntityArgument.players())
|
||||
+ .then(net.minecraft.commands.Commands.argument("item", new ItemArgument(commandRegistryAccess, true)).executes((commandcontext) -> {
|
||||
+ return GiveCommand.giveItem((CommandSourceStack) commandcontext.getSource(), ItemArgument.getItem(commandcontext, "item"), EntityArgument.getPlayers(commandcontext, "targets"), 1);
|
||||
+ })
|
||||
+ .then(net.minecraft.commands.Commands.argument("count", IntegerArgumentType.integer(1)).executes((commandcontext) -> {
|
||||
+ return GiveCommand.giveItem((CommandSourceStack) commandcontext.getSource(), ItemArgument.getItem(commandcontext, "item"), EntityArgument.getPlayers(commandcontext, "targets"), IntegerArgumentType.getInteger(commandcontext, "count"));
|
||||
+ }))
|
||||
+ )
|
||||
+ ).build();
|
||||
+ setClientNodes(node);
|
||||
+ dispatcher.getRoot().addChild(node);
|
||||
+ }
|
||||
+ static void setClientNodes(com.mojang.brigadier.tree.CommandNode<net.minecraft.commands.CommandSourceStack> node) {
|
||||
+ if (node instanceof com.mojang.brigadier.tree.ArgumentCommandNode<net.minecraft.commands.CommandSourceStack,?> argumentNode) {
|
||||
+ if (argumentNode.getType() instanceof ItemArgument) {
|
||||
+ node.clientNode = new com.mojang.brigadier.tree.ArgumentCommandNode<>(
|
||||
+ argumentNode.getName(),
|
||||
+ com.mojang.brigadier.arguments.StringArgumentType.greedyString(),
|
||||
+ argumentNode.getCommand(),
|
||||
+ argumentNode.getRequirement(),
|
||||
+ argumentNode.getRedirect(),
|
||||
+ argumentNode.getRedirectModifier(),
|
||||
+ argumentNode.isFork(),
|
||||
+ (ctx, builder) -> builder.buildFuture()
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+ node.getChildren().forEach(GiveCommand::setClientNodes);
|
||||
+ // Paper end - support component removals with a custom pgive command
|
||||
}
|
||||
|
||||
private static int giveItem(CommandSourceStack source, ItemInput item, Collection<ServerPlayer> targets, int count) throws CommandSyntaxException {
|
@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private final RedirectModifier<S> modifier;
|
||||
private final boolean forks;
|
||||
private Command<S> command;
|
||||
+ public LiteralCommandNode<CommandSourceStack> clientNode; // Paper - Brigadier API
|
||||
+ public CommandNode<CommandSourceStack> clientNode; // Paper - Brigadier API
|
||||
// CraftBukkit start
|
||||
public void removeCommand(String name) {
|
||||
this.children.remove(name);
|
||||
|
@ -0,0 +1,47 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 26 Apr 2024 21:33:20 -0700
|
||||
Subject: [PATCH] Don't lose removed data components in ItemMeta
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
return this;
|
||||
}
|
||||
|
||||
+ // Paper start - support removing component types
|
||||
+ <T> Applicator remove(DataComponentType<T> type) {
|
||||
+ this.builder.remove(type);
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Paper end - support removing component types
|
||||
+
|
||||
DataComponentPatch build() {
|
||||
return this.builder.build();
|
||||
}
|
||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
|
||||
Set<Map.Entry<DataComponentType<?>, Optional<?>>> keys = tag.entrySet();
|
||||
for (Map.Entry<DataComponentType<?>, Optional<?>> key : keys) {
|
||||
- if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
||||
+ if (key.getValue().isEmpty()) {
|
||||
+ this.unhandledTags.remove(key.getKey());
|
||||
+ } else if (!CraftMetaItem.getHandledTags().contains(key.getKey())) {
|
||||
key.getValue().ifPresentOrElse((value) -> {
|
||||
this.unhandledTags.set((DataComponentType) key.getKey(), value);
|
||||
}, () -> {
|
||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
}
|
||||
|
||||
for (Map.Entry<DataComponentType<?>, Optional<?>> e : this.unhandledTags.build().entrySet()) {
|
||||
- e.getValue().ifPresent((value) -> {
|
||||
+ e.getValue().ifPresentOrElse((value) -> {
|
||||
itemTag.builder.set((DataComponentType) e.getKey(), value);
|
||||
- });
|
||||
+ }, () -> itemTag.remove(e.getKey()));
|
||||
}
|
||||
|
||||
if (!this.persistentDataContainer.isEmpty()) {
|
@ -4,6 +4,18 @@ Date: Wed, 30 Mar 2016 19:36:20 -0400
|
||||
Subject: [PATCH] MC Dev fixes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java b/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
@@ -0,0 +0,0 @@ public class ItemInput {
|
||||
}
|
||||
|
||||
private String getItemName() {
|
||||
- return this.item.unwrapKey().map(ResourceKey::location).orElseGet(() -> "unknown[" + this.item + "]").toString();
|
||||
+ return this.item.unwrapKey().<Object>map(ResourceKey::location).orElseGet(() -> "unknown[" + this.item + "]").toString(); // Paper - decompile fix
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
|
@ -22,28 +22,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
@Override
|
||||
@@ -0,0 +0,0 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
|
||||
// Paper start
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component displayName(int level) {
|
||||
- return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getFullname(level));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translationKey() {
|
||||
return this.handle.getDescriptionId();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isTradeable() {
|
||||
+ return handle.isTradeable();
|
||||
+ return this.handle.isTradeable();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isDiscoverable() {
|
||||
+ return handle.isDiscoverable();
|
||||
+ return this.handle.isDiscoverable();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMinModifiedCost(int level) {
|
||||
+ return handle.getMinCost(level);
|
||||
+ return this.handle.getMinCost(level);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxModifiedCost(int level) {
|
||||
+ return handle.getMaxCost(level);
|
||||
+ return this.handle.getMaxCost(level);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -53,12 +61,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityCategory entityCategory) {
|
||||
+ return handle.getDamageBonus(level, guessEntityTypeFromEnchantmentCategory(entityCategory));
|
||||
+ return this.handle.getDamageBonus(level, this.guessEntityTypeFromEnchantmentCategory(entityCategory));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityType entityType) {
|
||||
+ return handle.getDamageBonus(level, org.bukkit.craftbukkit.util.CraftMagicNumbers.getEntityTypes(entityType));
|
||||
+ return this.handle.getDamageBonus(level, org.bukkit.craftbukkit.util.CraftMagicNumbers.getEntityTypes(entityType));
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated(forRemoval = true)
|
||||
@ -80,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public java.util.Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots() {
|
||||
+ return java.util.stream.Stream.of(handle.definition.slots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
|
||||
+ return java.util.stream.Stream.of(this.handle.definition.slots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
|
@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
|
||||
+ protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, @javax.annotation.Nullable net.minecraft.world.item.context.UseOnContext context) {
|
||||
+ // Paper end - UseOnContext param
|
||||
if (!oldState.is(state.getBlock())) {
|
||||
if (BaseFireBlock.inPortalDimension(world)) {
|
||||
@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return this.createPortalBlocks(null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean createPortalBlocks(net.minecraft.world.item.context.UseOnContext useOnContext) {
|
||||
+ public boolean createPortalBlocks(@Nullable net.minecraft.world.item.context.UseOnContext useOnContext) {
|
||||
+ // Paper end - UseOnContext param
|
||||
org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld();
|
||||
|
||||
|
@ -30,8 +30,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
if (this.customTag != null) {
|
||||
itemTag.put(CraftMetaItem.CUSTOM_DATA, CustomData.of(this.customTag));
|
||||
+ this.customTag.remove(CraftMetaItem.BUKKIT_CUSTOM_TAG.BUKKIT);
|
||||
+ if (this.customTag.isEmpty()) this.customTag = null;
|
||||
+ this.customTag.remove(CraftMetaItem.BUKKIT_CUSTOM_TAG.BUKKIT); // Paper - remove PDC from custom tag
|
||||
+ if (this.customTag.isEmpty()) this.customTag = null; // Paper - reset custom tag if empty
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- 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 {
|
||||
PublishCommand.register(this.dispatcher);
|
||||
}
|
||||
this.vanillaCommandNodes.addAll(this.dispatcher.getRoot().getChildren()); // Paper - Add UnknownCommandEvent
|
||||
|
||||
+ // Paper start - Vanilla command permission fixes
|
||||
+ for (final CommandNode<CommandSourceStack> node : this.dispatcher.getRoot().getChildren()) {
|
||||
|
Loading…
Reference in New Issue
Block a user