mirror of https://github.com/YatopiaMC/Yatopia.git
parent
0b9ce71ab6
commit
2b10346ecf
|
@ -12,6 +12,7 @@ This is an overview over all patches that are currently used.
|
|||
| api | Add ChatColor.getById | Aikar | |
|
||||
| api | Add GameProfileLookupEvent | tr7zw | |
|
||||
| server | Add GameProfileLookupEvent | tr7zw | |
|
||||
| server | Add GlueList | Mykyta Komarn | |
|
||||
| server | Add IntelliJ IDEA runnable | Bud Gidiere | |
|
||||
| api | Add NBT API as a first-class lib | tr7zw | |
|
||||
| server | Add NBT API as a first-class lib | tr7zw | |
|
||||
|
@ -137,7 +138,7 @@ This is an overview over all patches that are currently used.
|
|||
| server | lithium MixinDirection | JellySquid | |
|
||||
| server | lithium MixinGoalSelector | JellySquid | |
|
||||
| server | lithium MixinLandPathNodeMaker | JellySquid | |
|
||||
| server | lithium NoiseChunkGeneratorMixin | SuperCoder79 | |
|
||||
| server | lithium NoiseChunkGeneratorMixin | JellySquid | |
|
||||
| server | lithium PerlinNoiseSamplerMixin | JellySquid | |
|
||||
| server | lithium VoronoiBiomeAccessTypeMixin | JellySquid | |
|
||||
| server | lithium VoxelShapesMixin | JellySquid | Ivan Pekov |
|
||||
|
|
|
@ -4,121 +4,26 @@ Date: Tue, 29 Sep 2020 19:25:49 +0300
|
|||
Subject: [PATCH] Fix IndexOutOfBoundsException when sending too many changes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
index f43193c1090238f2241b878120247d1b3d0d4e57..a7783944e8e4ee2a164aa19b3cc342252bc84ee2 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
@@ -182,6 +182,7 @@ public class PacketDataSerializer extends ByteBuf {
|
||||
return i;
|
||||
}
|
||||
|
||||
+ public final long readVarLong() { return j(); } // Yatopia - OBFHELPER
|
||||
public long j() {
|
||||
long i = 0L;
|
||||
int j = 0;
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMultiBlockChange.java b/src/main/java/net/minecraft/server/PacketPlayOutMultiBlockChange.java
|
||||
index f260459d70053ffd17952aebf3e0410666f9bcd0..cae074a9a29fe5ddab74ec983a07c05d1439283d 100644
|
||||
index f260459d70053ffd17952aebf3e0410666f9bcd0..a28b6a44e744f16598419d20f4fe5d55016213e4 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMultiBlockChange.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMultiBlockChange.java
|
||||
@@ -8,8 +8,8 @@ import java.util.function.BiConsumer;
|
||||
public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayOut> {
|
||||
|
||||
private SectionPosition a;
|
||||
- private short[] b;
|
||||
- private IBlockData[] c;
|
||||
+ private java.util.List<Short> b; // Yatopia - change to list
|
||||
+ private java.util.List<IBlockData> c; // Yatopia - change to list
|
||||
private boolean d;
|
||||
|
||||
public PacketPlayOutMultiBlockChange() {}
|
||||
@@ -17,6 +17,8 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
public PacketPlayOutMultiBlockChange(SectionPosition sectionposition, ShortSet shortset, ChunkSection chunksection, boolean flag) {
|
||||
this.a = sectionposition;
|
||||
this.d = flag;
|
||||
+ // Yatopia start - replace logic
|
||||
+ /*
|
||||
@@ -20,12 +20,16 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
this.a(shortset.size());
|
||||
int i = 0;
|
||||
|
||||
@@ -26,12 +28,27 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
- for (ShortIterator shortiterator = shortset.iterator(); shortiterator.hasNext(); ++i) {
|
||||
- short short0 = (Short) shortiterator.next();
|
||||
+ // Yatopia start - fix IndexOutOfBounds exception when doing too many changes
|
||||
+ ShortIterator shortiterator = shortset.iterator();
|
||||
+ while (shortiterator.hasNext()) {
|
||||
+ short short0 = (Short) shortiterator.nextShort();
|
||||
|
||||
this.b[i] = short0;
|
||||
this.c[i] = (chunksection != null) ? chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)) : Blocks.AIR.getBlockData(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified
|
||||
+ i++;
|
||||
}
|
||||
+ */
|
||||
+ b = new java.util.ArrayList<>();
|
||||
+ c = new java.util.ArrayList<>();
|
||||
+ for (short s : shortset) {
|
||||
+ b.add(s);
|
||||
+ if (chunksection != null) {
|
||||
+ c.add(chunksection.getType(SectionPosition.a(s), SectionPosition.b(s), SectionPosition.c(s)));
|
||||
+ } else {
|
||||
+ c.add(Blocks.AIR.getBlockData());
|
||||
+ }
|
||||
+ }
|
||||
+ // Yatopia end
|
||||
|
||||
}
|
||||
|
||||
+
|
||||
private void a(int i) {
|
||||
+ /* // Yatopia start
|
||||
this.b = new short[i];
|
||||
this.c = new IBlockData[i];
|
||||
+ */ // Yatopia end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +57,8 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
this.d = packetdataserializer.readBoolean();
|
||||
int i = packetdataserializer.i();
|
||||
|
||||
+ // Yatopia start - replaced logic
|
||||
+ /*
|
||||
this.a(i);
|
||||
|
||||
for (int j = 0; j < this.b.length; ++j) {
|
||||
@@ -48,6 +67,15 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
this.b[j] = (short) ((int) (k & 4095L));
|
||||
this.c[j] = (IBlockData) Block.REGISTRY_ID.fromId((int) (k >>> 12));
|
||||
}
|
||||
+ */
|
||||
+ b = new java.util.ArrayList<>();
|
||||
+ c = new java.util.ArrayList<>();
|
||||
+ for (int j = 0; j < i; j++) {
|
||||
+ long k = packetdataserializer.readVarLong();
|
||||
+ b.add((short) ((int) (k & 4095L)));
|
||||
+ c.add(Block.REGISTRY_ID.fromId((int) (k >>> 12)));
|
||||
+ }
|
||||
+ // Yatopia end
|
||||
|
||||
}
|
||||
|
||||
@@ -55,10 +83,10 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
packetdataserializer.writeLong(this.a.s());
|
||||
packetdataserializer.writeBoolean(this.d);
|
||||
- packetdataserializer.d(this.b.length);
|
||||
+ packetdataserializer.d(this.b.size()); // Yatopia
|
||||
|
||||
- for (int i = 0; i < this.b.length; ++i) {
|
||||
- packetdataserializer.b((long) (Block.getCombinedId(this.c[i]) << 12 | this.b[i]));
|
||||
+ for (int i = 0; i < this.b.size(); ++i) { // Yatopia
|
||||
+ packetdataserializer.b((long) (Block.getCombinedId(this.c.get(i)) << 12 | this.b.get(i))); // Yatopia
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,11 +98,11 @@ public class PacketPlayOutMultiBlockChange implements Packet<PacketListenerPlayO
|
||||
public void a(BiConsumer<BlockPosition, IBlockData> biconsumer) {
|
||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
||||
|
||||
- for (int i = 0; i < this.b.length; ++i) {
|
||||
- short short0 = this.b[i];
|
||||
+ for (int i = 0; i < this.b.size(); ++i) { // Yatopia
|
||||
+ short short0 = this.b.get(i); // Yatopia
|
||||
|
||||
blockposition_mutableblockposition.d(this.a.d(short0), this.a.e(short0), this.a.f(short0));
|
||||
- biconsumer.accept(blockposition_mutableblockposition, this.c[i]);
|
||||
+ biconsumer.accept(blockposition_mutableblockposition, this.c.get(i)); // Yatopia
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,69 +18,69 @@ index 6c280d64bb069fba0d52a7d8b4eb6a0816354cc1..15ccdad0f46297c30ed603879db46760
|
|||
this.setPVP(dedicatedserverproperties.pvp);
|
||||
diff --git a/src/main/java/net/yatopia/server/NSPTCommand.java b/src/main/java/net/yatopia/server/NSPTCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..863fbde3162b5aa59e7631e4b401106f7ccc7d90
|
||||
index 0000000000000000000000000000000000000000..7a8c3e451788b017110a0dd5d83e40ebfeab9e70
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/yatopia/server/NSPTCommand.java
|
||||
@@ -0,0 +1,59 @@
|
||||
+package net.yatopia.server;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+public class NSPTCommand extends Command {
|
||||
+
|
||||
+ public NSPTCommand(String name) {
|
||||
+ super(name);
|
||||
+ this.description = "View server tick times in nanoseconds";
|
||||
+ this.usageMessage = "/nspt";
|
||||
+ this.setPermission("bukkit.command.nspt");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+
|
||||
+ List<String> times = new ArrayList<>();
|
||||
+ times.addAll(eval(server.tickTimes5s.getTimes()));
|
||||
+ times.addAll(eval(server.tickTimes10s.getTimes()));
|
||||
+ times.addAll(eval(server.tickTimes60s.getTimes()));
|
||||
+
|
||||
+ sender.sendMessage("§6Server tick NS times §e(§7avg§e/§7min§e/§7max§e)§6 from last 5s§7,§6 10s§7,§6 1m§e:");
|
||||
+ sender.sendMessage(String.format("§6◴ %s§7/%s§7/%s§e, %s§7/%s§7/%s§e, %s§7/%s§7/%s", times.toArray()));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private static List<String> eval(long[] times) {
|
||||
+ long min = Integer.MAX_VALUE;
|
||||
+ long max = 0L;
|
||||
+ long total = 0L;
|
||||
+ for (long value : times) {
|
||||
+ if (value > 0L && value < min) min = value;
|
||||
+ if (value > max) max = value;
|
||||
+ total += value;
|
||||
+ }
|
||||
+ double avgD = ((double) total / (double) times.length);
|
||||
+ return Arrays.asList(getColor(avgD), getColor(min), getColor(max));
|
||||
+ }
|
||||
+
|
||||
+ private static String getColor(double avg) {
|
||||
+ return ChatColor.COLOR_CHAR + (avg >= 5E+7 ? "c" : avg >= (4E+7) ? "e" : "a") + avg;
|
||||
+ }
|
||||
+}
|
||||
+package net.yatopia.server;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+public class NSPTCommand extends Command {
|
||||
+
|
||||
+ public NSPTCommand(String name) {
|
||||
+ super(name);
|
||||
+ this.description = "View server tick times in nanoseconds";
|
||||
+ this.usageMessage = "/nspt";
|
||||
+ this.setPermission("bukkit.command.nspt");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+
|
||||
+ List<String> times = new ArrayList<>();
|
||||
+ times.addAll(eval(server.tickTimes5s.getTimes()));
|
||||
+ times.addAll(eval(server.tickTimes10s.getTimes()));
|
||||
+ times.addAll(eval(server.tickTimes60s.getTimes()));
|
||||
+
|
||||
+ sender.sendMessage("§6Server tick NS times §e(§7avg§e/§7min§e/§7max§e)§6 from last 5s§7,§6 10s§7,§6 1m§e:");
|
||||
+ sender.sendMessage(String.format("§6◴ %s§7/%s§7/%s§e, %s§7/%s§7/%s§e, %s§7/%s§7/%s", times.toArray()));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private static List<String> eval(long[] times) {
|
||||
+ long min = Integer.MAX_VALUE;
|
||||
+ long max = 0L;
|
||||
+ long total = 0L;
|
||||
+ for (long value : times) {
|
||||
+ if (value > 0L && value < min) min = value;
|
||||
+ if (value > max) max = value;
|
||||
+ total += value;
|
||||
+ }
|
||||
+ double avgD = ((double) total / (double) times.length);
|
||||
+ return Arrays.asList(getColor(avgD), getColor(min), getColor(max));
|
||||
+ }
|
||||
+
|
||||
+ private static String getColor(double avg) {
|
||||
+ return ChatColor.COLOR_CHAR + (avg >= 5E+7 ? "c" : avg >= (4E+7) ? "e" : "a") + avg;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java
|
||||
index 0237e91512dd15dae1597f1cbb37b0fb178ae35e..e4c5a485caa9e97388aefd9dc5a3ce40efeca738 100644
|
||||
--- a/src/main/java/net/yatopia/server/YatopiaConfig.java
|
||||
|
|
|
@ -4,7 +4,6 @@ Date: Wed, 30 Sep 2020 18:20:12 +0300
|
|||
Subject: [PATCH] Configurable flight checks
|
||||
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 4fac720564b8687fae59c0f2e4898a48b16a9105..0d583ad962bc3bd24dc9e3da9fea33d694532176 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
|
|
Loading…
Reference in New Issue