More remapped patches

Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
This commit is contained in:
Mariell Hoversholm 2021-06-11 17:52:05 +02:00
parent ab79a948f5
commit ee3cf8cc09
12 changed files with 253 additions and 684 deletions

View file

@ -1,7 +1,7 @@
plugins {
java
id("com.github.johnrengelman.shadow") version "7.0.0" apply false
id("io.papermc.paperweight.core") version "1.0.0-SNAPSHOT"
id("io.papermc.paperweight.core") version "1.0.0-LOCAL-SNAPSHOT"
}
group = "com.destroystokyo.paper"
@ -36,6 +36,7 @@ subprojects {
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
maven("https://repo.aikar.co/content/groups/aikar")
maven("https://repo.md-5.net/content/repositories/releases/")
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
}

View file

@ -3,6 +3,7 @@ From: Gabriele C <sgdc3.mail@gmail.com>
Date: Fri, 5 Aug 2016 01:03:08 +0200
Subject: [PATCH] Add setting for proxy online mode status
TODO: Add isProxyOnlineMode check to Metrics
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -3,6 +3,7 @@ From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 18 Nov 2018 19:49:56 +0000
Subject: [PATCH] Make the default permission message configurable
TODO: Change the message in PaperCommand
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -1,55 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 4 Jul 2018 02:13:59 -0400
Subject: [PATCH] Store counts for each Entity/Block Entity Type
Opens door for future patches to optimize performance
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/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 @@ public class LevelChunk implements ChunkAccess {
}
// Paper start
+ public final co.aikar.util.Counter<String> entityCounts = new co.aikar.util.Counter<>();
+ public final co.aikar.util.Counter<String> tileEntityCounts = new co.aikar.util.Counter<>();
private class TileEntityHashMap extends java.util.HashMap<BlockPos, BlockEntity> {
@Override
public BlockEntity put(BlockPos key, BlockEntity value) {
BlockEntity replaced = super.put(key, value);
if (replaced != null) {
replaced.setCurrentChunk(null);
+ tileEntityCounts.decrement(replaced.getMinecraftKeyString());
}
if (value != null) {
value.setCurrentChunk(LevelChunk.this);
+ tileEntityCounts.increment(value.getMinecraftKeyString());
}
return replaced;
}
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
BlockEntity removed = super.remove(key);
if (removed != null) {
removed.setCurrentChunk(null);
+ tileEntityCounts.decrement(removed.getMinecraftKeyString());
}
return removed;
}
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
k = this.entitySlices.length - 1;
}
+ if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper
entity.inChunk = true;
entity.setCurrentChunk(this); // Paper
entity.xChunk = this.chunkPos.x;
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
if (!this.entitySlices[section].remove(entity)) {
return;
}
+ entityCounts.decrement(entity.getMinecraftKeyString());
// Paper end
this.entities.remove(entity); // Paper
}

View file

