mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
521 lines
17 KiB
Diff
521 lines
17 KiB
Diff
From 2f645c30fe0f5d24496ff2b921509a7ed6d12061 Mon Sep 17 00:00:00 2001
|
|
From: md_5 <md_5@live.com.au>
|
|
Date: Wed, 10 Apr 2013 13:52:52 +1000
|
|
Subject: [PATCH] mc-dev imports
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LocaleLanguage.java b/src/main/java/net/minecraft/server/LocaleLanguage.java
|
|
new file mode 100644
|
|
index 0000000..d88f864
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/LocaleLanguage.java
|
|
@@ -0,0 +1,141 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+import java.io.BufferedReader;
|
|
+import java.io.File;
|
|
+import java.io.FileReader;
|
|
+import java.io.IOException;
|
|
+import java.io.InputStreamReader;
|
|
+import java.util.Enumeration;
|
|
+import java.util.IllegalFormatException;
|
|
+import java.util.Properties;
|
|
+import java.util.TreeMap;
|
|
+
|
|
+public class LocaleLanguage {
|
|
+
|
|
+ private static LocaleLanguage a = new LocaleLanguage("en_US");
|
|
+ private Properties b = new Properties();
|
|
+ private TreeMap c;
|
|
+ private TreeMap d = new TreeMap();
|
|
+ private String e;
|
|
+ private boolean f;
|
|
+
|
|
+ public LocaleLanguage(String s) {
|
|
+ this.e();
|
|
+ this.a(s, false);
|
|
+ }
|
|
+
|
|
+ public static LocaleLanguage a() {
|
|
+ return a;
|
|
+ }
|
|
+
|
|
+ private void e() {
|
|
+ TreeMap treemap = new TreeMap();
|
|
+
|
|
+ try {
|
|
+ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(LocaleLanguage.class.getResourceAsStream("/lang/languages.txt"), "UTF-8"));
|
|
+
|
|
+ for (String s = bufferedreader.readLine(); s != null; s = bufferedreader.readLine()) {
|
|
+ String[] astring = s.trim().split("=");
|
|
+
|
|
+ if (astring != null && astring.length == 2) {
|
|
+ treemap.put(astring[0], astring[1]);
|
|
+ }
|
|
+ }
|
|
+ } catch (IOException ioexception) {
|
|
+ ioexception.printStackTrace();
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ this.c = treemap;
|
|
+ this.c.put("en_US", "English (US)");
|
|
+ }
|
|
+
|
|
+ public TreeMap b() {
|
|
+ return this.c;
|
|
+ }
|
|
+
|
|
+ private void a(Properties properties, String s) throws IOException {
|
|
+ BufferedReader bufferedreader = null;
|
|
+
|
|
+ if (this.d.containsKey(s)) {
|
|
+ bufferedreader = new BufferedReader(new FileReader((File) this.d.get(s)));
|
|
+ } else {
|
|
+ bufferedreader = new BufferedReader(new InputStreamReader(LocaleLanguage.class.getResourceAsStream("/lang/" + s + ".lang"), "UTF-8"));
|
|
+ }
|
|
+
|
|
+ for (String s1 = bufferedreader.readLine(); s1 != null; s1 = bufferedreader.readLine()) {
|
|
+ s1 = s1.trim();
|
|
+ if (!s1.startsWith("#")) {
|
|
+ String[] astring = s1.split("=");
|
|
+
|
|
+ if (astring != null && astring.length == 2) {
|
|
+ properties.setProperty(astring[0], astring[1]);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public synchronized void a(String s, boolean flag) {
|
|
+ if (flag || !s.equals(this.e)) {
|
|
+ Properties properties = new Properties();
|
|
+
|
|
+ try {
|
|
+ this.a(properties, "en_US");
|
|
+ } catch (IOException ioexception) {
|
|
+ ;
|
|
+ }
|
|
+
|
|
+ this.f = false;
|
|
+ if (!"en_US".equals(s)) {
|
|
+ try {
|
|
+ this.a(properties, s);
|
|
+ Enumeration enumeration = properties.propertyNames();
|
|
+
|
|
+ while (enumeration.hasMoreElements() && !this.f) {
|
|
+ Object object = enumeration.nextElement();
|
|
+ Object object1 = properties.get(object);
|
|
+
|
|
+ if (object1 != null) {
|
|
+ String s1 = object1.toString();
|
|
+
|
|
+ for (int i = 0; i < s1.length(); ++i) {
|
|
+ if (s1.charAt(i) >= 256) {
|
|
+ this.f = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ } catch (IOException ioexception1) {
|
|
+ ioexception1.printStackTrace();
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.e = s;
|
|
+ this.b = properties;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public synchronized String a(String s) {
|
|
+ return this.b.getProperty(s, s);
|
|
+ }
|
|
+
|
|
+ public synchronized String a(String s, Object... aobject) {
|
|
+ String s1 = this.b.getProperty(s, s);
|
|
+
|
|
+ try {
|
|
+ return String.format(s1, aobject);
|
|
+ } catch (IllegalFormatException illegalformatexception) {
|
|
+ return "Format error: " + s1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public synchronized boolean b(String s) {
|
|
+ return this.b.containsKey(s);
|
|
+ }
|
|
+
|
|
+ public synchronized String c(String s) {
|
|
+ return this.b.getProperty(s + ".name", "");
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/NextTickListEntry.java b/src/main/java/net/minecraft/server/NextTickListEntry.java
|
|
new file mode 100644
|
|
index 0000000..52a70a1
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/NextTickListEntry.java
|
|
@@ -0,0 +1,56 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+public class NextTickListEntry implements Comparable {
|
|
+
|
|
+ private static long g = 0L;
|
|
+ public int a;
|
|
+ public int b;
|
|
+ public int c;
|
|
+ public int d;
|
|
+ public long e;
|
|
+ public int f;
|
|
+ private long h;
|
|
+
|
|
+ public NextTickListEntry(int i, int j, int k, int l) {
|
|
+ this.h = (long) (g++);
|
|
+ this.a = i;
|
|
+ this.b = j;
|
|
+ this.c = k;
|
|
+ this.d = l;
|
|
+ }
|
|
+
|
|
+ public boolean equals(Object object) {
|
|
+ if (!(object instanceof NextTickListEntry)) {
|
|
+ return false;
|
|
+ } else {
|
|
+ NextTickListEntry nextticklistentry = (NextTickListEntry) object;
|
|
+
|
|
+ return this.a == nextticklistentry.a && this.b == nextticklistentry.b && this.c == nextticklistentry.c && Block.b(this.d, nextticklistentry.d);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public int hashCode() {
|
|
+ return (this.a * 1024 * 1024 + this.c * 1024 + this.b) * 256;
|
|
+ }
|
|
+
|
|
+ public NextTickListEntry a(long i) {
|
|
+ this.e = i;
|
|
+ return this;
|
|
+ }
|
|
+
|
|
+ public void a(int i) {
|
|
+ this.f = i;
|
|
+ }
|
|
+
|
|
+ public int compareTo(NextTickListEntry nextticklistentry) {
|
|
+ return this.e < nextticklistentry.e ? -1 : (this.e > nextticklistentry.e ? 1 : (this.f != nextticklistentry.f ? this.f - nextticklistentry.f : (this.h < nextticklistentry.h ? -1 : (this.h > nextticklistentry.h ? 1 : 0))));
|
|
+ }
|
|
+
|
|
+ public String toString() {
|
|
+ return this.d + ": (" + this.a + ", " + this.b + ", " + this.c + "), " + this.e + ", " + this.f + ", " + this.h;
|
|
+ }
|
|
+
|
|
+ public int compareTo(Object object) {
|
|
+ return this.compareTo((NextTickListEntry) object);
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
|
|
new file mode 100644
|
|
index 0000000..5d75a54
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/NibbleArray.java
|
|
@@ -0,0 +1,40 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+public class NibbleArray {
|
|
+
|
|
+ public final byte[] a;
|
|
+ private final int b;
|
|
+ private final int c;
|
|
+
|
|
+ public NibbleArray(int i, int j) {
|
|
+ this.a = new byte[i >> 1];
|
|
+ this.b = j;
|
|
+ this.c = j + 4;
|
|
+ }
|
|
+
|
|
+ public NibbleArray(byte[] abyte, int i) {
|
|
+ this.a = abyte;
|
|
+ this.b = i;
|
|
+ this.c = i + 4;
|
|
+ }
|
|
+
|
|
+ public int a(int i, int j, int k) {
|
|
+ int l = j << this.c | k << this.b | i;
|
|
+ int i1 = l >> 1;
|
|
+ int j1 = l & 1;
|
|
+
|
|
+ return j1 == 0 ? this.a[i1] & 15 : this.a[i1] >> 4 & 15;
|
|
+ }
|
|
+
|
|
+ public void a(int i, int j, int k, int l) {
|
|
+ int i1 = j << this.c | k << this.b | i;
|
|
+ int j1 = i1 >> 1;
|
|
+ int k1 = i1 & 1;
|
|
+
|
|
+ if (k1 == 0) {
|
|
+ this.a[j1] = (byte) (this.a[j1] & 240 | l & 15);
|
|
+ } else {
|
|
+ this.a[j1] = (byte) (this.a[j1] & 15 | (l & 15) << 4);
|
|
+ }
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/OldChunkLoader.java b/src/main/java/net/minecraft/server/OldChunkLoader.java
|
|
new file mode 100644
|
|
index 0000000..53c1cb5
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/OldChunkLoader.java
|
|
@@ -0,0 +1,120 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+public class OldChunkLoader {
|
|
+
|
|
+ public static OldChunk a(NBTTagCompound nbttagcompound) {
|
|
+ int i = nbttagcompound.getInt("xPos");
|
|
+ int j = nbttagcompound.getInt("zPos");
|
|
+ OldChunk oldchunk = new OldChunk(i, j);
|
|
+
|
|
+ oldchunk.g = nbttagcompound.getByteArray("Blocks");
|
|
+ oldchunk.f = new OldNibbleArray(nbttagcompound.getByteArray("Data"), 7);
|
|
+ oldchunk.e = new OldNibbleArray(nbttagcompound.getByteArray("SkyLight"), 7);
|
|
+ oldchunk.d = new OldNibbleArray(nbttagcompound.getByteArray("BlockLight"), 7);
|
|
+ oldchunk.c = nbttagcompound.getByteArray("HeightMap");
|
|
+ oldchunk.b = nbttagcompound.getBoolean("TerrainPopulated");
|
|
+ oldchunk.h = nbttagcompound.getList("Entities");
|
|
+ oldchunk.i = nbttagcompound.getList("TileEntities");
|
|
+ oldchunk.j = nbttagcompound.getList("TileTicks");
|
|
+
|
|
+ try {
|
|
+ oldchunk.a = nbttagcompound.getLong("LastUpdate");
|
|
+ } catch (ClassCastException classcastexception) {
|
|
+ oldchunk.a = (long) nbttagcompound.getInt("LastUpdate");
|
|
+ }
|
|
+
|
|
+ return oldchunk;
|
|
+ }
|
|
+
|
|
+ public static void a(OldChunk oldchunk, NBTTagCompound nbttagcompound, WorldChunkManager worldchunkmanager) {
|
|
+ nbttagcompound.setInt("xPos", oldchunk.k);
|
|
+ nbttagcompound.setInt("zPos", oldchunk.l);
|
|
+ nbttagcompound.setLong("LastUpdate", oldchunk.a);
|
|
+ int[] aint = new int[oldchunk.c.length];
|
|
+
|
|
+ for (int i = 0; i < oldchunk.c.length; ++i) {
|
|
+ aint[i] = oldchunk.c[i];
|
|
+ }
|
|
+
|
|
+ nbttagcompound.setIntArray("HeightMap", aint);
|
|
+ nbttagcompound.setBoolean("TerrainPopulated", oldchunk.b);
|
|
+ NBTTagList nbttaglist = new NBTTagList("Sections");
|
|
+
|
|
+ int j;
|
|
+
|
|
+ for (int k = 0; k < 8; ++k) {
|
|
+ boolean flag = true;
|
|
+
|
|
+ for (j = 0; j < 16 && flag; ++j) {
|
|
+ int l = 0;
|
|
+
|
|
+ while (l < 16 && flag) {
|
|
+ int i1 = 0;
|
|
+
|
|
+ while (true) {
|
|
+ if (i1 < 16) {
|
|
+ int j1 = j << 11 | i1 << 7 | l + (k << 4);
|
|
+ byte b0 = oldchunk.g[j1];
|
|
+
|
|
+ if (b0 == 0) {
|
|
+ ++i1;
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ flag = false;
|
|
+ }
|
|
+
|
|
+ ++l;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!flag) {
|
|
+ byte[] abyte = new byte[4096];
|
|
+ NibbleArray nibblearray = new NibbleArray(abyte.length, 4);
|
|
+ NibbleArray nibblearray1 = new NibbleArray(abyte.length, 4);
|
|
+ NibbleArray nibblearray2 = new NibbleArray(abyte.length, 4);
|
|
+
|
|
+ for (int k1 = 0; k1 < 16; ++k1) {
|
|
+ for (int l1 = 0; l1 < 16; ++l1) {
|
|
+ for (int i2 = 0; i2 < 16; ++i2) {
|
|
+ int j2 = k1 << 11 | i2 << 7 | l1 + (k << 4);
|
|
+ byte b1 = oldchunk.g[j2];
|
|
+
|
|
+ abyte[l1 << 8 | i2 << 4 | k1] = (byte) (b1 & 255);
|
|
+ nibblearray.a(k1, l1, i2, oldchunk.f.a(k1, l1 + (k << 4), i2));
|
|
+ nibblearray1.a(k1, l1, i2, oldchunk.e.a(k1, l1 + (k << 4), i2));
|
|
+ nibblearray2.a(k1, l1, i2, oldchunk.d.a(k1, l1 + (k << 4), i2));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
|
+
|
|
+ nbttagcompound1.setByte("Y", (byte) (k & 255));
|
|
+ nbttagcompound1.setByteArray("Blocks", abyte);
|
|
+ nbttagcompound1.setByteArray("Data", nibblearray.a);
|
|
+ nbttagcompound1.setByteArray("SkyLight", nibblearray1.a);
|
|
+ nbttagcompound1.setByteArray("BlockLight", nibblearray2.a);
|
|
+ nbttaglist.add(nbttagcompound1);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ nbttagcompound.set("Sections", nbttaglist);
|
|
+ byte[] abyte1 = new byte[256];
|
|
+
|
|
+ for (int k2 = 0; k2 < 16; ++k2) {
|
|
+ for (j = 0; j < 16; ++j) {
|
|
+ abyte1[j << 4 | k2] = (byte) (worldchunkmanager.getBiome(oldchunk.k << 4 | k2, oldchunk.l << 4 | j).id & 255);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ nbttagcompound.setByteArray("Biomes", abyte1);
|
|
+ nbttagcompound.set("Entities", oldchunk.h);
|
|
+ nbttagcompound.set("TileEntities", oldchunk.i);
|
|
+ if (oldchunk.j != null) {
|
|
+ nbttagcompound.set("TileTicks", oldchunk.j);
|
|
+ }
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/Packet63WorldParticles.java b/src/main/java/net/minecraft/server/Packet63WorldParticles.java
|
|
new file mode 100644
|
|
index 0000000..3ef5af3
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/Packet63WorldParticles.java
|
|
@@ -0,0 +1,51 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+import java.io.DataInputStream;
|
|
+import java.io.DataOutputStream;
|
|
+
|
|
+public class Packet63WorldParticles extends Packet {
|
|
+
|
|
+ private String a;
|
|
+ private float b;
|
|
+ private float c;
|
|
+ private float d;
|
|
+ private float e;
|
|
+ private float f;
|
|
+ private float g;
|
|
+ private float h;
|
|
+ private int i;
|
|
+
|
|
+ public Packet63WorldParticles() {}
|
|
+
|
|
+ public void a(DataInputStream datainputstream) throws java.io.IOException {
|
|
+ this.a = a(datainputstream, 64);
|
|
+ this.b = datainputstream.readFloat();
|
|
+ this.c = datainputstream.readFloat();
|
|
+ this.d = datainputstream.readFloat();
|
|
+ this.e = datainputstream.readFloat();
|
|
+ this.f = datainputstream.readFloat();
|
|
+ this.g = datainputstream.readFloat();
|
|
+ this.h = datainputstream.readFloat();
|
|
+ this.i = datainputstream.readInt();
|
|
+ }
|
|
+
|
|
+ public void a(DataOutputStream dataoutputstream) throws java.io.IOException {
|
|
+ a(this.a, dataoutputstream);
|
|
+ dataoutputstream.writeFloat(this.b);
|
|
+ dataoutputstream.writeFloat(this.c);
|
|
+ dataoutputstream.writeFloat(this.d);
|
|
+ dataoutputstream.writeFloat(this.e);
|
|
+ dataoutputstream.writeFloat(this.f);
|
|
+ dataoutputstream.writeFloat(this.g);
|
|
+ dataoutputstream.writeFloat(this.h);
|
|
+ dataoutputstream.writeInt(this.i);
|
|
+ }
|
|
+
|
|
+ public void handle(Connection connection) {
|
|
+ connection.a(this);
|
|
+ }
|
|
+
|
|
+ public int a() {
|
|
+ return 64;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
new file mode 100644
|
|
index 0000000..900ed68
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
@@ -0,0 +1,67 @@
|
|
+package net.minecraft.server;
|
|
+
|
|
+import java.io.DataInputStream;
|
|
+import java.io.DataOutputStream;
|
|
+import java.io.File;
|
|
+import java.io.IOException;
|
|
+import java.util.HashMap;
|
|
+import java.util.Iterator;
|
|
+import java.util.Map;
|
|
+
|
|
+public class RegionFileCache {
|
|
+
|
|
+ private static final Map a = new HashMap();
|
|
+
|
|
+ public static synchronized RegionFile a(File file1, int i, int j) {
|
|
+ File file2 = new File(file1, "region");
|
|
+ File file3 = new File(file2, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
|
|
+ RegionFile regionfile = (RegionFile) a.get(file3);
|
|
+
|
|
+ if (regionfile != null) {
|
|
+ return regionfile;
|
|
+ } else {
|
|
+ if (!file2.exists()) {
|
|
+ file2.mkdirs();
|
|
+ }
|
|
+
|
|
+ if (a.size() >= 256) {
|
|
+ a();
|
|
+ }
|
|
+
|
|
+ RegionFile regionfile1 = new RegionFile(file3);
|
|
+
|
|
+ a.put(file3, regionfile1);
|
|
+ return regionfile1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public static synchronized void a() {
|
|
+ Iterator iterator = a.values().iterator();
|
|
+
|
|
+ while (iterator.hasNext()) {
|
|
+ RegionFile regionfile = (RegionFile) iterator.next();
|
|
+
|
|
+ try {
|
|
+ if (regionfile != null) {
|
|
+ regionfile.c();
|
|
+ }
|
|
+ } catch (IOException ioexception) {
|
|
+ ioexception.printStackTrace();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ a.clear();
|
|
+ }
|
|
+
|
|
+ public static DataInputStream c(File file1, int i, int j) {
|
|
+ RegionFile regionfile = a(file1, i, j);
|
|
+
|
|
+ return regionfile.a(i & 31, j & 31);
|
|
+ }
|
|
+
|
|
+ public static DataOutputStream d(File file1, int i, int j) {
|
|
+ RegionFile regionfile = a(file1, i, j);
|
|
+
|
|
+ return regionfile.b(i & 31, j & 31);
|
|
+ }
|
|
+}
|
|
--
|
|
1.8.1.2
|
|
|