More work

This commit is contained in:
Nassim Jahnke
2021-11-23 12:27:39 +01:00
parent c46b20492e
commit e70c4bc478
17 changed files with 28 additions and 39 deletions

View File

@@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity {
if (entityhuman != null) { if (entityhuman != null) {
double d0 = entityhuman.distanceToSqr((Entity) this); // CraftBukkit - decompile error double d0 = entityhuman.distanceToSqr((Entity) this);
- int i = this.getType().getCategory().getDespawnDistance(); - int i = this.getType().getCategory().getDespawnDistance();
+ int i = this.level.paperConfig.hardDespawnDistances.getInt(this.getType().getCategory()); // Paper - custom despawn distances + int i = this.level.paperConfig.hardDespawnDistances.getInt(this.getType().getCategory()); // Paper - custom despawn distances
int j = i * i; int j = i * i;

View File

@@ -1036,9 +1036,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
+import io.papermc.paper.adventure.PaperAdventure; // Paper +import io.papermc.paper.adventure.PaperAdventure; // Paper
import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { @@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf {
private static final int MAX_VARLONG_SIZE = 10; private static final int MAX_VARLONG_SIZE = 10;
private static final int DEFAULT_NBT_QUOTA = 2097152; private static final int DEFAULT_NBT_QUOTA = 2097152;
@@ -1247,8 +1247,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.world.scores.criteria.ObjectiveCriteria; import net.minecraft.world.scores.criteria.ObjectiveCriteria;
+import io.papermc.paper.adventure.PaperAdventure; // Paper +import io.papermc.paper.adventure.PaperAdventure; // Paper
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.WeatherType;
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
// CraftBukkit start // CraftBukkit start
@@ -1290,7 +1290,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (deathMessage != null && deathMessage != net.kyori.adventure.text.Component.empty() && flag) { // Paper - Adventure // TODO: allow plugins to override? + if (deathMessage != null && deathMessage != net.kyori.adventure.text.Component.empty() && flag) { // Paper - Adventure // TODO: allow plugins to override?
+ Component ichatbasecomponent = PaperAdventure.asVanilla(deathMessage); // Paper - Adventure + Component ichatbasecomponent = PaperAdventure.asVanilla(deathMessage); // Paper - Adventure
this.connection.send((Packet) (new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent)), (future) -> { this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> {
if (!future.isSuccess()) { if (!future.isSuccess()) {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
} }
@@ -1299,7 +1299,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public java.util.Locale adventure$locale = java.util.Locale.US; // Paper + public java.util.Locale adventure$locale = java.util.Locale.US; // Paper
public void updateOptions(ServerboundClientInformationPacket packet) { public void updateOptions(ServerboundClientInformationPacket packet) {
// CraftBukkit start // CraftBukkit start
if (getMainArm() != packet.getMainHand()) { if (getMainArm() != packet.mainHand()) {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
this.server.server.getPluginManager().callEvent(event); this.server.server.getPluginManager().callEvent(event);
} }
@@ -1310,7 +1310,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end + // Paper end
this.clientViewDistance = packet.viewDistance; this.clientViewDistance = packet.viewDistance;
// CraftBukkit end // CraftBukkit end
this.chatVisibility = packet.getChatVisibility(); this.chatVisibility = packet.chatVisibility();
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1371,11 +1371,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
*/ */
this.player.disconnect(); this.player.disconnect();
- String quitMessage = this.server.getPlayerList().disconnect(this.player); - String quitMessage = this.server.getPlayerList().remove(this.player);
- if ((quitMessage != null) && (quitMessage.length() > 0)) { - if ((quitMessage != null) && (quitMessage.length() > 0)) {
- this.server.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); - this.server.getPlayerList().broadcastMessage(CraftChatMessage.fromString(quitMessage));
+ // Paper start - Adventure + // Paper start - Adventure
+ net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().disconnect(this.player); + net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().remove(this.player);
+ if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) { + if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
+ this.server.getPlayerList().broadcastMessage(PaperAdventure.asVanilla(quitMessage), ChatType.SYSTEM, Util.NIL_UUID); + this.server.getPlayerList().broadcastMessage(PaperAdventure.asVanilla(quitMessage), ChatType.SYSTEM, Util.NIL_UUID);
+ // Paper end + // Paper end
@@ -1542,8 +1542,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- public String disconnect(ServerPlayer entityplayer) { // CraftBukkit - return string - public String remove(ServerPlayer entityplayer) { // CraftBukkit - return string
+ public net.kyori.adventure.text.Component disconnect(ServerPlayer entityplayer) { // Paper - return Component + public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // Paper - return Component
ServerLevel worldserver = entityplayer.getLevel(); ServerLevel worldserver = entityplayer.getLevel();
entityplayer.awardStat(Stats.LEAVE_GAME); entityplayer.awardStat(Stats.LEAVE_GAME);
@@ -1585,7 +1585,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure
} else { } else {
// return this.players.size() >= this.maxPlayers && !this.d(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) { if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
- event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot - event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure + event.disallow(PlayerLoginEvent.Result.KICK_FULL, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
@@ -1706,8 +1706,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
+import io.papermc.paper.adventure.PaperAdventure; // Paper +import io.papermc.paper.adventure.PaperAdventure; // Paper
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;
@@ -0,0 +0,0 @@ public class MapItemSavedData extends SavedData { @@ -0,0 +0,0 @@ public class MapItemSavedData extends SavedData {
for (org.bukkit.map.MapCursor cursor : render.cursors) { for (org.bukkit.map.MapCursor cursor : render.cursors) {
@@ -2542,7 +2542,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public int getPing() { public int getPing() {
return this.getHandle().latency; return this.getHandle().latency;
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getInventory().setItemInMainHand(hand); return this.getHandle().allowsListing();
} }
+ // Paper start + // Paper start
@@ -2733,7 +2733,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.adventure$pointers; + return this.adventure$pointers;
+ } + }
+ // Paper end + // Paper end
+
// Spigot start // Spigot start
private final Player.Spigot spigot = new Player.Spigot() private final Player.Spigot spigot = new Player.Spigot()
{ {

View File

@@ -22,7 +22,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
return this.isInWater() || this.isInRain(); return this.isInWater() || this.isInRain();
} }
@@ -40,8 +40,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public GoalSelector goalSelector; public GoalSelector goalSelector;
+ @Nullable public net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper + @Nullable public net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper
public GoalSelector targetSelector; public GoalSelector targetSelector;
@Nullable
private LivingEntity target; private LivingEntity target;
private final Sensing sensing;
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity {
@Override @Override
protected final void serverAiStep() { protected final void serverAiStep() {

View File

@@ -34,11 +34,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/level/block/BambooBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BambooBlock.java
@@ -0,0 +0,0 @@ public class BambooBlock extends Block implements BonemealableBlock { @@ -0,0 +0,0 @@ public class BambooBlock extends Block implements BonemealableBlock {
if (random.nextInt(Math.max(1, (int) (100.0F / world.spigotConfig.bambooModifier) * 3)) == 0 && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) { // Spigot if (random.nextInt(Math.max(1, (int) (100.0F / world.spigotConfig.bambooModifier) * 3)) == 0 && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) { // Spigot
int i = this.getHeightBelowUpToMax((BlockGetter) world, pos) + 1; int i = this.getHeightBelowUpToMax(world, pos) + 1;
- if (i < 16) { - if (i < 16) {
+ if (i < world.paperConfig.bambooMaxHeight) { // Paper + if (i < world.paperConfig.bambooMaxHeight) { // Paper
this.growBamboo(state, (Level) world, pos, random, i); this.growBamboo(state, world, pos, random, i);
} }
} }
@@ -0,0 +0,0 @@ public class BambooBlock extends Block implements BonemealableBlock { @@ -0,0 +0,0 @@ public class BambooBlock extends Block implements BonemealableBlock {

View File

@@ -733,16 +733,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import it.unimi.dsi.fastutil.longs.LongIterator; +import it.unimi.dsi.fastutil.longs.LongIterator;
+import it.unimi.dsi.fastutil.shorts.Short2LongOpenHashMap; +import it.unimi.dsi.fastutil.shorts.Short2LongOpenHashMap;
+import java.util.Arrays; +import java.util.Arrays;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.GlobalPalette; +import net.minecraft.world.level.chunk.GlobalPalette;
+import net.minecraft.world.level.chunk.LevelChunkSection;
+ +
+/** +/**
+ * @author Spottedleaf + * @author Spottedleaf
+ */ + */
+public final class IBlockDataList { +public final class IBlockDataList {
+ +
+ static final GlobalPalette<BlockState> GLOBAL_PALETTE = (GlobalPalette) LevelChunkSection.GLOBAL_BLOCKSTATE_PALETTE; + static final GlobalPalette<BlockState> GLOBAL_PALETTE = new GlobalPalette<>(Block.BLOCK_STATE_REGISTRY);
+ +
+ // map of location -> (index | (location << 16) | (palette id << 32)) + // map of location -> (index | (location << 16) | (palette id << 32))
+ private final Short2LongOpenHashMap map = new Short2LongOpenHashMap(2, 0.8f); + private final Short2LongOpenHashMap map = new Short2LongOpenHashMap(2, 0.8f);
@@ -5382,6 +5382,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.LevelData;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
+import java.util.function.Function; // Paper
public class ServerChunkCache extends ChunkSource { public class ServerChunkCache extends ChunkSource {
+ public static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper + public static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper

View File

@@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/EntitySelector.java --- a/src/main/java/net/minecraft/world/entity/EntitySelector.java
+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java +++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java
@@ -0,0 +0,0 @@ public final class EntitySelector { @@ -0,0 +0,0 @@ public final class EntitySelector {
}; public static final Predicate<Entity> CAN_BE_COLLIDED_WITH = EntitySelector.NO_SPECTATORS.and(Entity::canBeCollidedWith);
private EntitySelector() {} private EntitySelector() {}
+ // Paper start + // Paper start
@@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Player entityhuman = this.level.findNearbyPlayer(this, -1.0D, EntitySelector.affectsSpawning); // Paper + Player entityhuman = this.level.findNearbyPlayer(this, -1.0D, EntitySelector.affectsSpawning); // Paper
if (entityhuman != null) { if (entityhuman != null) {
double d0 = entityhuman.distanceToSqr((Entity) this); // CraftBukkit - decompile error double d0 = entityhuman.distanceToSqr((Entity) this);
diff --git a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java diff --git a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java --- a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java

View File

@@ -8,25 +8,13 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -0,0 +0,0 @@ import net.minecraft.world.level.TickList; @@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess {
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.EntityBlock;
+import net.minecraft.world.level.block.SpawnerBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.TickingBlockEntity;
+import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.EuclideanGameEventDispatcher;
import net.minecraft.world.level.gameevent.GameEventDispatcher;
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
} }
// CraftBukkit start // CraftBukkit start
+ // Paper start - Remove invalid mob spawner tile entities + // Paper start - Remove invalid mob spawner tile entities
+ } else if (blockEntity instanceof SpawnerBlockEntity && !(getBlockState(blockposition).getBlock() instanceof SpawnerBlock)) { + } else if (blockEntity instanceof net.minecraft.world.level.block.entity.SpawnerBlockEntity
+ && !(getBlockState(blockposition).getBlock() instanceof net.minecraft.world.level.block.SpawnerBlock)) {
+ this.removeBlockEntity(blockEntity.getBlockPos()); + this.removeBlockEntity(blockEntity.getBlockPos());
+ // Paper end + // Paper end
} else { } else {

View File

@@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/Main.java --- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -0,0 +0,0 @@ public class Main { @@ -0,0 +0,0 @@ public class Main {
deadline.add(Calendar.DAY_OF_YEAR, -28); deadline.add(Calendar.DAY_OF_YEAR, -7);
if (buildDate.before(deadline.getTime())) { if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Error, this build is outdated ***");
- System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); - System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");

View File

@@ -1 +1,2 @@
Add Timings to LevelTicks and EntityTickList Add Timings to LevelTicks and EntityTickList
Check IBlockDataList#GLOBAL_PALETTE