This commit is contained in:
Jason Penilla 2021-06-11 20:07:57 -07:00
parent c56800c6fb
commit d43c31d141
No known key found for this signature in database
GPG key ID: 0E75A301420E48F8
10 changed files with 106 additions and 105 deletions

View file

@ -1,40 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Sat, 2 Apr 2016 05:09:16 -0400
Subject: [PATCH] Add PlayerUseUnknownEntityEvent
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
index 9ff5b938f97da5ca1f13fd2bcbf3d13e8b8f760c..e1d219550006d22b0a8e949e820488c6ed96dc58 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
@@ -11,7 +11,7 @@ import net.minecraft.world.phys.Vec3;
public class ServerboundInteractPacket implements Packet<ServerGamePacketListener> {
- private int entityId;
+ private int entityId; public int getEntityId() { return this.entityId; } // Paper - add accessor
private ServerboundInteractPacket.Action action;
private Vec3 location;
private InteractionHand hand;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 73683ba59d0aff3a61f555b4ae15753e9e4e6141..e2bfe8e916c9e59af81627ea0ee449970527034d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2198,6 +2198,16 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
}
}
}
+ // Paper start - fire event
+ else {
+ this.craftServer.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
+ this.getPlayer(),
+ packet.getEntityId(),
+ packet.getAction() == ServerboundInteractPacket.Action.ATTACK,
+ packet.getHand() == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
+ ));
+ }
+ // Paper end
}

View file

