Paper/Spigot-Server-Patches/0003-MC-Dev-fixes.patch
Spottedleaf 33a5a0f84e
Optimize GameRules to use LinkedHashMap
Previously TreeMap was used which has poor get(K) performance.
2019-04-05 23:25:12 -04:00

290 lines
14 KiB
Diff

From 30a67e448eb304db37ace97ac0cc0f1347cd5bb6 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 30 Mar 2016 19:36:20 -0400
Subject: [PATCH] MC Dev fixes
diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java
index bcb4b5e5c..c399bdecc 100644
--- a/src/main/java/net/minecraft/server/BiomeBase.java
+++ b/src/main/java/net/minecraft/server/BiomeBase.java
@@ -124,7 +124,7 @@ public abstract class BiomeBase {
@Nullable
public static BiomeBase a(BiomeBase biomebase) {
- return (BiomeBase) BiomeBase.aH.fromId(IRegistry.BIOME.a((Object) biomebase));
+ return (BiomeBase) BiomeBase.aH.fromId(IRegistry.BIOME.a(biomebase)); // Paper - decompile fix
}
public static <C extends WorldGenFeatureConfiguration> WorldGenCarverWrapper<C> a(WorldGenCarver<C> worldgencarver, C c0) {
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index 16bca7942..13dc7abc5 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger;
@Immutable
public class BlockPosition extends BaseBlockPosition {
- private static final Logger b = LogManager.getLogger();
+ //private static final Logger b = LogManager.getLogger(); // Paper - variable name conflict, logger isn't used
public static final BlockPosition ZERO = new BlockPosition(0, 0, 0);
private static final int c = 1 + MathHelper.e(MathHelper.c(30000000));
private static final int d = BlockPosition.c;
@@ -147,7 +147,7 @@ public class BlockPosition extends BaseBlockPosition {
return a(Math.min(blockposition.getX(), blockposition1.getX()), Math.min(blockposition.getY(), blockposition1.getY()), Math.min(blockposition.getZ(), blockposition1.getZ()), Math.max(blockposition.getX(), blockposition1.getX()), Math.max(blockposition.getY(), blockposition1.getY()), Math.max(blockposition.getZ(), blockposition1.getZ()));
}
- public static Iterable<BlockPosition> a(int i, int j, int k, int l, int i1, int j1) {
+ public static Iterable<BlockPosition> a(int ix, int jx, int kx, int l, int i1, int j1) { // Paper - decompile fix
return () -> {
return new AbstractIterator<BlockPosition>() {
private boolean g = true;
@@ -158,21 +158,21 @@ public class BlockPosition extends BaseBlockPosition {
protected BlockPosition computeNext() {
if (this.g) {
this.g = false;
- this.h = i;
- this.i = j;
- this.j = k;
- return new BlockPosition(i, j, k);
+ this.h = ix; // Paper - decompile fix
+ this.i = jx; // Paper - decompile fix
+ this.j = kx; // Paper - decompile fix
+ return new BlockPosition(ix, jx, kx);
} else if (this.h == l && this.i == i1 && this.j == j1) {
return (BlockPosition) this.endOfData();
} else {
if (this.h < l) {
++this.h;
} else if (this.i < i1) {
- this.h = i;
+ this.h = ix; // Paper - decompile fix
++this.i;
} else if (this.j < j1) {
- this.h = i;
- this.i = j;
+ this.h = ix; // Paper - decompile fix
+ this.i = jx; // Paper - decompile fix
++this.j;
}
@@ -206,8 +206,11 @@ public class BlockPosition extends BaseBlockPosition {
if (this.g.b < l) {
++this.g.b;
} else if (this.g.c < i1) {
+ this.g.b = i; // Paper - decompile fix Readd line removed by the decompiler
++this.g.c;
} else if (this.g.d < j1) {
+ this.g.b = i; // Paper - decompile fix Readd line removed by the decompiler
+ this.g.c = j; // Paper - decompile fix Readd line removed by the decompiler
++this.g.d;
}
diff --git a/src/main/java/net/minecraft/server/BlockStateEnum.java b/src/main/java/net/minecraft/server/BlockStateEnum.java
index 401b6d970..986b9ccea 100644
--- a/src/main/java/net/minecraft/server/BlockStateEnum.java
+++ b/src/main/java/net/minecraft/server/BlockStateEnum.java
@@ -20,10 +20,10 @@ public class BlockStateEnum<T extends Enum<T> & INamable> extends BlockState<T>
protected BlockStateEnum(String s, Class<T> oclass, Collection<T> collection) {
super(s, oclass);
this.a = ImmutableSet.copyOf(collection);
- Iterator iterator = collection.iterator();
+ Iterator<T> iterator = collection.iterator(); // Paper - decompile fix
while (iterator.hasNext()) {
- T t0 = (Enum) iterator.next();
+ T t0 = iterator.next(); // Paper - Decompile fix
String s1 = ((INamable) t0).getName();
if (this.b.containsKey(s1)) {
diff --git a/src/main/java/net/minecraft/server/DefinedStructure.java b/src/main/java/net/minecraft/server/DefinedStructure.java
index 66b168396..83db94c4a 100644
--- a/src/main/java/net/minecraft/server/DefinedStructure.java
+++ b/src/main/java/net/minecraft/server/DefinedStructure.java
@@ -85,7 +85,7 @@ public class DefinedStructure {
}
private void a(World world, BlockPosition blockposition, BlockPosition blockposition1) {
- List<Entity> list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (entity) -> {
+ List<Entity> list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (java.util.function.Predicate<? super Entity>) (entity) -> { // Paper - decompile fix
return !(entity instanceof EntityHuman);
});
@@ -235,7 +235,7 @@ public class DefinedStructure {
boolean flag = true;
EnumDirection[] aenumdirection = new EnumDirection[] { EnumDirection.UP, EnumDirection.NORTH, EnumDirection.EAST, EnumDirection.SOUTH, EnumDirection.WEST};
- int l1;
+ //int l1; // Paper - decompile fix
while (flag && !list1.isEmpty()) {
flag = false;
@@ -245,7 +245,7 @@ public class DefinedStructure {
BlockPosition blockposition2 = (BlockPosition) iterator1.next();
Fluid fluid1 = generatoraccess.getFluid(blockposition2);
- for (l1 = 0; l1 < aenumdirection.length && !fluid1.d(); ++l1) {
+ for (int l1 = 0; l1 < aenumdirection.length && !fluid1.d(); ++l1) { // Paper - decompile fix
Fluid fluid2 = generatoraccess.getFluid(blockposition2.shift(aenumdirection[l1]));
if (fluid2.getHeight() > fluid1.getHeight() || fluid2.d() && !fluid1.d()) {
@@ -270,7 +270,7 @@ public class DefinedStructure {
int i2 = j;
int j2 = k;
- l1 = l;
+ int l1 = l; // Paper - decompile fix
Iterator iterator2 = list2.iterator();
Pair pair;
@@ -717,7 +717,7 @@ public class DefinedStructure {
public IBlockData a(int i) {
IBlockData iblockdata = (IBlockData) this.b.fromId(i);
- return iblockdata == null ? DefinedStructure.a.a : iblockdata;
+ return iblockdata == null ? a : iblockdata; // Paper - decompile fix
}
public Iterator<IBlockData> iterator() {
diff --git a/src/main/java/net/minecraft/server/GameRules.java b/src/main/java/net/minecraft/server/GameRules.java
index d954b94c3..fd2a4f1b8 100644
--- a/src/main/java/net/minecraft/server/GameRules.java
+++ b/src/main/java/net/minecraft/server/GameRules.java
@@ -17,7 +17,7 @@ import javax.annotation.Nullable;
public class GameRules {
- private static final TreeMap<String, GameRules.GameRuleDefinition> a = (TreeMap) SystemUtils.a((Object) (new TreeMap()), (treemap) -> {
+ private static final TreeMap<String, GameRules.GameRuleDefinition> a = SystemUtils.a(new TreeMap(), (treemap) -> { // Paper - decompile fix
treemap.put("doFireTick", new GameRules.GameRuleDefinition("true", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
treemap.put("mobGriefing", new GameRules.GameRuleDefinition("true", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
treemap.put("keepInventory", new GameRules.GameRuleDefinition("false", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
@@ -133,7 +133,7 @@ public class GameRules {
private final Supplier<ArgumentType<?>> d;
private final BiFunction<CommandContext<CommandListenerWrapper>, String, String> e;
- private EnumGameRuleType(Supplier supplier, BiFunction bifunction) {
+ private EnumGameRuleType(Supplier supplier, BiFunction<CommandContext<CommandListenerWrapper>, String, String> bifunction) { // Paper - decompile fix
this.d = supplier;
this.e = bifunction;
}
diff --git a/src/main/java/net/minecraft/server/NBTBase.java b/src/main/java/net/minecraft/server/NBTBase.java
index 1425584ed..b2757aad8 100644
--- a/src/main/java/net/minecraft/server/NBTBase.java
+++ b/src/main/java/net/minecraft/server/NBTBase.java
@@ -88,7 +88,7 @@ public interface NBTBase {
}
}
- NBTBase clone();
+ public NBTBase clone(); // Paper - decompile fix
default String asString() {
return this.toString();
diff --git a/src/main/java/net/minecraft/server/NBTTagByteArray.java b/src/main/java/net/minecraft/server/NBTTagByteArray.java
index 767013cae..e0fb6fb49 100644
--- a/src/main/java/net/minecraft/server/NBTTagByteArray.java
+++ b/src/main/java/net/minecraft/server/NBTTagByteArray.java
@@ -66,7 +66,8 @@ public class NBTTagByteArray extends NBTList<NBTTagByte> {
return stringbuilder.append(']').toString();
}
- public NBTBase clone() {
+ @Override
+ public NBTTagByteArray clone() { // Paper - decompile fix
byte[] abyte = new byte[this.data.length];
System.arraycopy(this.data, 0, abyte, 0, this.data.length);
diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java
index 2b7b8be8a..27debcfca 100644
--- a/src/main/java/net/minecraft/server/NBTTagList.java
+++ b/src/main/java/net/minecraft/server/NBTTagList.java
@@ -14,7 +14,7 @@ import org.apache.logging.log4j.Logger;
public class NBTTagList extends NBTList<NBTBase> {
private static final Logger f = LogManager.getLogger();
- private List<NBTBase> list = Lists.newArrayList();
+ public List<NBTBase> list = Lists.newArrayList(); // Paper
private byte type = 0;
public NBTTagList() {}
diff --git a/src/main/java/net/minecraft/server/Registry.java b/src/main/java/net/minecraft/server/Registry.java
index 723372f26..9efec49d6 100644
--- a/src/main/java/net/minecraft/server/Registry.java
+++ b/src/main/java/net/minecraft/server/Registry.java
@@ -1,3 +1,8 @@
package net.minecraft.server;
-public interface Registry extends Iterable {}
+import java.util.Iterator;
+public interface Registry<T> extends Iterable<T> { // Paper - decompile fix
+
+ @Override
+ Iterator<T> iterator(); // Paper - decompile fix
+}
diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java
index 50410264f..a894f7886 100644
--- a/src/main/java/net/minecraft/server/RegistryBlockID.java
+++ b/src/main/java/net/minecraft/server/RegistryBlockID.java
@@ -27,7 +27,7 @@ public class RegistryBlockID<T> implements Registry<T> {
this.b.put(t0, i);
while (this.c.size() <= i) {
- this.c.add((Object) null);
+ this.c.add(null); // Paper - decompile fix
}
this.c.set(i, t0);
diff --git a/src/main/java/net/minecraft/server/RegistryID.java b/src/main/java/net/minecraft/server/RegistryID.java
index 9400a4369..5a5c464ea 100644
--- a/src/main/java/net/minecraft/server/RegistryID.java
+++ b/src/main/java/net/minecraft/server/RegistryID.java
@@ -17,9 +17,9 @@ public class RegistryID<K> implements Registry<K> {
public RegistryID(int i) {
i = (int) ((float) i / 0.8F);
- this.b = (Object[]) (new Object[i]);
+ this.b = (K[]) (new Object[i]); // Paper - decompile fix
this.c = new int[i];
- this.d = (Object[]) (new Object[i]);
+ this.d = (K[]) (new Object[i]); // Paper - decompile fix
}
public int getId(@Nullable K k0) {
@@ -54,9 +54,9 @@ public class RegistryID<K> implements Registry<K> {
K[] ak = this.b;
int[] aint = this.c;
- this.b = (Object[]) (new Object[i]);
+ this.b = (K[]) (new Object[i]); // Paper - decompile fix
this.c = new int[i];
- this.d = (Object[]) (new Object[i]);
+ this.d = (K[]) (new Object[i]); // Paper - decompile fix
this.e = 0;
this.f = 0;
diff --git a/src/main/java/net/minecraft/server/WorldPersistentData.java b/src/main/java/net/minecraft/server/WorldPersistentData.java
index c01a05b25..478bf4997 100644
--- a/src/main/java/net/minecraft/server/WorldPersistentData.java
+++ b/src/main/java/net/minecraft/server/WorldPersistentData.java
@@ -39,14 +39,14 @@ public class WorldPersistentData {
@Nullable
public <T extends PersistentBase> T a(Function<String, T> function, String s) {
- PersistentBase persistentbase = (PersistentBase) this.data.get(s);
+ T persistentbase = (T) this.data.get(s); // Paper - decompile fix
if (persistentbase == null && this.e != null) {
try {
File file = this.e.getDataFile(this.b, s);
if (file != null && file.exists()) {
- persistentbase = (PersistentBase) function.apply(s);
+ persistentbase = function.apply(s); // Paper - decompile fix
persistentbase.a(a(this.e, this.b, s, 1631).getCompound("data"));
this.data.put(s, persistentbase);
}
--
2.21.0