Update to Minecraft 1.20

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-06-08 01:30:00 +10:00
parent bac55e67d6
commit 9d740b84b0
269 changed files with 2605 additions and 2568 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandDifficulty.java
+++ b/net/minecraft/server/commands/CommandDifficulty.java
@@ -42,11 +42,12 @@
@@ -44,11 +44,12 @@
public static int setDifficulty(CommandListenerWrapper commandlistenerwrapper, EnumDifficulty enumdifficulty) throws CommandSyntaxException {
MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
@@ -12,6 +12,6 @@
} else {
- minecraftserver.setDifficulty(enumdifficulty, true);
+ worldServer.serverLevelData.setDifficulty(enumdifficulty); // CraftBukkit
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.difficulty.success", enumdifficulty.getDisplayName()), true);
return 0;
}
commandlistenerwrapper.sendSuccess(() -> {
return IChatBaseComponent.translatable("commands.difficulty.success", enumdifficulty.getDisplayName());
}, true);

View File

@@ -9,7 +9,7 @@
++j;
}
}
@@ -110,7 +110,7 @@
@@ -114,7 +114,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -18,7 +18,7 @@
++i;
}
}
@@ -136,7 +136,7 @@
@@ -144,7 +144,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();

View File

@@ -8,13 +8,13 @@
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
t0.setFromArgument(commandcontext, "value");
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.gamerule.set", gamerules_gamerulekey.getId(), t0.toString()), true);
@@ -39,7 +39,7 @@
commandlistenerwrapper.sendSuccess(() -> {
@@ -41,7 +41,7 @@
}
static <T extends GameRules.GameRuleValue<T>> int queryRule(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey);
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.gamerule.query", gamerules_gamerulekey.getId(), t0.toString()), false);
return t0.getCommandResult();
commandlistenerwrapper.sendSuccess(() -> {
return IChatBaseComponent.translatable("commands.gamerule.query", gamerules_gamerulekey.getId(), t0.toString());

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/server/commands/CommandGive.java
+++ b/net/minecraft/server/commands/CommandGive.java
@@ -60,7 +60,7 @@
@@ -61,7 +61,7 @@
if (flag && itemstack.isEmpty()) {
itemstack.setCount(1);
- entityitem = entityplayer.drop(itemstack, false);
+ entityitem = entityplayer.drop(itemstack, false, false, false); // SPIGOT-2942: Add boolean to call event
if (flag && itemstack1.isEmpty()) {
itemstack1.setCount(1);
- entityitem = entityplayer.drop(itemstack1, false);
+ entityitem = entityplayer.drop(itemstack1, false, false, false); // SPIGOT-2942: Add boolean to call event
if (entityitem != null) {
entityitem.makeFakeItem();
}

View File

@@ -1,15 +1,18 @@
--- a/net/minecraft/server/commands/CommandList.java
+++ b/net/minecraft/server/commands/CommandList.java
@@ -36,6 +36,12 @@
@@ -35,7 +35,14 @@
private static int format(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) {
PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList();
List<EntityPlayer> list = playerlist.getPlayers();
- List<EntityPlayer> list = playerlist.getPlayers();
+ // CraftBukkit start
+ List<EntityPlayer> players = playerlist.getPlayers();
+ if (commandlistenerwrapper.getBukkitSender() instanceof org.bukkit.entity.Player) {
+ org.bukkit.entity.Player sender = (org.bukkit.entity.Player) commandlistenerwrapper.getBukkitSender();
+ list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList());
+ players = players.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList());
+ }
+ List<EntityPlayer> list = players;
+ // CraftBukkit end
IChatBaseComponent ichatbasecomponent = ChatComponentUtils.formatList(list, function);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), ichatbasecomponent), false);
commandlistenerwrapper.sendSuccess(() -> {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandSpreadPlayers.java
+++ b/net/minecraft/server/commands/CommandSpreadPlayers.java
@@ -90,7 +90,7 @@
@@ -92,7 +92,7 @@
if (entity instanceof EntityHuman) {
set.add(entity.getTeam());
} else {
@@ -9,7 +9,7 @@
}
}
@@ -200,7 +200,7 @@
@@ -202,7 +202,7 @@
commandspreadplayers_a = acommandspreadplayers_a[j++];
}
@@ -18,7 +18,7 @@
d1 = Double.MAX_VALUE;
CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a;
int k = acommandspreadplayers_a.length;
@@ -299,7 +299,7 @@
@@ -301,7 +301,7 @@
for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) {
blockposition_mutableblockposition.move(EnumDirection.DOWN);
@@ -27,16 +27,16 @@
if (!flag1 && flag2 && flag) {
return blockposition_mutableblockposition.getY() + 1;
}
@@ -312,7 +312,7 @@
@@ -314,7 +314,7 @@
public boolean isSafe(IBlockAccess iblockaccess, int i) {
BlockPosition blockposition = BlockPosition.containing(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z);
- IBlockData iblockdata = iblockaccess.getBlockState(blockposition);
+ IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit
Material material = iblockdata.getMaterial();
return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE;
@@ -322,5 +322,12 @@
return blockposition.getY() < i && !iblockdata.liquid() && !iblockdata.is(TagsBlock.FIRE);
}
@@ -323,5 +323,12 @@
this.x = MathHelper.nextDouble(randomsource, d0, d2);
this.z = MathHelper.nextDouble(randomsource, d1, d3);
}