@ -1,171 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 4 Jul 2018 02:10:36 -0400
Subject: [PATCH] Store reference to current Chunk for Entity and Block
Entities
This enables us a fast reference to the entities current chunk instead
of having to look it up by hashmap lookups.
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/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, CommandSource, net.minecraft.s
}
public boolean isChunkLoaded() {
- return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4);
+ return getCurrentChunk() != null;
}
// CraftBukkit end
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
// Paper start
+ public java.lang.ref.WeakReference<net.minecraft.world.level.chunk.LevelChunk> currentChunk = null;
+
+ public void setCurrentChunk(net.minecraft.world.level.chunk.LevelChunk chunk) {
+ this.currentChunk = chunk != null ? new java.lang.ref.WeakReference<>(chunk) : null;
+ }
+ /**
+ * Returns the entities current registered chunk. If the entity is not added to a chunk yet, it will return null
+ */
+ public net.minecraft.world.level.chunk.LevelChunk getCurrentChunk() {
+ final net.minecraft.world.level.chunk.LevelChunk chunk = currentChunk != null ? currentChunk.get() : null;
+ if (chunk != null && chunk.loaded) {
+ return chunk;
+ }
+
+ return !inChunk ? null : ((ServerLevel)level).getChunkSource().getChunkAtIfLoadedMainThreadNoCache(xChunk, zChunk);
+ }
+
private ResourceLocation entityKey;
private String entityKeyString;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -0,0 +0,0 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.LevelChunk;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Supplier;
@@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
getMinecraftKey(); // Try to load if it doesn't exists.
return tileEntityKeyString;
}
+
+ private java.lang.ref.WeakReference<LevelChunk> currentChunk = null;
+ public LevelChunk getCurrentChunk() {
+ final LevelChunk chunk = currentChunk != null ? currentChunk.get() : null;
+ return chunk != null && chunk.loaded ? chunk : null;
+ }
+ public void setCurrentChunk(LevelChunk chunk) {
+ this.currentChunk = chunk != null ? new java.lang.ref.WeakReference<>(chunk) : null;
+ }
// Paper end
@Nullable
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/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 @@ public class LevelChunk implements ChunkAccess {
this(world, pos, biomes, UpgradeData.EMPTY, EmptyTickList.empty(), EmptyTickList.empty(), 0L, (LevelChunkSection[]) null, (Consumer) null);
}
+ // Paper start
+ private class TileEntityHashMap extends java.util.HashMap<BlockPos, BlockEntity> {
+ @Override
+ public BlockEntity put(BlockPos key, BlockEntity value) {
+ BlockEntity replaced = super.put(key, value);
+ if (replaced != null) {
+ replaced.setCurrentChunk(null);
+ }
+ if (value != null) {
+ value.setCurrentChunk(LevelChunk.this);
+ }
+ return replaced;
+ }
+
+ @Override
+ public BlockEntity remove(Object key) {
+ BlockEntity removed = super.remove(key);
+ if (removed != null) {
+ removed.setCurrentChunk(null);
+ }
+ return removed;
+ }
+ }
+ // Paper end
+
public LevelChunk(Level world, ChunkPos pos, ChunkBiomeContainer biomes, UpgradeData upgradeData, TickList<Block> blockTickScheduler, TickList<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sections, @Nullable Consumer<LevelChunk> loadToWorldConsumer) {
this.sections = new LevelChunkSection[16];
this.pendingBlockEntities = Maps.newHashMap();
this.heightmaps = Maps.newEnumMap(Heightmap.Types.class);
- this.blockEntities = Maps.newHashMap();
+ this.blockEntities = new TileEntityHashMap(); // Paper
this.structureStarts = Maps.newHashMap();
this.structuresRefences = Maps.newHashMap();
this.postProcessing = new ShortList[16];
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
}
entity.inChunk = true;
+ entity.setCurrentChunk(this); // Paper
entity.xChunk = this.chunkPos.x;
entity.yChunk = k;
entity.zChunk = this.chunkPos.z;
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
((Heightmap) this.heightmaps.get(type)).setRawData(heightmap);
}
+ public final void removeEntity(Entity entity) { this.removeEntity(entity); } // Paper - OBFHELPER
public void removeEntity(Entity entity) {
this.removeEntity(entity, entity.yChunk);
}
@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess {
section = this.entitySlices.length - 1;
}
- this.entitySlices[section].remove(entity);
+ // Paper start
+ if (entity.currentChunk != null && entity.currentChunk.get() == this) entity.setCurrentChunk(null);
+ if (!this.entitySlices[section].remove(entity)) {
+ return;
+ }
+ // Paper end
this.entities.remove(entity); // Paper
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -0,0 +0,0 @@ import net.minecraft.world.entity.vehicle.MinecartHopper;
import net.minecraft.world.entity.vehicle.MinecartSpawner;
import net.minecraft.world.entity.vehicle.MinecartTNT;
import net.minecraft.world.phys.AABB;
+import org.bukkit.Chunk; // Paper
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
this.entity = entity;
}
+ @Override
+ public Chunk getChunk() {
+ net.minecraft.world.level.chunk.LevelChunk currentChunk = entity.getCurrentChunk();
+ return currentChunk != null ? currentChunk.bukkitChunk : getLocation().getChunk();
+ }
+
public static CraftEntity getEntity(CraftServer server, Entity entity) {
/*
* Order is *EXTREMELY* important -- keep it right! =D

View file

@ -28,6 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import net.minecraft.resources.ResourceLocation;
+
+// TODO(Mariell Hoversholm): Move stupid ass class
+public interface KeyedObject {
+ ResourceLocation getMinecraftKey();
+ default String getMinecraftKeyString() {
@ -43,12 +44,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.plugin.PluginManager;
// CraftBukkit end
-public abstract class Entity implements Nameable, CommandSource {
+public abstract class Entity implements Nameable, CommandSource, net.minecraft.server.KeyedObject { // Paper
-public abstract class Entity implements Nameable, EntityAccess, CommandSource {
+public abstract class Entity implements Nameable, EntityAccess, CommandSource, net.minecraft.server.KeyedObject { // Paper
// CraftBukkit start
private static final int CURRENT_LEVEL = 2;
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return true;
}
@ -80,12 +81,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
protected abstract void readAdditionalSaveData(CompoundTag tag);
protected abstract void readAdditionalSaveData(CompoundTag nbt);
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -0,0 +0,0 @@ public class EntityType<T extends Entity> {
@@ -0,0 +0,0 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
}
}
@ -114,9 +115,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final BlockEntityType<?> type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER
@Nullable
protected Level level;
protected BlockPos worldPosition;
protected final BlockPos worldPosition;
@@ -0,0 +0,0 @@ public abstract class BlockEntity {
this.type = type;
this.blockState = state;
}
+ // Paper start

View file

@ -722,7 +722,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ /* // Paper - Replace with our own
if ( metrics == null )
if ( SpigotConfig.metrics == null )
{
try
@@ -0,0 +0,0 @@ public class SpigotConfig

View file

@ -1,5 +1,6 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
maven("https://wav.jfrog.io/artifactory/repo/")
}