mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 13:36:44 +01:00
More multiworld fixes
This commit is contained in:
parent
62b5da4e3a
commit
8835cb905f
5 changed files with 393 additions and 12 deletions
234
src/main/java/net/minecraft/server/ItemWorldMap.java
Normal file
234
src/main/java/net/minecraft/server/ItemWorldMap.java
Normal file
|
@ -0,0 +1,234 @@
|
|||
package net.minecraft.server;
|
||||
|
||||
public class ItemWorldMap extends ItemWorldMapBase {
|
||||
|
||||
protected ItemWorldMap(int i) {
|
||||
super(i);
|
||||
this.c(1);
|
||||
}
|
||||
|
||||
public WorldMap a(ItemStack itemstack, World world) {
|
||||
|
||||
WorldMap worldmap = (WorldMap) world.a(WorldMap.class, "map_" + itemstack.getData());
|
||||
|
||||
if (worldmap == null) {
|
||||
itemstack.b(world.b("map"));
|
||||
String s = "map_" + itemstack.getData();
|
||||
|
||||
worldmap = new WorldMap(s);
|
||||
worldmap.b = world.q().c();
|
||||
worldmap.c = world.q().e();
|
||||
worldmap.e = 3;
|
||||
worldmap.d = (byte) ((WorldServer) world).dimension; // CraftBukkit
|
||||
worldmap.a();
|
||||
world.a(s, (WorldMapBase) worldmap);
|
||||
}
|
||||
|
||||
return worldmap;
|
||||
}
|
||||
|
||||
public void a(World world, Entity entity, WorldMap worldmap) {
|
||||
if (((WorldServer) world).dimension == worldmap.d) { // CraftBukkit
|
||||
short short1 = 128;
|
||||
short short2 = 128;
|
||||
int i = 1 << worldmap.e;
|
||||
int j = worldmap.b;
|
||||
int k = worldmap.c;
|
||||
int l = MathHelper.floor(entity.locX - (double) j) / i + short1 / 2;
|
||||
int i1 = MathHelper.floor(entity.locZ - (double) k) / i + short2 / 2;
|
||||
int j1 = 128 / i;
|
||||
|
||||
if (world.worldProvider.e) {
|
||||
j1 /= 2;
|
||||
}
|
||||
|
||||
++worldmap.g;
|
||||
|
||||
for (int k1 = l - j1 + 1; k1 < l + j1; ++k1) {
|
||||
if ((k1 & 15) == (worldmap.g & 15)) {
|
||||
int l1 = 255;
|
||||
int i2 = 0;
|
||||
double d0 = 0.0D;
|
||||
|
||||
for (int j2 = i1 - j1 - 1; j2 < i1 + j1; ++j2) {
|
||||
if (k1 >= 0 && j2 >= -1 && k1 < short1 && j2 < short2) {
|
||||
int k2 = k1 - l;
|
||||
int l2 = j2 - i1;
|
||||
boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2);
|
||||
int i3 = (j / i + k1 - short1 / 2) * i;
|
||||
int j3 = (k / i + j2 - short2 / 2) * i;
|
||||
byte b0 = 0;
|
||||
byte b1 = 0;
|
||||
byte b2 = 0;
|
||||
int[] aint = new int[256];
|
||||
Chunk chunk = world.b(i3, j3);
|
||||
int k3 = i3 & 15;
|
||||
int l3 = j3 & 15;
|
||||
int i4 = 0;
|
||||
double d1 = 0.0D;
|
||||
int j4;
|
||||
int k4;
|
||||
int l4;
|
||||
int i5;
|
||||
|
||||
if (world.worldProvider.e) {
|
||||
l4 = i3 + j3 * 231871;
|
||||
l4 = l4 * l4 * 31287121 + l4 * 11;
|
||||
if ((l4 >> 20 & 1) == 0) {
|
||||
aint[Block.DIRT.id] += 10;
|
||||
} else {
|
||||
aint[Block.STONE.id] += 10;
|
||||
}
|
||||
|
||||
d1 = 100.0D;
|
||||
} else {
|
||||
for (l4 = 0; l4 < i; ++l4) {
|
||||
for (j4 = 0; j4 < i; ++j4) {
|
||||
k4 = chunk.b(l4 + k3, j4 + l3) + 1;
|
||||
int j5 = 0;
|
||||
|
||||
if (k4 > 1) {
|
||||
boolean flag1 = false;
|
||||
|
||||
do {
|
||||
flag1 = true;
|
||||
j5 = chunk.getTypeId(l4 + k3, k4 - 1, j4 + l3);
|
||||
if (j5 == 0) {
|
||||
flag1 = false;
|
||||
} else if (k4 > 0 && j5 > 0 && Block.byId[j5].material.A == MaterialMapColor.b) {
|
||||
flag1 = false;
|
||||
}
|
||||
|
||||
if (!flag1) {
|
||||
--k4;
|
||||
j5 = chunk.getTypeId(l4 + k3, k4 - 1, j4 + l3);
|
||||
}
|
||||
} while (!flag1);
|
||||
|
||||
if (j5 != 0 && Block.byId[j5].material.isLiquid()) {
|
||||
i5 = k4 - 1;
|
||||
boolean flag2 = false;
|
||||
|
||||
int k5;
|
||||
|
||||
do {
|
||||
k5 = chunk.getTypeId(l4 + k3, i5--, j4 + l3);
|
||||
++i4;
|
||||
} while (i5 > 0 && k5 != 0 && Block.byId[k5].material.isLiquid());
|
||||
}
|
||||
}
|
||||
|
||||
d1 += (double) k4 / (double) (i * i);
|
||||
++aint[j5];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i4 /= i * i;
|
||||
int l5 = b0 / (i * i);
|
||||
|
||||
l5 = b1 / (i * i);
|
||||
l5 = b2 / (i * i);
|
||||
l4 = 0;
|
||||
j4 = 0;
|
||||
|
||||
for (k4 = 0; k4 < 256; ++k4) {
|
||||
if (aint[k4] > l4) {
|
||||
j4 = k4;
|
||||
l4 = aint[k4];
|
||||
}
|
||||
}
|
||||
|
||||
double d2 = (d1 - d0) * 4.0D / (double) (i + 4) + ((double) (k1 + j2 & 1) - 0.5D) * 0.4D;
|
||||
byte b3 = 1;
|
||||
|
||||
if (d2 > 0.6D) {
|
||||
b3 = 2;
|
||||
}
|
||||
|
||||
if (d2 < -0.6D) {
|
||||
b3 = 0;
|
||||
}
|
||||
|
||||
i5 = 0;
|
||||
if (j4 > 0) {
|
||||
MaterialMapColor materialmapcolor = Block.byId[j4].material.A;
|
||||
|
||||
if (materialmapcolor == MaterialMapColor.n) {
|
||||
d2 = (double) i4 * 0.1D + (double) (k1 + j2 & 1) * 0.2D;
|
||||
b3 = 1;
|
||||
if (d2 < 0.5D) {
|
||||
b3 = 2;
|
||||
}
|
||||
|
||||
if (d2 > 0.9D) {
|
||||
b3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
i5 = materialmapcolor.q;
|
||||
}
|
||||
|
||||
d0 = d1;
|
||||
if (j2 >= 0 && k2 * k2 + l2 * l2 < j1 * j1 && (!flag || (k1 + j2 & 1) != 0)) {
|
||||
byte b4 = worldmap.f[k1 + j2 * short1];
|
||||
byte b5 = (byte) (i5 * 4 + b3);
|
||||
|
||||
if (b4 != b5) {
|
||||
if (l1 > j2) {
|
||||
l1 = j2;
|
||||
}
|
||||
|
||||
if (i2 < j2) {
|
||||
i2 = j2;
|
||||
}
|
||||
|
||||
worldmap.f[k1 + j2 * short1] = b5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (l1 <= i2) {
|
||||
worldmap.a(k1, l1, i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(ItemStack itemstack, World world, Entity entity, int i, boolean flag) {
|
||||
if (!world.isStatic) {
|
||||
WorldMap worldmap = this.a(itemstack, world);
|
||||
|
||||
if (entity instanceof EntityHuman) {
|
||||
EntityHuman entityhuman = (EntityHuman) entity;
|
||||
|
||||
worldmap.a(entityhuman, itemstack);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
this.a(world, entity, worldmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void c(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
||||
itemstack.b(world.b("map"));
|
||||
String s = "map_" + itemstack.getData();
|
||||
WorldMap worldmap = new WorldMap(s);
|
||||
|
||||
world.a(s, (WorldMapBase) worldmap);
|
||||
worldmap.b = MathHelper.floor(entityhuman.locX);
|
||||
worldmap.c = MathHelper.floor(entityhuman.locZ);
|
||||
worldmap.e = 3;
|
||||
worldmap.d = (byte) ((WorldServer) world).dimension; // CraftBukkit
|
||||
worldmap.a();
|
||||
}
|
||||
|
||||
public Packet b(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
||||
byte[] abyte = this.a(itemstack, world).a(itemstack, world, entityhuman);
|
||||
|
||||
return abyte == null ? null : new Packet131((short) Item.MAP.id, (short) itemstack.getData(), abyte);
|
||||
}
|
||||
}
|
|
@ -13,11 +13,11 @@ public class WorldManager implements IWorldAccess {
|
|||
public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {}
|
||||
|
||||
public void a(Entity entity) {
|
||||
this.server.b(this.world.worldProvider.dimension).a(entity);
|
||||
this.server.b(this.world.dimension).a(entity); // CraftBukkit
|
||||
}
|
||||
|
||||
public void b(Entity entity) {
|
||||
this.server.b(this.world.worldProvider.dimension).untrackEntity(entity);
|
||||
this.server.b(this.world.dimension).untrackEntity(entity); // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(String s, double d0, double d1, double d2, float f, float f1) {}
|
||||
|
@ -27,7 +27,7 @@ public class WorldManager implements IWorldAccess {
|
|||
public void a() {}
|
||||
|
||||
public void a(int i, int j, int k) {
|
||||
this.server.serverConfigurationManager.flagDirty(i, j, k, this.world.worldProvider.dimension);
|
||||
this.server.serverConfigurationManager.flagDirty(i, j, k, this.world.dimension); // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(String s, int i, int j, int k) {}
|
||||
|
@ -37,6 +37,6 @@ public class WorldManager implements IWorldAccess {
|
|||
}
|
||||
|
||||
public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) {
|
||||
this.server.serverConfigurationManager.a(entityhuman, (double) j, (double) k, (double) l, 64.0D, this.world.worldProvider.dimension, new Packet61(i, j, k, l, i1));
|
||||
this.server.serverConfigurationManager.a(entityhuman, (double) j, (double) k, (double) l, 64.0D, this.world.dimension, new Packet61(i, j, k, l, i1)); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
|
144
src/main/java/net/minecraft/server/WorldMap.java
Normal file
144
src/main/java/net/minecraft/server/WorldMap.java
Normal file
|
@ -0,0 +1,144 @@
|
|||
package net.minecraft.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldMap extends WorldMapBase {
|
||||
|
||||
public int b;
|
||||
public int c;
|
||||
public byte d;
|
||||
public byte e;
|
||||
public byte[] f = new byte[16384];
|
||||
public int g;
|
||||
public List h = new ArrayList();
|
||||
private Map j = new HashMap();
|
||||
public List i = new ArrayList();
|
||||
|
||||
public WorldMap(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
this.d = nbttagcompound.c("dimension");
|
||||
this.b = nbttagcompound.e("xCenter");
|
||||
this.c = nbttagcompound.e("zCenter");
|
||||
this.e = nbttagcompound.c("scale");
|
||||
if (this.e < 0) {
|
||||
this.e = 0;
|
||||
}
|
||||
|
||||
if (this.e > 4) {
|
||||
this.e = 4;
|
||||
}
|
||||
|
||||
short short1 = nbttagcompound.d("width");
|
||||
short short2 = nbttagcompound.d("height");
|
||||
|
||||
if (short1 == 128 && short2 == 128) {
|
||||
this.f = nbttagcompound.j("colors");
|
||||
} else {
|
||||
byte[] abyte = nbttagcompound.j("colors");
|
||||
|
||||
this.f = new byte[16384];
|
||||
int i = (128 - short1) / 2;
|
||||
int j = (128 - short2) / 2;
|
||||
|
||||
for (int k = 0; k < short2; ++k) {
|
||||
int l = k + j;
|
||||
|
||||
if (l >= 0 || l < 128) {
|
||||
for (int i1 = 0; i1 < short1; ++i1) {
|
||||
int j1 = i1 + i;
|
||||
|
||||
if (j1 >= 0 || j1 < 128) {
|
||||
this.f[j1 + l * 128] = abyte[i1 + k * short1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.a("dimension", this.d);
|
||||
nbttagcompound.a("xCenter", this.b);
|
||||
nbttagcompound.a("zCenter", this.c);
|
||||
nbttagcompound.a("scale", this.e);
|
||||
nbttagcompound.a("width", (short) 128);
|
||||
nbttagcompound.a("height", (short) 128);
|
||||
nbttagcompound.a("colors", this.f);
|
||||
}
|
||||
|
||||
public void a(EntityHuman entityhuman, ItemStack itemstack) {
|
||||
if (!this.j.containsKey(entityhuman)) {
|
||||
WorldMapHumanTracker worldmaphumantracker = new WorldMapHumanTracker(this, entityhuman);
|
||||
|
||||
this.j.put(entityhuman, worldmaphumantracker);
|
||||
this.h.add(worldmaphumantracker);
|
||||
}
|
||||
|
||||
this.i.clear();
|
||||
|
||||
for (int i = 0; i < this.h.size(); ++i) {
|
||||
WorldMapHumanTracker worldmaphumantracker1 = (WorldMapHumanTracker) this.h.get(i);
|
||||
|
||||
if (!worldmaphumantracker1.a.dead && worldmaphumantracker1.a.inventory.c(itemstack)) {
|
||||
float f = (float) (worldmaphumantracker1.a.locX - (double) this.b) / (float) (1 << this.e);
|
||||
float f1 = (float) (worldmaphumantracker1.a.locZ - (double) this.c) / (float) (1 << this.e);
|
||||
byte b0 = 64;
|
||||
byte b1 = 64;
|
||||
|
||||
if (f >= (float) (-b0) && f1 >= (float) (-b1) && f <= (float) b0 && f1 <= (float) b1) {
|
||||
byte b2 = 0;
|
||||
byte b3 = (byte) ((int) ((double) (f * 2.0F) + 0.5D));
|
||||
byte b4 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D));
|
||||
byte b5 = (byte) ((int) ((double) (entityhuman.yaw * 16.0F / 360.0F) + 0.5D));
|
||||
|
||||
if (this.d < 0) {
|
||||
int j = this.g / 10;
|
||||
|
||||
b5 = (byte) (j * j * 34187121 + j * 121 >> 15 & 15);
|
||||
}
|
||||
|
||||
if (worldmaphumantracker1.a.dimension == this.d) {
|
||||
this.i.add(new WorldMapOrienter(this, b2, b3, b4, b5));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.j.remove(worldmaphumantracker1.a);
|
||||
this.h.remove(worldmaphumantracker1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] a(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
||||
WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.j.get(entityhuman);
|
||||
|
||||
if (worldmaphumantracker == null) {
|
||||
return null;
|
||||
} else {
|
||||
byte[] abyte = worldmaphumantracker.a(itemstack);
|
||||
|
||||
return abyte;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int i, int j, int k) {
|
||||
super.a();
|
||||
|
||||
for (int l = 0; l < this.h.size(); ++l) {
|
||||
WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.h.get(l);
|
||||
|
||||
if (worldmaphumantracker.b[i] < 0 || worldmaphumantracker.b[i] > j) {
|
||||
worldmaphumantracker.b[i] = j;
|
||||
}
|
||||
|
||||
if (worldmaphumantracker.c[i] < 0 || worldmaphumantracker.c[i] < k) {
|
||||
worldmaphumantracker.c[i] = k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,9 +117,8 @@ public class WorldServer extends World implements BlockChangeDelegate {
|
|||
if (lightning.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, this.dimension, new Packet71Weather(entity));
|
||||
// CraftBukkit end
|
||||
|
||||
this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, this.worldProvider.dimension, new Packet71Weather(entity));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -129,7 +128,8 @@ public class WorldServer extends World implements BlockChangeDelegate {
|
|||
public void a(Entity entity, byte b0) {
|
||||
Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0);
|
||||
|
||||
this.server.b(this.worldProvider.dimension).b(entity, packet38entitystatus);
|
||||
// CraftBukkit
|
||||
this.server.b(this.dimension).b(entity, packet38entitystatus);
|
||||
}
|
||||
|
||||
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
|
||||
|
@ -139,15 +139,19 @@ public class WorldServer extends World implements BlockChangeDelegate {
|
|||
if (explosion.wasCanceled) {
|
||||
return explosion;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, this.worldProvider.dimension, new Packet60Explosion(d0, d1, d2, f, explosion.g));
|
||||
// explosion.a = flag;
|
||||
// explosion.a();
|
||||
// explosion.a(false);
|
||||
this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, this.dimension, new Packet60Explosion(d0, d1, d2, f, explosion.g));
|
||||
// CraftBukkit end
|
||||
return explosion;
|
||||
}
|
||||
|
||||
public void d(int i, int j, int k, int l, int i1) {
|
||||
super.d(i, j, k, l, i1);
|
||||
this.server.serverConfigurationManager.a((double) i, (double) j, (double) k, 64.0D, this.worldProvider.dimension, new Packet54PlayNoteBlock(i, j, k, l, i1));
|
||||
// CraftBukkit
|
||||
this.server.serverConfigurationManager.a((double) i, (double) j, (double) k, 64.0D, this.dimension, new Packet54PlayNoteBlock(i, j, k, l, i1));
|
||||
}
|
||||
|
||||
public void saveLevel() {
|
||||
|
|
|
@ -172,8 +172,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
EntityPlayer entity = getHandle();
|
||||
|
||||
if (oldWorld != newWorld) {
|
||||
this.sendMessage("Multiworld teleporting disabled in this build. Nether works");
|
||||
// this.entity = manager.a(entity, newWorld.dimension, false);
|
||||
this.entity = manager.a(entity, newWorld.dimension, false);
|
||||
return true;
|
||||
} else {
|
||||
return entity.netServerHandler.teleport(location);
|
||||
|
|
Loading…
Reference in a new issue