View File

@@ -14,7 +14,7 @@
public class CommandTeleport {
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition"));
@@ -147,7 +154,30 @@
@@ -155,7 +162,30 @@
float f2 = MathHelper.wrapDegrees(f);
float f3 = MathHelper.wrapDegrees(f1);

View File

@@ -12,7 +12,7 @@
public class CommandTime {
public CommandTime() {}
@@ -47,12 +52,18 @@
@@ -49,12 +54,18 @@
}
public static int setTime(CommandListenerWrapper commandlistenerwrapper, int i) {
@@ -32,8 +32,8 @@
+ // CraftBukkit end
}
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.time.set", i), true);
@@ -60,12 +71,18 @@
commandlistenerwrapper.sendSuccess(() -> {
@@ -64,12 +75,18 @@
}
public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandTrigger.java
+++ b/net/minecraft/server/commands/CommandTrigger.java
@@ -90,7 +90,7 @@
@@ -96,7 +96,7 @@
if (scoreboardobjective.getCriteria() != IScoreboardCriteria.TRIGGER) {
throw CommandTrigger.ERROR_INVALID_OBJECTIVE.create();
} else {

View File

@@ -9,7 +9,7 @@
if (worldborder.getDamageSafeZone() == (double) f) {
throw CommandWorldBorder.ERROR_SAME_DAMAGE_BUFFER.create();
@@ -69,7 +69,7 @@
@@ -71,7 +71,7 @@
}
private static int setDamageAmount(CommandListenerWrapper commandlistenerwrapper, float f) throws CommandSyntaxException {
@@ -18,7 +18,7 @@
if (worldborder.getDamagePerBlock() == (double) f) {
throw CommandWorldBorder.ERROR_SAME_DAMAGE_AMOUNT.create();
@@ -81,7 +81,7 @@
@@ -85,7 +85,7 @@
}
private static int setWarningTime(CommandListenerWrapper commandlistenerwrapper, int i) throws CommandSyntaxException {
@@ -27,7 +27,7 @@
if (worldborder.getWarningTime() == i) {
throw CommandWorldBorder.ERROR_SAME_WARNING_TIME.create();
@@ -93,7 +93,7 @@
@@ -99,7 +99,7 @@
}
private static int setWarningDistance(CommandListenerWrapper commandlistenerwrapper, int i) throws CommandSyntaxException {
@@ -36,15 +36,16 @@
if (worldborder.getWarningBlocks() == i) {
throw CommandWorldBorder.ERROR_SAME_WARNING_DISTANCE.create();
@@ -105,14 +105,14 @@
@@ -113,7 +113,7 @@
}
private static int getSize(CommandListenerWrapper commandlistenerwrapper) {
- double d0 = commandlistenerwrapper.getServer().overworld().getWorldBorder().getSize();
+ double d0 = commandlistenerwrapper.getLevel().getWorldBorder().getSize(); // CraftBukkit
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0)), false);
return MathHelper.floor(d0 + 0.5D);
commandlistenerwrapper.sendSuccess(() -> {
return IChatBaseComponent.translatable("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0));
@@ -122,7 +122,7 @@
}
private static int setCenter(CommandListenerWrapper commandlistenerwrapper, Vec2F vec2f) throws CommandSyntaxException {
@@ -53,7 +54,7 @@
if (worldborder.getCenterX() == (double) vec2f.x && worldborder.getCenterZ() == (double) vec2f.y) {
throw CommandWorldBorder.ERROR_SAME_CENTER.create();
@@ -126,7 +126,7 @@
@@ -138,7 +138,7 @@
}
private static int setSize(CommandListenerWrapper commandlistenerwrapper, double d0, long i) throws CommandSyntaxException {