more patches (#5827)

* more patches

* even moar patches
This commit is contained in:
Jake Potrebic 2021-06-14 01:37:14 -07:00 committed by GitHub
parent 405ab6388e
commit 7fe98bd520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 369 additions and 463 deletions

View File

@ -24,6 +24,8 @@ Massive update to light to improve performance and chunk loading/generation.
7) Buffer non urgent tasks even if queueUpdate is called multiple times to improve efficiency.
8) Fix NPE risk that crashes server in getting nibble data
1.17: Depends on chunk urgency patch as well
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 8260636da673ef095728c208db2d6237bab2db19..9e3629884709126574a52ad44fe7523f01dbcce9 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java

View File

@ -6,6 +6,8 @@ Subject: [PATCH] Fix enderdragon exp dupe
Properly track death stage when unloading/loading in the
dragon
1.17: Mojang fixed in 1.17(maybe before, idk)
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
index ec9436005a3a6fdfb4783d1092bb361224eb6414..b224a630f8adb1fa357c838e6b32c784aed0b15b 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java

View File

@ -3,6 +3,7 @@ From: Trigary <trigary0@gmail.com>
Date: Fri, 14 Sep 2018 17:42:08 +0200
Subject: [PATCH] Limit lightning strike effect distance
Doesnt seem to apply anymore as spigot isn't using relative distance for lightning
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 1655bca0502e7b871de4addaa163536d86547a02..978062774c1db286bfb9b0ffdef19d880b1f249b 100644

View File