@ -1,18 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Sat, 2 Apr 2016 20:37:03 -0400
Subject: [PATCH] Fix reducedDebugInfo not initialized on client
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index a63babe123fad398b07685ec57cd88756435457c..aa440a6341a6d30aba8fd5f6bcd122bd5d8760cd 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -242,6 +242,7 @@ public abstract class PlayerList {
playerconnection.send(new ClientboundSetCarriedItemPacket(player.inventory.selected));
playerconnection.send(new ClientboundUpdateRecipesPacket(this.server.getRecipeManager().getRecipes()));
playerconnection.send(new ClientboundUpdateTagsPacket(this.server.getTags()));
+ playerconnection.send(new ClientboundEntityEventPacket(player, (byte) (worldserver1.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23))); // Paper - fix this rule not being initialized on the client
this.sendPlayerPermissionLevel(player);
player.getStats().markAllDirty();
player.getRecipeBook().sendInitialRecipeBook(player);

View file

@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Apr 2016 16:28:17 -0400
Subject: [PATCH] Configurable Grass Spread Tick Rate
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 74ba5dbb83c13ce1721619b755036a7864a1fb90..db2dddd12f54e6d15916c4cee623676541de37fb 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -248,4 +248,10 @@ public class PaperWorldConfig {
}
fixedInhabitedTime = getInt("fixed-chunk-inhabited-time", -1);
}
+
+ public int grassUpdateRate = 1;
+ private void grassUpdateRate() {
+ grassUpdateRate = Math.max(0, getInt("grass-spread-tick-rate", grassUpdateRate));
+ log("Grass Spread Tick Rate: " + grassUpdateRate);
+ }
}
diff --git a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
index d54f097afc455a01486d7f7459b0cfc4ab4f3970..813a5b0598eca28aa173cd6e34bc16381f313604 100644
--- a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.Tag;
@@ -41,6 +42,7 @@ public abstract class SpreadingSnowyDirtBlock extends SnowyDirtBlock {
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
+ if (this instanceof GrassBlock && world.paperConfig.grassUpdateRate != 1 && (world.paperConfig.grassUpdateRate < 1 || (MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig.grassUpdateRate != 0)) { return; } // Paper
if (!canBeGrass(state, (LevelReader) world, pos)) {
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.DIRT.defaultBlockState()).isCancelled()) {

View file

@ -1,18 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Apr 2016 17:48:50 -0400
Subject: [PATCH] Fix Cancelling BlockPlaceEvent triggering physics
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index d47ed15382f98aabd509e32a3c202a91088adf6b..89a6a0b4235cfcc1d3ad68ff59a21fa60df4508f 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -518,6 +518,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public void setBlocksDirty(BlockPos pos, BlockState old, BlockState updated) {}
public void updateNeighborsAt(BlockPos pos, Block block) {
+ if (captureBlockStates) { return; } // Paper - Cancel all physics during placement
this.neighborChanged(pos.west(), block, pos);
this.neighborChanged(pos.east(), block, pos);
this.neighborChanged(pos.below(), block, pos);

View file

@ -1,84 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Apr 2016 21:38:58 -0400
Subject: [PATCH] Optimize DataBits
Remove Debug checks as these are super hot and causing noticeable hits
Before: http://i.imgur.com/nQsMzAE.png
After: http://i.imgur.com/nJ46crB.png
Optimize redundant converting of static fields into an unsigned long each call by precomputing it in ctor
diff --git a/src/main/java/net/minecraft/util/BitStorage.java b/src/main/java/net/minecraft/util/BitStorage.java
index 97bde5f8402452e59b0da94edfe1b970cdb86748..dd84984f28484cf7129c294222696784e128221a 100644
--- a/src/main/java/net/minecraft/util/BitStorage.java
+++ b/src/main/java/net/minecraft/util/BitStorage.java
@@ -13,8 +13,8 @@ public class BitStorage {
private final long mask;
private final int size;
private final int valuesPerLong;
- private final int divideMul;
- private final int divideAdd;
+ private final int divideMul;private final long g_unsigned; // Paper - referenced in b(int) with 2 Integer.toUnsignedLong calls
+ private final int divideAdd;private final long h_unsigned; // Paper
private final int divideShift;
public BitStorage(int elementBits, int size) {
@@ -29,8 +29,8 @@ public class BitStorage {
this.valuesPerLong = (char) (64 / elementBits);
int k = 3 * (this.valuesPerLong - 1);
- this.divideMul = BitStorage.MAGIC[k + 0];
- this.divideAdd = BitStorage.MAGIC[k + 1];
+ this.divideMul = BitStorage.MAGIC[k + 0]; this.g_unsigned = Integer.toUnsignedLong(this.divideMul); // Paper
+ this.divideAdd = BitStorage.MAGIC[k + 1]; this.h_unsigned = Integer.toUnsignedLong(this.divideAdd); // Paper
this.divideShift = BitStorage.MAGIC[k + 2];
int l = (size + this.valuesPerLong - 1) / this.valuesPerLong;
@@ -47,15 +47,15 @@ public class BitStorage {
}
private int cellIndex(int i) {
- long j = Integer.toUnsignedLong(this.divideMul);
- long k = Integer.toUnsignedLong(this.divideAdd);
+ //long j = Integer.toUnsignedLong(this.g); // Paper
+ //long k = Integer.toUnsignedLong(this.h); // Paper
- return (int) ((long) i * j + k >> 32 >> this.divideShift);
+ return (int) ((long) i * this.g_unsigned + this.h_unsigned >> 32 >> this.divideShift); // Paper
}
- public int getAndSet(int index, int value) {
- Validate.inclusiveBetween(0L, (long) (this.size - 1), (long) index);
- Validate.inclusiveBetween(0L, this.mask, (long) value);
+ public final int getAndSet(int index, int value) { // Paper - make final for inline
+ //Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i); // Paper
+ //Validate.inclusiveBetween(0L, this.d, (long) j); // Paper
int k = this.cellIndex(index);
long l = this.data[k];
int i1 = (index - k * this.valuesPerLong) * this.bits;
@@ -65,9 +65,9 @@ public class BitStorage {
return j1;
}
- public void set(int index, int value) {
- Validate.inclusiveBetween(0L, (long) (this.size - 1), (long) index);
- Validate.inclusiveBetween(0L, this.mask, (long) value);
+ public final void set(int index, int value) { // Paper - make final for inline
+ //Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i); // Paper
+ //Validate.inclusiveBetween(0L, this.d, (long) j); // Paper
int k = this.cellIndex(index);
long l = this.data[k];
int i1 = (index - k * this.valuesPerLong) * this.bits;
@@ -75,8 +75,8 @@ public class BitStorage {
this.data[k] = l & ~(this.mask << i1) | ((long) value & this.mask) << i1;
}
- public int get(int index) {
- Validate.inclusiveBetween(0L, (long) (this.size - 1), (long) index);
+ public final int get(int index) { // Paper - make final for inline
+ //Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i); // Paper
int j = this.cellIndex(index);
long k = this.data[j];
int l = (index - j * this.valuesPerLong) * this.bits;

View file

@ -1,66 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Wed, 6 Apr 2016 01:04:23 -0500
Subject: [PATCH] Option to use vanilla per-world scoreboard coloring on names
This change is basically a bandaid to fix CB's complete and utter lack
of support for vanilla scoreboard name modifications.
In the future, finding a way to merge the vanilla expectations in with
bukkit's concept of a display name would be preferable. There was a PR
for this on CB at one point but I can't find it. We may need to do this
ourselves at some point in the future.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index db2dddd12f54e6d15916c4cee623676541de37fb..1942f5224aaebb18adb591d6f70a419cfc1a7bdd 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -254,4 +254,9 @@ public class PaperWorldConfig {
grassUpdateRate = Math.max(0, getInt("grass-spread-tick-rate", grassUpdateRate));
log("Grass Spread Tick Rate: " + grassUpdateRate);
}
+
+ public boolean useVanillaScoreboardColoring;
+ private void useVanillaScoreboardColoring() {
+ useVanillaScoreboardColoring = getBoolean("use-vanilla-world-scoreboard-name-coloring", false);
+ }
}
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
index a29b6aaafd529e56a83dd96c32211f21e4aad348..2039f83a718427d0969a1a2e2200f7922097449e 100644
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
@@ -16,7 +16,11 @@ import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.event.ClickEvent;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.world.scores.PlayerTeam;
+import net.minecraft.world.scores.Team;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.util.LazyPlayerSet;
import org.bukkit.craftbukkit.util.Waitable;
@@ -178,10 +182,22 @@ public final class ChatProcessor {
}
private static String legacyDisplayName(final CraftPlayer player) {
+ if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) {
+ final ServerPlayer ep = player.getHandle();
+ net.minecraft.network.chat.Component name = ep.getName();
+ final Team team = ep.getTeam();
+ if (team != null) {
+ name = team.getFormattedName(name);
+ }
+ return PaperAdventure.LEGACY_SECTION_UXRC.serialize(PaperAdventure.asAdventure(name)) + ChatColor.RESET;
+ }
return player.getDisplayName();
}
private static Component displayName(final CraftPlayer player) {
+ if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) {
+ return PaperAdventure.asAdventure(PlayerTeam.formatNameForTeam(player.getHandle().getTeam(), player.getHandle().getName()));
+ }
return player.displayName();
}

View file

@ -1,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sun, 10 Apr 2016 03:23:32 -0500
Subject: [PATCH] Workaround for setting passengers on players
SPIGOT-1915 & GH-114
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index b7d5a718375083a4162df4bb41de3acd57b297fb..b264cbe5f91da9e31c5fd00ee285735a19aaad35 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -870,6 +870,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return true;
}
+ // Paper start - Ugly workaround for SPIGOT-1915 & GH-114
+ @Override
+ public boolean setPassenger(org.bukkit.entity.Entity passenger) {
+ boolean wasSet = super.setPassenger(passenger);
+ if (wasSet) {
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSetPassengersPacket(this.getHandle()));
+ }
+ return wasSet;
+ }
+ // Paper end
+
@Override
public void setSneaking(boolean sneak) {
getHandle().setShiftKeyDown(sneak);

View file

@ -1,90 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 13 Apr 2016 00:25:28 -0400
Subject: [PATCH] Remove unused World Tile Entity List
Massive hit to performance and it is completely unnecessary.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f7eddb39985072afeb79ec0cbfc084d7e84638e6..bb99d9fe5e274318d8480a6de2c45b0a57351f77 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1715,7 +1715,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
}
bufferedwriter.write(String.format("entities: %d\n", this.entitiesById.size()));
- bufferedwriter.write(String.format("block_entities: %d\n", this.blockEntityList.size()));
+ bufferedwriter.write(String.format("block_entities: %d\n", this.tickableBlockEntities.size())); // Paper - remove unused list
bufferedwriter.write(String.format("block_ticks: %d\n", this.getBlockTicks().size()));
bufferedwriter.write(String.format("fluid_ticks: %d\n", this.getLiquidTicks().size()));
bufferedwriter.write("distance_manager: " + playerchunkmap.getDistanceManager().getDebugStatus() + "\n");
@@ -1854,7 +1854,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
private void dumpBlockEntities(Writer writer) throws IOException {
CsvOutput csvwriter = CsvOutput.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("type").build(writer);
- Iterator iterator = this.blockEntityList.iterator();
+ Iterator iterator = this.tickableBlockEntities.iterator(); // Paper - remove unused list
while (iterator.hasNext()) {
BlockEntity tileentity = (BlockEntity) iterator.next();
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 89a6a0b4235cfcc1d3ad68ff59a21fa60df4508f..8f0fec38b482465285057d3fd27d456cf036f2fd 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -91,7 +91,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public static final ResourceKey<Level> NETHER = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("the_nether"));
public static final ResourceKey<Level> END = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("the_end"));
private static final Direction[] DIRECTIONS = Direction.values();
- public final List<BlockEntity> blockEntityList = Lists.newArrayList();
+ //public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
public final List<BlockEntity> tickableBlockEntities = Lists.newArrayList();
protected final List<BlockEntity> pendingBlockEntities = Lists.newArrayList();
protected final java.util.Set<BlockEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet();
@@ -683,9 +683,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}, blockEntity::getBlockPos});
}
- boolean flag = this.blockEntityList.add(blockEntity);
+ boolean flag = true; // Paper - remove unused list
- if (flag && blockEntity instanceof TickableBlockEntity) {
+ if (flag && blockEntity instanceof TickableBlockEntity && !this.tickableBlockEntities.contains(blockEntity)) { // Paper
this.tickableBlockEntities.add(blockEntity);
}
@@ -721,7 +721,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
timings.tileEntityTick.startTiming(); // Spigot
if (!this.tileEntityListUnload.isEmpty()) {
this.tickableBlockEntities.removeAll(this.tileEntityListUnload);
- this.blockEntityList.removeAll(this.tileEntityListUnload);
+ //this.tileEntityList.removeAll(this.tileEntityListUnload); // Paper - remove unused list
this.tileEntityListUnload.clear();
}
@@ -781,7 +781,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
tilesThisCycle--;
this.tickableBlockEntities.remove(tileTickPosition--);
// Spigot end
- this.blockEntityList.remove(tileentity);
+ //this.tileEntityList.remove(tileentity); // Paper - remove unused list
if (this.hasChunkAt(tileentity.getBlockPos())) {
this.getChunkAt(tileentity.getBlockPos()).removeBlockEntity(tileentity.getBlockPos());
}
@@ -811,7 +811,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
this.sendBlockUpdated(tileentity1.getBlockPos(), iblockdata, iblockdata, 3);
// CraftBukkit start
// From above, don't screw this up - SPIGOT-1746
- if (!this.blockEntityList.contains(tileentity1)) {
+ if (true) { // Paper - remove unused list
this.addBlockEntity(tileentity1);
}
// CraftBukkit end
@@ -957,7 +957,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
} else {
if (tileentity != null) {
this.pendingBlockEntities.remove(tileentity);
- this.blockEntityList.remove(tileentity);
+ //this.tileEntityList.remove(tileentity); // Paper - remove unused list
this.tickableBlockEntities.remove(tileentity);
}

View file

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 13 Apr 2016 00:30:10 -0400
Subject: [PATCH] Don't tick Skulls - unused code
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
index 6a46517e4026971d8c050c685c710883b5976fa3..eebaeaccc3ba1a9ec089d84b8de6c9d36034868f 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
@@ -31,7 +31,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.players.GameProfileCache;
import net.minecraft.util.StringUtil;
-public class SkullBlockEntity extends BlockEntity implements TickableBlockEntity {
+public class SkullBlockEntity extends BlockEntity /*implements ITickable*/ { // Paper - remove tickable
@Nullable
private static GameProfileCache profileCache;
@@ -134,7 +134,7 @@ public class SkullBlockEntity extends BlockEntity implements TickableBlockEntity
}
- @Override
+ // Paper - remove override
public void tick() {
BlockState iblockdata = this.getBlockState();