This commit is contained in:
Jason Penilla
2021-06-11 20:07:57 -07:00
parent 25eea26621
commit 961d6d7dac
10 changed files with 94 additions and 214 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
}
}
}
+ // 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,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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ 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,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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity implements TickableBlockEntity
}
- @Override
+ // Paper - remove override
public void tick() {
BlockState iblockdata = this.getBlockState();

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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
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,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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -0,0 +0,0 @@ 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,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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/util/BitStorage.java
+++ b/src/main/java/net/minecraft/util/BitStorage.java
@@ -0,0 +0,0 @@ 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) {
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ 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 <1254957+zachbr@users.noreply.github.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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ 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,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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
}
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");
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
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();
@@ -0,0 +0,0 @@ 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);
}
@@ -0,0 +0,0 @@ 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();
}
@@ -0,0 +0,0 @@ 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());
}
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ 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,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <1254957+zachbr@users.noreply.github.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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
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);