@ -1,36 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nesaak <52047222+Nesaak@users.noreply.github.com>
Date: Sat, 23 May 2020 10:31:11 -0400
Subject: [PATCH] Expose Arrow getItemStack
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
index 3ce431c1fdf1f5bd62b49f26cca188e939e98efa..6225f390b51733217a809910182f58acea1055e2 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -556,6 +556,7 @@ public abstract class AbstractArrow extends Projectile {
}
}
+ public final ItemStack getOriginalItemStack() { return getPickupItem(); } // Paper - OBFHELPER - exists purely due to overrides all as protected and dont want to change them all
protected abstract ItemStack getPickupItem();
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
index 5b898118a46007a85254931c7b5bd18d7cda99be..91d32aff07e81608a2f8ecb1301ef3c08533494b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
@@ -102,6 +102,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
getHandle().pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.byOrdinal(status.ordinal());
}
+ // Paper start
+ @Override
+ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() {
+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(getHandle().getOriginalItemStack());
+ }
+ //Paper end
+
@Override
public void setTicksLived(int value) {
super.setTicksLived(value);

View File

@ -1,48 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 10 May 2020 22:12:46 -0400
Subject: [PATCH] Ensure Entity AABB's are never invalid
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d9bb00752ac81b2171d3ad25fd84904467a18e3b..728379292728cf58f5512feae3cdc74392980f68 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -66,6 +66,7 @@ import net.minecraft.world.Nameable;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.animal.AbstractFish;
import net.minecraft.world.entity.animal.Animal;
+import net.minecraft.world.entity.decoration.HangingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
@@ -478,7 +479,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
public void setPos(double x, double y, double z) {
this.setPosRaw(x, y, z);
- this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, z));
+ //this.a(this.size.a(d0, d1, d2)); // Paper - move into setPositionRaw
if (valid) ((ServerLevel) level).updateChunkPos(this); // CraftBukkit
}
@@ -2998,6 +2999,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
return new AABB(vec3d, vec3d1);
}
+ public final void setBoundingBox(AABB axisalignedbb) { setBoundingBox(axisalignedbb); } // Paper - OBFHELPER
public void setBoundingBox(AABB boundingBox) {
// CraftBukkit start - block invalid bounding boxes
double minX = boundingBox.minX,
@@ -3436,6 +3438,12 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
public void setPosRaw(double x, double y, double z) {
+ // Paper start - never allow AABB to become desynced from position
+ // hanging has its own special logic
+ if (!(this instanceof HangingEntity) && (this.position.x != x || this.position.y != y || this.position.z != z)) {
+ this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, z));
+ }
+ // Paper end
if (this.position.x != x || this.position.y != y || this.position.z != z) {
this.position = new Vec3(x, y, z);
int i = Mth.floor(x);

View File

@ -1,71 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sun, 10 May 2020 22:49:05 -0400
Subject: [PATCH] Optimize WorldBorder collision checks and air
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 728379292728cf58f5512feae3cdc74392980f68..e9a658b11e2b6683831dc3f5bd20be9a7840ed69 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -102,7 +102,6 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
-import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
@@ -908,7 +907,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
AABB axisalignedbb = this.getBoundingBox();
CollisionContext voxelshapecollision = CollisionContext.of(this);
VoxelShape voxelshape = this.level.getWorldBorder().getCollisionShape();
- Stream<VoxelShape> stream = Shapes.joinIsNotEmpty(voxelshape, Shapes.create(axisalignedbb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty() : Stream.of(voxelshape);
+ Stream<VoxelShape> stream = !this.level.getWorldBorder().isInBounds(axisalignedbb) ? Stream.empty() : Stream.of(voxelshape); // Paper
Stream<VoxelShape> stream1 = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(movement), (entity) -> {
return true;
});
diff --git a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
index feca9ff34936686c0665ae0dbc926869087df3a7..60f8585a736af5b654b8aaed89a39a8bf5e91301 100644
--- a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
+++ b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
@@ -143,10 +143,10 @@ public class CollisionSpliterator extends AbstractSpliterator<VoxelShape> {
AABB axisalignedbb = this.source.getBoundingBox();
if (!isBoxFullyWithinWorldBorder(worldborder, axisalignedbb)) {
- VoxelShape voxelshape = worldborder.getCollisionShape();
-
- if (!isOutsideBorder(voxelshape, axisalignedbb) && isCloseToBorder(voxelshape, axisalignedbb)) {
- consumer.accept(voxelshape);
+ // Paper start
+ if (worldborder.isInBounds(axisalignedbb.deflate(1.0E-7D)) && !worldborder.isInBounds(axisalignedbb.grow(1.0E-7D))) {
+ consumer.accept(worldborder.asVoxelShape());
+ // Paper end
return true;
}
}
diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
index 7a728ca96ee2eaf776c391ba8351196a526e18ec..aaa6251838483de5c46913534413151b5cb1d3fe 100644
--- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java
+++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
@@ -52,6 +52,7 @@ public class WorldBorder {
return (double) pos.getMaxBlockX() > this.getMinX() && (double) pos.getMinBlockX() < this.getMaxX() && (double) pos.getMaxBlockZ() > this.getMinZ() && (double) pos.getMinBlockZ() < this.getMaxZ();
}
+ public final boolean isInBounds(AABB aabb) { return this.isWithinBounds(aabb); } // Paper - OBFHELPER
public boolean isWithinBounds(AABB box) {
return box.maxX > this.getMinX() && box.minX < this.getMaxX() && box.maxZ > this.getMinZ() && box.minZ < this.getMaxZ();
}
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
index 1603eb3f7d90a4b3a028b20776566db77d09c123..f28d2126bc29fad3971a32cf85a7a7c4803b36ab 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
@@ -252,7 +252,7 @@ public final class Shapes {
BlockState iblockdata = world.getTypeIfLoaded(blockposition_mutableblockposition); // Paper
if (iblockdata == null) return 0.0D; // Paper
- if ((k2 != 1 || iblockdata.hasLargeCollisionShape()) && (k2 != 2 || iblockdata.is(Blocks.MOVING_PISTON))) {
+ if (!iblockdata.isAir() && (k2 != 1 || iblockdata.hasLargeCollisionShape()) && (k2 != 2 || iblockdata.is(Blocks.MOVING_PISTON))) { // Paper
initial = iblockdata.getCollisionShape((BlockGetter) world, blockposition_mutableblockposition, context).collide(enumdirection_enumaxis2, box.move((double) (-blockposition_mutableblockposition.getX()), (double) (-blockposition_mutableblockposition.getY()), (double) (-blockposition_mutableblockposition.getZ())), initial);
if (Math.abs(initial) < 1.0E-7D) {
return 0.0D;

View File

@ -1,68 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 1 Jul 2020 03:12:06 -0400
Subject: [PATCH] Clean up duplicated GameProfile Properties
We had a bug where we accidently cloned properties resulting in skulls
growing to large sizes and preventing login.
This now automatically cleans up the extra properties.
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index f57c5e441045a81072a2edfed0f199d90e6d7fde..3abfd21ea84c54aec6256008b3b9e6bbc7ae694c 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -59,8 +59,8 @@ public final class NbtUtils {
while (iterator.hasNext()) {
String s1 = (String) iterator.next();
ListTag nbttaglist = nbttagcompound1.getList(s1, 10);
-
- for (int i = 0; i < nbttaglist.size(); ++i) {
+ if (nbttaglist.size() == 0) continue; // Paper - remove duplicate properties
+ for (int i = nbttaglist.size() - 1; i < nbttaglist.size(); ++i) { // Paper - remove duplicate properties
CompoundTag nbttagcompound2 = nbttaglist.getCompound(i);
String s2 = nbttagcompound2.getString("Value");
@@ -246,7 +246,7 @@ public final class NbtUtils {
Optional<T> optional = property.getValue(propertiesTag.getString(key));
if (optional.isPresent()) {
- return (StateHolder) state.setValue(property, (Comparable) optional.get());
+ return state.setValue(property, optional.get()); // Paper - decompile error
} else {
NbtUtils.LOGGER.warn("Unable to read property: {} with value: {} for blockstate: {}", key, propertiesTag.getString(key), mainTag.toString());
return state;
@@ -276,8 +276,8 @@ public final class NbtUtils {
return nbttagcompound;
}
- private static <T extends Comparable<T>> String getName(net.minecraft.world.level.block.state.properties.Property<T> property, Comparable<?> value) {
- return property.value(value);
+ private static <T extends Comparable<T>> String getName(net.minecraft.world.level.block.state.properties.Property<T> property, Comparable<T> value) {// Paper - decompile error
+ return property.getName((T) value);// Paper - decompile error
}
public static CompoundTag update(DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion) {
diff --git a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
index 1cb67832a849db96f1cce95c32b41574e990e5b7..d97be7a1dfa7ad413afb8ff7668189fd37baf264 100644
--- a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
+++ b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
@@ -59,6 +59,18 @@ public class PlayerHeadItem extends StandingAndWallBlockItem {
return true;
} else {
// CraftBukkit start
+ // Paper start - clean up old duplicated properties
+ CompoundTag properties = tag.getCompound("SkullOwner").getCompound("Properties");
+ for (String key : properties.getAllKeys()) {
+ net.minecraft.nbt.ListTag values = properties.getList(key, 10);
+ if (values.size() > 1) {
+ net.minecraft.nbt.Tag texture = values.get(values.size() - 1);
+ values = new net.minecraft.nbt.ListTag();
+ values.add(texture);
+ properties.put(key, values);
+ }
+ }
+ // Paper end
net.minecraft.nbt.ListTag textures = tag.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
for (int i = 0; i < textures.size(); i++) {
if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).contains("Signature", 8) && ((CompoundTag) textures.get(i)).getString("Value").trim().isEmpty()) {

View File

@ -17,14 +17,13 @@ This allows servers with smaller worlds who do less long distance exploring to s
wasting cpu cycles on saving/unloading/reloading chunks repeatedly.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 6463d3e4837d032a35654a035f42b8a805e0e286..1655bca0502e7b871de4addaa163536d86547a02 100644
index 3bc6329d3ea48966cb99e792f9b35e2d2d71a34b..1f4d0d3493e748f52eb3b679c0a8a1306c0cc8b4 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -637,4 +637,13 @@ public class PaperWorldConfig {
private void viewDistance() {
@@ -495,6 +495,15 @@ public class PaperWorldConfig {
this.noTickViewDistance = this.getInt("viewdistances.no-tick-view-distance", -1);
}
+
+ public long delayChunkUnloadsBy;
+ private void delayChunkUnloadsBy() {
+ delayChunkUnloadsBy = PaperConfig.getSeconds(getString("delay-chunk-unloads-by", "10s"));
@ -33,12 +32,15 @@ index 6463d3e4837d032a35654a035f42b8a805e0e286..1655bca0502e7b871de4addaa163536d
+ delayChunkUnloadsBy *= 20;
+ }
+ }
}
+
public boolean altItemDespawnRateEnabled;
public Map<Material, Integer> altItemDespawnRateMap;
private void altItemDespawnRate() {
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
index e41f388e8350010a471410436adf15a906f07e97..e0241b9d60cd2b72f8fb774f1ab4753dfd615184 100644
index 577b391dcba1db712c1e2c83296e1c87b3e34ab2..d94241bcca4f2fd5e464a860bd356af504dc68b7 100644
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
@@ -185,6 +185,27 @@ public abstract class DistanceManager {
@@ -181,6 +181,27 @@ public abstract class DistanceManager {
boolean removed = false; // CraftBukkit
if (arraysetsorted.remove(ticket)) {
removed = true; // CraftBukkit
@ -56,7 +58,7 @@ index e41f388e8350010a471410436adf15a906f07e97..e0241b9d60cd2b72f8fb774f1ab4753d
+ if (!hasPlayer && playerChunk != null && playerChunk.isFullChunkReady()) {
+ Ticket<Long> delayUnload = new Ticket<Long>(TicketType.DELAY_UNLOAD, 33, i);
+ delayUnload.delayUnloadBy = delayChunkUnloadsBy;
+ delayUnload.setCurrentTick(this.ticketTickCounter);
+ delayUnload.setCreatedTick(this.ticketTickCounter);
+ arraysetsorted.remove(delayUnload);
+ // refresh ticket
+ arraysetsorted.add(delayUnload);
@ -67,13 +69,13 @@ index e41f388e8350010a471410436adf15a906f07e97..e0241b9d60cd2b72f8fb774f1ab4753d
if (arraysetsorted.isEmpty()) {
diff --git a/src/main/java/net/minecraft/server/level/Ticket.java b/src/main/java/net/minecraft/server/level/Ticket.java
index c0bfe136ccb9ad4fc0f8ccdd703254205213ec8e..f7898bd7806684d2c068898cecbf835d834df461 100644
index 8b0c6e1a649400908dbb674dfb4cdd1aa0ce1d38..a7aa7a9038d4812a9d1e4e72c4dbbbe10df15820 100644
--- a/src/main/java/net/minecraft/server/level/Ticket.java
+++ b/src/main/java/net/minecraft/server/level/Ticket.java
@@ -9,11 +9,13 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
@@ -7,11 +7,13 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
private final int ticketLevel;
public final T key; public final T getObjectReason() { return this.key; } // Paper - OBFHELPER
private long createdTick; public final long getCreationTick() { return this.createdTick; } // Paper - OBFHELPER
public int priority = 0; // Paper
+ public long delayUnloadBy; // Paper
protected Ticket(TicketType<T> type, int level, T argument) {
@ -83,25 +85,25 @@ index c0bfe136ccb9ad4fc0f8ccdd703254205213ec8e..f7898bd7806684d2c068898cecbf835d
+ this.delayUnloadBy = type.timeout; // Paper
}
public int compareTo(Ticket<?> ticket) {
@@ -63,7 +65,7 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
@Override
@@ -60,7 +62,7 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
}
protected boolean timedOut(long currentTick) {
- long j = this.type.timeout();
+ long j = delayUnloadBy; // Paper
return j != 0L && currentTick - this.createdTick > j;
- long l = this.type.timeout();
+ long l = delayUnloadBy; // Paper
return l != 0L && currentTick - this.createdTick > l;
}
}
diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java
index 2444f6f676db543509b14e8c882491dc3f41b264..531ebf1bafec2b295af9f6dfec8f4b6466688287 100644
index 78fbb4c3e52e900956ae0811aaf934c81ee5ea48..8770fe0db46b01e8b608637df4f1a669a3f4cdde 100644
--- a/src/main/java/net/minecraft/server/level/TicketType.java
+++ b/src/main/java/net/minecraft/server/level/TicketType.java
@@ -30,6 +30,7 @@ public class TicketType<T> {
public static final TicketType<Long> ASYNC_LOAD = create("async_load", Long::compareTo); // Paper
public static final TicketType<ChunkPos> PRIORITY = create("priority", Comparator.comparingLong(ChunkPos::toLong), 300); // Paper
public static final TicketType<ChunkPos> URGENT = create("urgent", Comparator.comparingLong(ChunkPos::toLong), 300); // Paper
@@ -28,6 +28,7 @@ public class TicketType<T> {
public static final TicketType<ChunkPos> UNKNOWN = TicketType.create("unknown", Comparator.comparingLong(ChunkPos::toLong), 1);
public static final TicketType<Unit> PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit
public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
+ public static final TicketType<Long> DELAY_UNLOAD = create("delay_unload", Long::compareTo, 300); // Paper
public static <T> TicketType<T> create(String name, Comparator<T> comparator) {
return new TicketType<>(name, comparator, 0L);
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
return new TicketType<>(name, argumentComparator, 0L);

View File

@ -5,7 +5,7 @@ Subject: [PATCH] incremental chunk saving
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 3bc6329d3ea48966cb99e792f9b35e2d2d71a34b..ec51a9e19670888584e5324a57a47aa9c676d423 100644
index 1f4d0d3493e748f52eb3b679c0a8a1306c0cc8b4..91917b11163c0740d5e5effc5e93d494e2b2d73e 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -47,6 +47,21 @@ public class PaperWorldConfig {

View File

@ -22,40 +22,32 @@ wants it to collect even faster, they can restore that setting back to 1 instead
Not adding it to .getType() though to keep behavior consistent with vanilla for performance reasons.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 92f1a6d32a96fee682342e86c3ffd3c65292150b..2ec41cb87cec97780f1fa8abfbb756fca4dba1bf 100644
index 94670ec4de01341822f6affe0fa1c9774dd6131b..6bc5ba51c90723c7138b1b5d2381cb215f1e5271 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -342,7 +342,7 @@ public final class CraftServer implements Server {
ambientSpawn = configuration.getInt("spawn-limits.ambient");
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
- TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks");
+ TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
minimumAPI = configuration.getString("settings.minimum-api");
loadIcon();
@@ -346,7 +346,7 @@ public final class CraftServer implements Server {
this.ambientSpawn = this.configuration.getInt("spawn-limits.ambient");
console.autosavePeriod = this.configuration.getInt("ticks-per.autosave");
this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose"));
- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks");
+ TicketType.PLUGIN.timeout = Math.min(20, this.configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
this.minimumAPI = this.configuration.getString("settings.minimum-api");
this.loadIcon();
}
@@ -832,7 +832,7 @@ public final class CraftServer implements Server {
waterAmbientSpawn = configuration.getInt("spawn-limits.water-ambient");
ambientSpawn = configuration.getInt("spawn-limits.ambient");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
- TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks");
@@ -834,7 +834,7 @@ public final class CraftServer implements Server {
this.waterAmbientSpawn = this.configuration.getInt("spawn-limits.water-ambient");
this.ambientSpawn = this.configuration.getInt("spawn-limits.ambient");
this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose"));
- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks");
+ TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
minimumAPI = configuration.getString("settings.minimum-api");
printSaveWarning = false;
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
this.minimumAPI = this.configuration.getString("settings.minimum-api");
this.printSaveWarning = false;
console.autosavePeriod = this.configuration.getInt("ticks-per.autosave");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea16307e0785b9 100644
index 72c9ad9f75c20d6c1a6d54e2913e2f9918c11ffd..f72471ac82907a0d5112598b3289689495285944 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -30,6 +30,7 @@ import net.minecraft.network.protocol.game.ClientboundCustomSoundPacket;
import net.minecraft.network.protocol.game.ClientboundLevelEventPacket;
import net.minecraft.network.protocol.game.ClientboundSetTimePacket;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MCUtil;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.DistanceManager;
@@ -389,8 +390,21 @@ public class CraftWorld implements World {
@@ -405,8 +405,21 @@ public class CraftWorld implements World {
@Override
public Chunk getChunkAt(int x, int z) {
@ -72,22 +64,22 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630
+
+ // Paper start
+ private void addTicket(int x, int z) {
+ MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
+ net.minecraft.server.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
}
+ // Paper end
@Override
public Chunk getChunkAt(Block block) {
@@ -465,7 +479,7 @@ public class CraftWorld implements World {
@@ -481,7 +494,7 @@ public class CraftWorld implements World {
public boolean unloadChunkRequest(int x, int z) {
org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
if (isChunkLoaded(x, z)) {
- world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
+ world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE); // Paper
if (this.isChunkLoaded(x, z)) {
- this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
+ this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE); // Paper
}
return true;
@@ -542,9 +556,12 @@ public class CraftWorld implements World {
@@ -558,9 +571,12 @@ public class CraftWorld implements World {
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
// Paper start - Optimize this method
ChunkPos chunkPos = new ChunkPos(x, z);
@ -101,7 +93,7 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630
if (immediate == null) {
immediate = world.getChunkSource().chunkMap.getUnloadingChunk(x, z);
}
@@ -552,7 +569,7 @@ public class CraftWorld implements World {
@@ -568,7 +584,7 @@ public class CraftWorld implements World {
if (!(immediate instanceof ImposterProtoChunk) && !(immediate instanceof net.minecraft.world.level.chunk.LevelChunk)) {
return false; // not full status
}
@ -110,7 +102,7 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630
world.getChunk(x, z); // make sure we're at ticket level 32 or lower
return true;
}
@@ -579,7 +596,7 @@ public class CraftWorld implements World {
@@ -594,7 +610,7 @@ public class CraftWorld implements World {
// we do this so we do not re-read the chunk data on disk
}
@ -119,11 +111,11 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630
world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
return true;
// Paper end
@@ -2529,6 +2546,7 @@ public class CraftWorld implements World {
}
@@ -2544,6 +2560,7 @@ public class CraftWorld implements World {
return this.world.getChunkSource().getChunkAtAsynchronously(x, z, gen, urgent).thenComposeAsync((either) -> {
net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk) either.left().orElse(null);
+ if (chunk != null) addTicket(x, z); // Paper
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
return java.util.concurrent.CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
}, net.minecraft.server.MinecraftServer.getServer());
}

View File

@ -13,17 +13,15 @@ The fix for the issue is quite simple, casting chunk coordinates to longs
allows the distance calculation to avoid overflow and work as intended.
diff --git a/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java b/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java
index af006c2e45e0a14367a0bc850c319024c6b82024..063369d3a64b4afc9cc6e1d20360900595e1a05f 100644
index 7f7b0c961a76119b6004da03fe01ff4e2ae41628..9a64ab092ac8616ed8b9ea5c1e8677dda5c4333c 100644
--- a/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java
+++ b/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java
@@ -75,7 +75,9 @@ public class TheEndBiomeSource extends BiomeSource {
@@ -84,7 +84,7 @@ public class TheEndBiomeSource extends BiomeSource {
int l = j / 2;
int i1 = i % 2;
int j1 = j % 2;
- float f = 100.0F - Mth.sqrt((float) (i * i + j * j)) * 8.0F;
+ // Paper start - cast ints to long to avoid integer overflow
+ float f = 100.0F - Mth.sqrt((long) i * (long) i + (long) j * (long) j) * 8.0F;
+ // Paper end
int m = i % 2;
int n = j % 2;
- float f = 100.0F - Mth.sqrt((float)(i * i + j * j)) * 8.0F;
+ float f = 100.0F - Mth.sqrt((long) i * (long) i + (long) j * (long) j) * 8.0F; // Paper - cast ints to long to avoid integer overflow
f = Mth.clamp(f, -100.0F, 80.0F);
for(int o = -12; o <= 12; ++o) {

View File

@ -7,15 +7,15 @@ Subject: [PATCH] Fix CraftScheduler#runTaskTimerAsynchronously(Plugin,
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index ca90237a53c9a026919d28adaedf483ca3c7c2a8..13e461ffb2ee2e7d0440c0f60809ea99629b843c 100644
index dd1e8b170e87bff2089f642f41dcf7442a8ccd16..33480893ddee34a1983c5f1c4b14db98ff438528 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -184,7 +184,7 @@ public class CraftScheduler implements BukkitScheduler {
@Override
public void runTaskTimerAsynchronously(Plugin plugin, Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException {
- runTaskTimerAsynchronously(plugin, (Object) task, delay, CraftTask.NO_REPEATING);
+ runTaskTimerAsynchronously(plugin, (Object) task, delay, period);
- this.runTaskTimerAsynchronously(plugin, (Object) task, delay, CraftTask.NO_REPEATING);
+ this.runTaskTimerAsynchronously(plugin, (Object) task, delay, period);
}
@Override

View File

@ -47,10 +47,10 @@ index 7f140333c2e62012fa572c1a061d84432426997f..b67ba8f75e4a3358d7c2462918b85b0b
+ }
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index 40a18302dd682e5ade4ec77ac7f316b6c0f8c112..44876557515eaa6bbe33344b3d3ba03aee58409f 100644
index 44cc09006eac6315d167a2628857f9942eb1fc13..aea9a2dc4164f5728e711efb3009bde8862c7345 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -398,12 +398,24 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -411,14 +411,26 @@ public class PistonBaseBlock extends DirectionalBlock {
}
for (k = list.size() - 1; k >= 0; --k) {
@ -63,14 +63,16 @@ index 40a18302dd682e5ade4ec77ac7f316b6c0f8c112..44876557515eaa6bbe33344b3d3ba03a
+ // Paper end - fix a variety of piston desync dupes
blockposition3 = blockposition3.relative(enumdirection1);
map.remove(blockposition3);
world.setBlock(blockposition3, (BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, dir), 68);
- world.setBlockEntity(blockposition3, MovingPistonBlock.newMovingBlockEntity((BlockState) list1.get(k), dir, retract, false));
BlockState iblockdata2 = (BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, dir);
world.setBlock(blockposition3, iblockdata2, 68);
- world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, (BlockState) list1.get(k), dir, retract, false));
+ // Paper start - fix a variety of piston desync dupes
+ if (!allowDesync) {
+ iblockdata1 = world.getBlockState(oldPos);
+ map.replace(oldPos, iblockdata1);
+ }
+ world.setBlockEntity(blockposition3, MovingPistonBlock.newMovingBlockEntity(allowDesync ? list1.get(k) : iblockdata1, dir, retract, false));
+ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? list1.get(k) : iblockdata1, dir, retract, false));
+ if (!allowDesync) {
+ world.setBlock(oldPos, Blocks.AIR.defaultBlockState(), 2 | 4 | 16 | 1024); // set air to prevent later physics updates from seeing this block
+ }
@ -79,15 +81,15 @@ index 40a18302dd682e5ade4ec77ac7f316b6c0f8c112..44876557515eaa6bbe33344b3d3ba03a
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index 73888713746e7ddd72ba9ac9d33d8e616eb3bd25..001e90da8b09e16b6df4849a5bac4f4821000c94 100644
index 9b631698d1c736f61e07a5a1253127f4081dc90d..87bedba9ab495edcce289c6665271d92b7165944 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -279,7 +279,7 @@ public class PistonMovingBlockEntity extends BlockEntity implements TickableBloc
BlockState iblockdata = Block.updateFromNeighbourShapes(this.movedState, (LevelAccessor) this.level, this.worldPosition);
if (iblockdata.isAir()) {
- this.level.setBlock(this.worldPosition, this.movedState, 84);
+ this.level.setBlock(this.worldPosition, this.movedState, com.destroystokyo.paper.PaperConfig.allowPistonDuplication ? 84 : (84 | 2)); // Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
Block.updateOrDestroy(this.movedState, iblockdata, this.level, this.worldPosition, 3);
@@ -281,7 +281,7 @@ public class PistonMovingBlockEntity extends BlockEntity {
if (blockEntity.movedState != null && world.getBlockState(pos).is(Blocks.MOVING_PISTON)) {
BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, world, pos);
if (blockState.isAir()) {
- world.setBlock(pos, blockEntity.movedState, 84);
+ world.setBlock(pos, blockEntity.movedState, com.destroystokyo.paper.PaperConfig.allowPistonDuplication ? 84 : (84 | 2)); // Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
Block.updateOrDestroy(blockEntity.movedState, blockState, world, pos, 3);
} else {
if (iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockStateProperties.WATERLOGGED)) {
if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) {

View File

@ -7,27 +7,27 @@ If the falling block dies during teleportation (entity#move), then we need
to detect that by placing a check after the move.
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index ff8f7e4569a889ead1512b7c9908f9c5cad9eed5..2ba81e7179c7f9e2e1add1ad6bd6b96ee12c5da1 100644
index 2332a00780edcf054ec63a60a42962033d0cc74a..2fad050547242028d4ff2deb613e074190f51341 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -101,6 +101,11 @@ public class FallingBlockEntity extends Entity {
@@ -106,6 +106,11 @@ public class FallingBlockEntity extends Entity {
@Override
public void tick() {
+ // Paper start - fix sand duping
+ if (this.removed) {
+ if (this.isRemoved()) {
+ return;
+ }
+ // Paper end - fix sand duping
if (this.blockState.isAir()) {
this.remove();
this.discard();
} else {
@@ -123,6 +128,12 @@ public class FallingBlockEntity extends Entity {
@@ -128,6 +133,12 @@ public class FallingBlockEntity extends Entity {
this.move(MoverType.SELF, this.getDeltaMovement());
+ // Paper start - fix sand duping
+ if (this.removed) {
+ if (this.isRemoved()) {
+ return;
+ }
+ // Paper end - fix sand duping

View File

@ -14,10 +14,10 @@ behaviour, we need to move all of this dangerous logic outside
of the move call and into an appropriate place in the tick method.
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0625bc7ffd07b66b27176fe62ae3061aa7c67df2..fbafb89cc63744d942933546026e272122bd9fba 100644
index b5325f19458467b307db629a00359af41004124a..7c9ac85431f8c5a325c94c0e7d1db0315b2d62c1 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1324,6 +1324,11 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -1345,6 +1345,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
this.player.move(MoverType.PLAYER, new Vec3(d7, d8, d9));
this.player.setOnGround(packet.isOnGround()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move
@ -28,4 +28,4 @@ index 0625bc7ffd07b66b27176fe62ae3061aa7c67df2..fbafb89cc63744d942933546026e2721
+ // Paper end - prevent position desync
double d12 = d8;
d7 = d4 - this.player.getX();
d7 = d0 - this.player.getX();

View File

@ -5,33 +5,25 @@ Subject: [PATCH] Inventory getHolder method without block snapshot
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index ef2d18d19a86b3701855aa1ac126462e663f8fcd..7ccc085228f373e6eba55d809bed480d43d5c211 100644
index 56bd3290fdf011590594d68128eb3fe9ca71506c..7850dfa9130761905030856786a97a008c700687 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -10,6 +10,7 @@ import net.minecraft.world.inventory.PlayerEnderChestContainer;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BarrelBlockEntity;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
+import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.entity.DispenserBlockEntity;
import net.minecraft.world.level.block.entity.DropperBlockEntity;
@@ -525,6 +526,13 @@ public class CraftInventory implements Inventory {
return inventory.getOwner();
@@ -525,6 +525,13 @@ public class CraftInventory implements Inventory {
return this.inventory.getOwner();
}
+ // Paper start - getHolder without snapshot
+ @Override
+ public InventoryHolder getHolder(boolean useSnapshot) {
+ return inventory instanceof BlockEntity ? ((BlockEntity) inventory).getOwner(useSnapshot) : getHolder();
+ return inventory instanceof net.minecraft.world.level.block.entity.BlockEntity ? ((net.minecraft.world.level.block.entity.BlockEntity) inventory).getOwner(useSnapshot) : getHolder();
+ }
+ // Paper end
+
@Override
public int getMaxStackSize() {
return inventory.getMaxStackSize();
return this.inventory.getMaxStackSize();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java
index 3245dfa94410d319e53543c862c990e80ed3c72d..23dcf6e9332bd2b42ebb851497483e41948355d8 100644
index 01d425d359f2d6d87b6c01b435a9cfcfe11caa20..4707a651dc80086efa852bcfba38a534e7f1f3d0 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java
@@ -64,6 +64,13 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC
@ -47,4 +39,4 @@ index 3245dfa94410d319e53543c862c990e80ed3c72d..23dcf6e9332bd2b42ebb851497483e41
+
@Override
public Location getLocation() {
return getLeftSide().getLocation().add(getRightSide().getLocation()).multiply(0.5);
return this.getLeftSide().getLocation().add(this.getRightSide().getLocation()).multiply(0.5);

View File

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nesaak <52047222+Nesaak@users.noreply.github.com>
Date: Sat, 23 May 2020 10:31:11 -0400
Subject: [PATCH] Expose Arrow getItemStack
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
index 376885c8148da619a3b203145d315ebaf44994fb..88defdc48c72580bbf029910f159dedccf67dc1e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
@@ -102,6 +102,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
this.getHandle().pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.byOrdinal(status.ordinal());
}
+ // Paper start
+ @Override
+ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() {
+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(getHandle().getPickupItem());
+ }
+ //Paper end
+
@Override
public void setTicksLived(int value) {
super.setTicksLived(value);

View File

@ -5,25 +5,23 @@ Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index fbafb89cc63744d942933546026e272122bd9fba..a0b2fc3fe59d97b9282a9451f35542b39df774e7 100644
index 7c9ac85431f8c5a325c94c0e7d1db0315b2d62c1..c65f6eda0cff66ae9007e92002075e1f6fd631cd 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2770,9 +2770,15 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -2778,9 +2778,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
this.player.resetLastActionTime();
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.isSynched(this.player) && this.player.containerMenu instanceof RecipeBookMenu) {
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) {
- this.server.getRecipeManager().byKey(packet.getRecipe()).ifPresent((irecipe) -> {
- ((RecipeBookMenu) this.player.containerMenu).handlePlacement(packet.isShiftDown(), irecipe, this.player);
- });
+ // Paper start - fire event for clicking recipes in the recipe book
+ com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent event = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent(
+ player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(packet.getRecipe()), packet.isShiftDown());
+ if (event.callEvent()) {
+ this.server.getRecipeManager().byKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getRecipe())).ifPresent((irecipe) -> {
+ ((ContainerRecipeBook) this.player.activeContainer).a(event.isMakeAll(), irecipe, this.player);
+ });
+ }
+ // Paper end
+ ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isMakeAll(), irecipe, this.player);
});
+ } // Paper end
}
}

View File

@ -9,7 +9,7 @@ on harddrives.
-DPaper.enable-sync-chunk-writes=true to enable
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
index 545096d9ba403396b6aaa7bb6d912f2de08a967e..3450a58fc02a472eb710aa1a31f6fecefc982b6f 100644
index e3409d5f4ddcaa4edecfa4b3c638a12624b09f1b..c9d80a5430cc66d6189bf337770af43121a5bfd5 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -108,7 +108,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie

View File

@ -5,23 +5,23 @@ Subject: [PATCH] Add permission for command blocks
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index af048ab682612233c01f7087d7b8afbf7e58945b..79f3e4176145c42debb9adc1e68175cf063c1f22 100644
index f4a056185990181e486f452960159a5287947382..6c55bd8b876d1d694e05ad6de6a9fd29a4d4d053 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -386,7 +386,7 @@ public class ServerPlayerGameMode {
@@ -389,7 +389,7 @@ public class ServerPlayerGameMode {
BlockEntity tileentity = this.level.getBlockEntity(pos);
Block block = iblockdata.getBlock();
- if ((block instanceof CommandBlock || block instanceof StructureBlock || block instanceof JigsawBlock) && !this.player.canUseGameMasterBlocks()) {
+ if ((block instanceof CommandBlock || block instanceof StructureBlock || block instanceof JigsawBlock) && !this.player.canUseGameMasterBlocks() && !(block instanceof CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
- if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) {
+ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks() && !(block instanceof net.minecraft.world.level.block.CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
this.level.sendBlockUpdated(pos, iblockdata, iblockdata, 3);
return false;
} else if (this.player.blockActionRestricted((Level) this.level, pos, this.gameModeForPlayer)) {
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a0b2fc3fe59d97b9282a9451f35542b39df774e7..471370a9aafa3eda83beb4097c6233650bd155ee 100644
index c65f6eda0cff66ae9007e92002075e1f6fd631cd..8193f783cbe7c678632b55f4bc59bc9d7b5756be 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -796,7 +796,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -788,7 +788,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (!this.server.isCommandBlockEnabled()) {
this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID);
@ -30,7 +30,7 @@ index a0b2fc3fe59d97b9282a9451f35542b39df774e7..471370a9aafa3eda83beb4097c623365
this.player.sendMessage(new TranslatableComponent("advMode.notAllowed"), Util.NIL_UUID);
} else {
BaseCommandBlock commandblocklistenerabstract = null;
@@ -859,7 +859,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -855,7 +855,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (!this.server.isCommandBlockEnabled()) {
this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID);
@ -40,10 +40,10 @@ index a0b2fc3fe59d97b9282a9451f35542b39df774e7..471370a9aafa3eda83beb4097c623365
} else {
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level);
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
index 00dc4cd436023b946d7005f17a7ba983a4bbdfb6..23500428abf5e7daec19f8fb3c24e6c5361f0819 100644
index 2e6172930526efc536a214e420e690a5ea42ac3e..c0dd148d08abf064b5f3c261046cf41d0d1bcf06 100644
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
@@ -192,7 +192,7 @@ public abstract class BaseCommandBlock implements CommandSource {
@@ -200,7 +200,7 @@ public abstract class BaseCommandBlock implements CommandSource {
}
public InteractionResult usedBy(Player player) {
@ -53,10 +53,10 @@ index 00dc4cd436023b946d7005f17a7ba983a4bbdfb6..23500428abf5e7daec19f8fb3c24e6c5
} else {
if (player.getCommandSenderWorld().isClientSide) {
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
index 088d78905732cacf69beb7a4b713dac4bec82220..c5e81e7d67504b1bc2a87c0b577bb93be4a57e9c 100644
index 363ad038e6c2edc675ded828c7800852d1b0668a..fd73e9100feac8c7bf9a5fee21a0ab2d502dc3e0 100644
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
@@ -128,7 +128,7 @@ public class CommandBlock extends BaseEntityBlock {
@@ -129,7 +129,7 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
BlockEntity tileentity = world.getBlockEntity(pos);
@ -66,14 +66,14 @@ index 088d78905732cacf69beb7a4b713dac4bec82220..c5e81e7d67504b1bc2a87c0b577bb93b
return InteractionResult.sidedSuccess(world.isClientSide);
} else {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
index 525ebf961e5da0687183a5e2ead23ed92cbd9d79..a4a809f302c5ff9c76cde5fc0add2ceec1bdf9b5 100644
index c93eec7a81ed83dc9190417dd51acb2780d3b60d..cb75827316fe6c22ec900efea800d35d40573380 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
@@ -16,6 +16,7 @@ public final class CraftDefaultPermissions {
DefaultPermissions.registerPermission(ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
DefaultPermissions.registerPermission(ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
DefaultPermissions.registerPermission(ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent);
+ DefaultPermissions.registerPermission(ROOT + ".commandblock", "Gives the user the ability to use command blocks.", org.bukkit.permissions.PermissionDefault.OP, parent); // Paper
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent);
+ DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".commandblock", "Gives the user the ability to use command blocks.", org.bukkit.permissions.PermissionDefault.OP, parent); // Paper
// Spigot end
parent.recalculatePermissibles();
}

View File

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 10 May 2020 22:12:46 -0400
Subject: [PATCH] Ensure Entity AABB's are never invalid
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 11ae525a5d2bd29bfe658d683c53a0ab2626616a..fd0cef886761e71fe331aa60806c186c23ed19bc 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -540,7 +540,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
public void setPos(double x, double y, double z) {
this.setPosRaw(x, y, z);
- this.setBoundingBox(this.makeBoundingBox());
+ // this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw
}
protected AABB makeBoundingBox() {
@@ -3717,6 +3717,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
public final void setPosRaw(double x, double y, double z) {
+ // Paper start - never allow AABB to become desynced from position
+ // hanging has its own special logic
+ if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (this.position.x != x || this.position.y != y || this.position.z != z)) {
+ this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, z));
+ }
+ // Paper end
if (this.position.x != x || this.position.y != y || this.position.z != z) {
this.position = new Vec3(x, y, z);
int i = Mth.floor(x);

View File

@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sun, 10 May 2020 22:49:05 -0400
Subject: [PATCH] Optimize WorldBorder collision checks and air
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index fd0cef886761e71fe331aa60806c186c23ed19bc..96da70f1077f70c4bd5ba1196292a856deb25286 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1024,7 +1024,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
AABB axisalignedbb = this.getBoundingBox();
CollisionContext voxelshapecollision = CollisionContext.of(this);
VoxelShape voxelshape = this.level.getWorldBorder().getCollisionShape();
- Stream<VoxelShape> stream = Shapes.joinIsNotEmpty(voxelshape, Shapes.create(axisalignedbb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty() : Stream.of(voxelshape);
+ Stream<VoxelShape> stream = !this.level.getWorldBorder().isWithinBounds(axisalignedbb) ? Stream.empty() : Stream.of(voxelshape); // Paper
Stream<VoxelShape> stream1 = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(movement), (entity) -> {
return true;
});
diff --git a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
index 90039d01ef481ba206f2e952c99a755e94201ea3..2e93f33d6c9074c246c2289523b1fda20a2cf0dd 100644
--- a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
+++ b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
@@ -135,9 +135,10 @@ public class CollisionSpliterator extends AbstractSpliterator<VoxelShape> {
WorldBorder worldBorder = this.collisionGetter.getWorldBorder();
AABB aABB = this.source.getBoundingBox();
if (!isBoxFullyWithinWorldBorder(worldBorder, aABB)) {
- VoxelShape voxelShape = worldBorder.getCollisionShape();
- if (!isOutsideBorder(voxelShape, aABB) && isCloseToBorder(voxelShape, aABB)) {
- action.accept(voxelShape);
+ // Paper start
+ if (worldBorder.isWithinBounds(aABB.deflate(1.0E-7D)) && !worldBorder.isWithinBounds(aABB.inflate(1.0E-7D))) {
+ action.accept(worldBorder.asVoxelShape());
+ // Paper end
return true;
}
}
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
index 94f58332bb1408971fe65e5fd0401457ab986441..ceeec68fba8dacdc5b023c8817a6863b28c0e132 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
@@ -240,7 +240,7 @@ public final class Shapes {
mutableBlockPos.set(axisCycle, q, r, p);
BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
if (blockState == null) return 0.0D; // Paper
- if ((s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) {
+ if (!blockState.isAir() && (s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) { // Paper
initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial);
if (Math.abs(initial) < 1.0E-7D) {
return 0.0D;

View File

@ -8,61 +8,52 @@ makes it so that the server keeps the last difficulty used instead
of restoring the server.properties every single load.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f530c739b6aee3718eb5d0e0e6a09d882d817c68..19544b794b5a46c129016172798ff7294fcfed33 100644
index 363dcebb3b2d5a2512776a191f6716ed3d0e8aff..1feda8b44364c748497174944b26abc4f058f354 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1645,11 +1645,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1721,11 +1721,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
- public void setDifficulty(Difficulty enumdifficulty, boolean forceUpdate) {
- public void setDifficulty(Difficulty difficulty, boolean forceUpdate) {
- if (forceUpdate || !this.worldData.isDifficultyLocked()) {
- this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : enumdifficulty);
- this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : difficulty);
- this.updateMobSpawningFlags();
- this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
+ // Paper start - fix per world difficulty
+ public void setWorldDifficulty(ServerLevel world, Difficulty enumdifficulty, boolean forcefullySet) { this.a(world, enumdifficulty, forcefullySet); }
+ public void a(ServerLevel world, Difficulty enumdifficulty, boolean flag) {
+ PrimaryLevelData worldData = world.worldDataServer;
+ if (flag || !worldData.isDifficultyLocked()) {
+ worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : enumdifficulty);
+ world.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals());
+ //this.getPlayerList().getPlayers().forEach(this::b); // Commented: WorldDataServer#setDifficulty handles updating players' difficulties
+ // Paper start - remember per level difficulty
+ public void setDifficulty(ServerLevel level, Difficulty difficulty, boolean forceUpdate) {
+ PrimaryLevelData worldData = level.serverLevelData;
+ if (forceUpdate || !worldData.isDifficultyLocked()) {
+ worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty);
+ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals());
+ // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
+ // Paper end
}
}
diff --git a/src/main/java/net/minecraft/server/commands/DifficultyCommand.java b/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
index 106c633a91fea6c27d76d43d4678c00287b0992a..f0dfa78b13a774f5c6139efc70750a154961cede 100644
index 33c859df0b669d0c3e97ccba29f17c1ba2166a27..9f03b738aea623fe409ca176397f48be055466da 100644
--- a/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
+++ b/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
@@ -7,6 +7,7 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Difficulty;
@@ -35,10 +35,11 @@ public class DifficultyCommand {
public class DifficultyCommand {
@@ -41,10 +42,11 @@ public class DifficultyCommand {
public static int setDifficulty(CommandSourceStack source, Difficulty difficulty) throws CommandSyntaxException {
MinecraftServer minecraftserver = source.getServer();
- if (minecraftserver.getWorldData().getDifficulty() == difficulty) {
+ ServerLevel world = source.getLevel(); // Paper
+ if (world.worldDataServer.getDifficulty() == difficulty) { // Paper
throw DifficultyCommand.ERROR_ALREADY_DIFFICULT.create(difficulty.getKey());
MinecraftServer minecraftServer = source.getServer();
- if (minecraftServer.getWorldData().getDifficulty() == difficulty) {
+ net.minecraft.server.level.ServerLevel level = source.getLevel(); // Paper
+ if (level.serverLevelData.getDifficulty() == difficulty) { // Paper
throw ERROR_ALREADY_DIFFICULT.create(difficulty.getKey());
} else {
- minecraftserver.setDifficulty(difficulty, true);
+ minecraftserver.a(world, difficulty, true); // Paper
source.sendSuccess(new TranslatableComponent("commands.difficulty.success", new Object[]{difficulty.getDisplayName()}), true);
- minecraftServer.setDifficulty(difficulty, true);
+ minecraftServer.setDifficulty(level, difficulty, true); // Paper - use world
source.sendSuccess(new TranslatableComponent("commands.difficulty.success", difficulty.getDisplayName()), true);
return 0;
}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 6477ba1f31d977f8199fb4c7532938920b385ae7..95f9863bbccaa23d08c409792314df4f2397a317 100644
index e5f7f043cbdb28d85b8aa0eea7cbaeb584e5fb85..a5c1114f9b323e8a49c84d0e68461e473bbcd690 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -359,7 +359,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -367,7 +367,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@Override
public void forceDifficulty() {
@ -72,10 +63,10 @@ index 6477ba1f31d977f8199fb4c7532938920b385ae7..95f9863bbccaa23d08c409792314df4f
@Override
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 471370a9aafa3eda83beb4097c6233650bd155ee..773f2589c14e16d2f5b01a6dbd48e09d17d19c7e 100644
index 8193f783cbe7c678632b55f4bc59bc9d7b5756be..39777c2b1bbb12ce3e5be3724235ea0a8072cef8 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3039,7 +3039,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -3041,7 +3041,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {

View File

@ -6,18 +6,18 @@ Subject: [PATCH] Paper dumpitem command
Let's you quickly view the item in your hands NBT data
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 528c860fc0c04431e0ebb2ae6bc96bf9c2d04789..6fad9329213e4e8a3ef9ce7fb568ad22484a11f3 100644
index 7b5afc5d34b78e6404c1a5c6bb823d9589471f13..1700681197ca2ff47ea1618b06d811aa4f06ac7d 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -12,6 +12,7 @@ import com.google.gson.JsonObject;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonWriter;
import net.minecraft.core.BlockPos;
+import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.ClientboundLightUpdatePacket;
@@ -14,6 +14,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ThreadedLevelLightEngine;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ChunkPos;
+import net.minecraft.network.protocol.game.ClientboundLightUpdatePacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MCUtil;
@@ -36,7 +37,9 @@ import org.bukkit.command.CommandSender;
import org.apache.commons.lang3.tuple.MutablePair;
@@ -27,7 +28,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
@ -26,17 +26,17 @@ index 528c860fc0c04431e0ebb2ae6bc96bf9c2d04789..6fad9329213e4e8a3ef9ce7fb568ad22
+import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.FileOutputStream;
@@ -59,7 +62,7 @@ import java.util.stream.Collectors;
import java.time.LocalDateTime;
@@ -47,7 +50,7 @@ import java.util.stream.Collectors;
public class PaperCommand extends Command {
private static final String BASE_PERM = "bukkit.command.paper.";
- private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "dumpwaiting", "syncloadinfo", "fixlight").build();
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "dumpwaiting", "syncloadinfo", "fixlight", "dumpitem").build();
- private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight").build();
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight", "dumpitem").build();
public PaperCommand(String name) {
super(name);
@@ -168,6 +171,9 @@ public class PaperCommand extends Command {
@@ -156,6 +159,9 @@ public class PaperCommand extends Command {
case "reload":
doReload(sender);
break;
@ -46,18 +46,18 @@ index 528c860fc0c04431e0ebb2ae6bc96bf9c2d04789..6fad9329213e4e8a3ef9ce7fb568ad22
case "debug":
doDebug(sender, args);
break;
@@ -200,6 +206,19 @@ public class PaperCommand extends Command {
return true;
}
@@ -420,6 +426,19 @@ public class PaperCommand extends Command {
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Paper config reload complete.");
}
+ private void doDumpItem(CommandSender sender) {
+ ItemStack itemInHand = ((CraftPlayer) sender).getItemInHand();
+ net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(itemInHand);
+ CompoundTag tag = itemStack.getTag();
+ net.minecraft.nbt.CompoundTag tag = itemStack.getTag();
+ if (tag != null) {
+ String nbt = org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(tag.getNbtPrettyComponent());
+ Bukkit.getConsoleSender().sendMessage(nbt);
+ sender.sendMessage(nbt);
+ net.kyori.adventure.text.Component nbtComponent = io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.nbt.NbtUtils.toPrettyComponent(tag));
+ Bukkit.getConsoleSender().sendMessage(nbtComponent);
+ sender.sendMessage(nbtComponent);
+ } else {
+ sender.sendMessage("Item does not have NBT");
+ }
@ -66,15 +66,3 @@ index 528c860fc0c04431e0ebb2ae6bc96bf9c2d04789..6fad9329213e4e8a3ef9ce7fb568ad22
private void doFixLight(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command");
diff --git a/src/main/java/net/minecraft/nbt/Tag.java b/src/main/java/net/minecraft/nbt/Tag.java
index 85e9c5f4620fcf48cb3655fbb2db58b3fb31aa74..ba204cf135be333d4ac1c06ee6c2e961faadf8cb 100644
--- a/src/main/java/net/minecraft/nbt/Tag.java
+++ b/src/main/java/net/minecraft/nbt/Tag.java
@@ -26,6 +26,7 @@ public interface Tag {
return this.toString();
}
+ default Component getNbtPrettyComponent() { return this.getPrettyDisplay(); } // Paper - OBFHELPER
default Component getPrettyDisplay() {
return this.getPrettyDisplay("", 0);
}

View File

@ -5,23 +5,15 @@ Subject: [PATCH] Don't allow null UUID's for chat
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
index 002a6c7933f64405707d7d34d3e5c17584539623..a983785bf3bc43f65bd0809870c14a9fd30a3fc1 100644
index 26a229f7aa3f4425ed572e2d50730b4e978bf33e..a9fdfa7ec2a022e8adaa62721fb56748884686f5 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java
@@ -3,6 +3,7 @@ package net.minecraft.network.protocol.game;
import java.io.IOException;
import java.util.UUID;
+import net.minecraft.Util;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
@@ -21,7 +22,7 @@ public class ClientboundChatPacket implements Packet<ClientGamePacketListener> {
public ClientboundChatPacket(Component message, ChatType location, UUID senderUuid) {
@@ -18,7 +18,7 @@ public class ClientboundChatPacket implements Packet<ClientGamePacketListener> {
public ClientboundChatPacket(Component message, ChatType location, UUID sender) {
this.message = message;
this.type = location;
- this.sender = senderUuid;
+ this.sender = senderUuid != null ? senderUuid : Util.getNullUUID(); // Paper
- this.sender = sender;
+ this.sender = sender != null ? sender : net.minecraft.Util.NIL_UUID;
}
@Override
public ClientboundChatPacket(FriendlyByteBuf buf) {

View File

@ -7,7 +7,7 @@ Don't constantly send format: false for all formatting options when parent alrea
has it false
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1bc178d2ad 100644
index 0de5a46423ae0403dcbfca630dfd7c5ac1e1761d..26d43c229caf9f8504af7071c3a61ec6da7e27ec 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -46,6 +46,7 @@ public final class CraftChatMessage {
@ -15,11 +15,11 @@ index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1b
private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE);
// ChatColor.b does not explicitly reset, its more of empty
+ private static final Style EMPTY = Style.EMPTY.withItalic(false); // Paper - OBFHELPER
private static final Style RESET = Style.EMPTY.withBold(false).withItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false);
private static final Style RESET = Style.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false);
private final List<Component> list = new ArrayList<Component>();
@@ -67,6 +68,7 @@ public final class CraftChatMessage {
Matcher matcher = (keepNewlines ? INCREMENTAL_PATTERN_KEEP_NEWLINES : INCREMENTAL_PATTERN).matcher(message);
Matcher matcher = (keepNewlines ? StringMessage.INCREMENTAL_PATTERN_KEEP_NEWLINES : StringMessage.INCREMENTAL_PATTERN).matcher(message);
String match = null;
boolean needsAdd = false;
+ boolean hasReset = false; // Paper
@ -30,7 +30,7 @@ index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1b
throw new AssertionError("Unexpected message format");
}
} else { // Color resets formatting
- modifier = RESET.withColor(format);
- this.modifier = StringMessage.RESET.withColor(format);
+ // Paper start - improve legacy formatting
+ Style previous = modifier;
+ modifier = (!hasReset ? RESET : EMPTY).withColor(format);
@ -42,13 +42,13 @@ index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1b
+ modifier = modifier.withItalic(false);
+ }
+ if (previous.isObfuscated()) {
+ modifier = modifier.setRandom(false);
+ modifier = modifier.withObfuscated(false);
+ }
+ if (previous.isStrikethrough()) {
+ modifier = modifier.setStrikethrough(false);
+ modifier = modifier.withStrikethrough(false);
+ }
+ if (previous.isUnderlined()) {
+ modifier = modifier.setUnderline(false);
+ modifier = modifier.withUnderlined(false);
+ }
+ // Paper end
}

View File

@ -8,10 +8,10 @@ We have stored UUID in plenty of places that did not get DFU'd
So just look for old format and load it if it exists.
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
index c856ca720a9329a94bb07eaa3060c034f95718b3..0b739b5f040697049893d311c99456dbc5470e93 100644
index 1aa3af8c7714b2c850fb4264c863db8e639e6284..2a805d6bbeede50898d36258976ff25ee0aea165 100644
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
@@ -142,6 +142,12 @@ public class CompoundTag implements Tag {
@@ -121,6 +121,12 @@ public class CompoundTag implements Tag {
public void setUUID(String prefix, UUID uuid) { putUUID(prefix, uuid); } // Paper - OBFHELPER
public void putUUID(String key, UUID value) {
@ -24,9 +24,9 @@ index c856ca720a9329a94bb07eaa3060c034f95718b3..0b739b5f040697049893d311c99456db
this.tags.put(key, NbtUtils.createUUID(value));
}
@@ -151,11 +157,21 @@ public class CompoundTag implements Tag {
@@ -129,10 +135,20 @@ public class CompoundTag implements Tag {
* You must use {@link #hasUUID(String)} before or else it <b>will</b> throw an NPE.
*/
public UUID getUUID(String prefix) { return getUUID(prefix); } // Paper - OBFHELPER
public UUID getUUID(String key) {
+ // Paper start - support old format
+ if (!contains(key, 11) && this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) {
@ -36,29 +36,45 @@ index c856ca720a9329a94bb07eaa3060c034f95718b3..0b739b5f040697049893d311c99456db
return NbtUtils.loadUUID(this.get(key));
}
public final boolean hasUUID(String s) { return this.hasUUID(s); } // Paper - OBFHELPER
public boolean hasUUID(String key) {
+ // Paper start - support old format
+ if (this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) {
+ return true;
+ }
+ // Paper end
Tag nbtbase = this.get(key);
return nbtbase != null && nbtbase.getType() == IntArrayTag.TYPE && ((IntArrayTag) nbtbase).getAsIntArray().length == 4;
Tag tag = this.get(key);
return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
}
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index bf0da04ec9db3ec8313bddb06c278c13073819d1..f57c5e441045a81072a2edfed0f199d90e6d7fde 100644
index 57c9575a9714acb95d9dced672955a96d71dfd1e..dc136cd4d5d4ba1e0e53a7187b3a2e836e185c19 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -40,6 +40,11 @@ public final class NbtUtils {
s = tag.getString("Name");
@@ -40,14 +40,14 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class NbtUtils {
- private static final Comparator<ListTag> YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((listTag) -> {
+ private static final Comparator<ListTag> YXZ_LISTTAG_INT_COMPARATOR = Comparator.<ListTag>comparingInt((listTag) -> { // Paper - decompile fix
return listTag.getInt(1);
}).thenComparingInt((listTag) -> {
return listTag.getInt(0);
}).thenComparingInt((listTag) -> {
return listTag.getInt(2);
});
- private static final Comparator<ListTag> YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((listTag) -> {
+ private static final Comparator<ListTag> YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.<ListTag>comparingDouble((listTag) -> { // Paper - decompile fix
return listTag.getDouble(1);
}).thenComparingDouble((listTag) -> {
return listTag.getDouble(0);
@@ -76,6 +76,11 @@ public final class NbtUtils {
string = compound.getString("Name");
}
+ // Paper start - support string UUID's
+ if (tag.contains("Id", 8)) {
+ uuid = UUID.fromString(tag.getString("Id"));
+ if (compound.contains("Id", 8)) {
+ uUID = UUID.fromString(compound.getString("Id"));
+ }
+ // Paper end
if (tag.hasUUID("Id")) {
uuid = tag.getUUID("Id");
if (compound.hasUUID("Id")) {
uUID = compound.getUUID("Id");
}

View File

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 1 Jul 2020 03:12:06 -0400
Subject: [PATCH] Clean up duplicated GameProfile Properties
We had a bug where we accidently cloned properties resulting in skulls
growing to large sizes and preventing login.
This now automatically cleans up the extra properties.
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index dc136cd4d5d4ba1e0e53a7187b3a2e836e185c19..1a9435a55e20170244497be70d86d989a4e0f78f 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -93,7 +93,8 @@ public final class NbtUtils {
for(String string2 : compoundTag.getAllKeys()) {
ListTag listTag = compoundTag.getList(string2, 10);
- for(int i = 0; i < listTag.size(); ++i) {
+ if (listTag.size() == 0) continue; // Paper - remove duplicate properties
+ for (int i = listTag.size() - 1; i < listTag.size(); ++i) { // Paper - remove duplicate properties
CompoundTag compoundTag2 = listTag.getCompound(i);
String string3 = compoundTag2.getString("Value");
if (compoundTag2.contains("Signature", 8)) {
diff --git a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
index 7fb2cc8d49a2d8f256f625cb99b66ef8efc3fc0e..f9980110a4614bb0206dce3dc796d9459069b750 100644
--- a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
+++ b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
@@ -53,6 +53,18 @@ public class PlayerHeadItem extends StandingAndWallBlockItem {
});
// CraftBukkit start
} else {
+ // Paper start - clean up old duplicated properties
+ CompoundTag properties = nbt.getCompound("SkullOwner").getCompound("Properties");
+ for (String key : properties.getAllKeys()) {
+ net.minecraft.nbt.ListTag values = properties.getList(key, 10);
+ if (values.size() > 1) {
+ net.minecraft.nbt.Tag texture = values.get(values.size() - 1);
+ values = new net.minecraft.nbt.ListTag();
+ values.add(texture);
+ properties.put(key, values);
+ }
+ }
+ // Paper end
net.minecraft.nbt.ListTag textures = nbt.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
for (int i = 0; i < textures.size(); i++) {
if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).contains("Signature", 8) && ((CompoundTag) textures.get(i)).getString("Value").trim().isEmpty()) {