1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/world/storage/MapData.java.patch

154 lines
6.7 KiB
Diff
Raw Normal View History

2015-03-22 17:38:04 +00:00
--- ../src-base/minecraft/net/minecraft/world/storage/MapData.java
+++ ../src-work/minecraft/net/minecraft/world/storage/MapData.java
@@ -14,6 +14,14 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldSavedData;
+// CraftBukkit start
+import java.util.UUID;
+
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.map.CraftMapView;
+// CraftBukkit end
+
public class MapData extends WorldSavedData
{
public int xCenter;
@@ -23,12 +31,22 @@
public byte[] colors = new byte[16384];
2015-03-22 17:38:04 +00:00
public List playersArrayList = new ArrayList();
private Map playersHashMap = new HashMap();
- public Map playersVisibleOnMap = new LinkedHashMap();
+ public Map<UUID, MapData.MapCoord> playersVisibleOnMap = new LinkedHashMap();
2015-03-22 17:38:04 +00:00
+
+ // CraftBukkit start
+ public final CraftMapView mapView;
+ private CraftServer server;
+ private UUID uniqueId = null;
+ // CraftBukkit end
private static final String __OBFID = "CL_00000577";
public MapData(String p_i2140_1_)
{
super(p_i2140_1_);
+ // CraftBukkit start
+ mapView = new CraftMapView(this);
+ server = (CraftServer) org.bukkit.Bukkit.getServer();
+ // CraftBukkit end
}
public void readFromNBT(NBTTagCompound p_76184_1_)
@@ -107,14 +125,14 @@
2015-03-22 17:38:04 +00:00
{
if (!this.playersHashMap.containsKey(p_76191_1_))
{
- MapData.MapInfo mapinfo = new MapData.MapInfo(p_76191_1_);
+ MapData.MapInfo mapinfo = new MapData.MapInfo(this, p_76191_1_); // Cauldron
this.playersHashMap.put(p_76191_1_, mapinfo);
this.playersArrayList.add(mapinfo);
}
if (!p_76191_1_.inventory.hasItemStack(p_76191_2_))
{
- this.playersVisibleOnMap.remove(p_76191_1_.getCommandSenderName());
+ this.playersVisibleOnMap.remove(p_76191_1_.getUniqueID());
}
for (int i = 0; i < this.playersArrayList.size(); ++i)
@@ -166,7 +184,7 @@
{
if (Math.abs(f) >= 320.0F || Math.abs(f1) >= 320.0F)
{
- this.playersVisibleOnMap.remove(p_82567_3_);
+ this.playersVisibleOnMap.remove(java.util.UUID.nameUUIDFromBytes(p_82567_3_.getBytes(org.apache.commons.codec.Charsets.US_ASCII)));
return;
}
@@ -194,7 +212,7 @@
}
}
- this.playersVisibleOnMap.put(p_82567_3_, new MapData.MapCoord((byte)p_82567_1_, b0, b1, b2));
+ this.playersVisibleOnMap.put(java.util.UUID.nameUUIDFromBytes(p_82567_3_.getBytes(org.apache.commons.codec.Charsets.US_ASCII)), new MapData.MapCoord((byte)p_82567_1_, b0, b1, b2));
}
public byte[] getUpdatePacketData(ItemStack p_76193_1_, World p_76193_2_, EntityPlayer p_76193_3_)
@@ -250,7 +268,7 @@
byte b3 = p_76192_1_[i * 3 + 2];
byte b0 = p_76192_1_[i * 3 + 3];
byte b1 = (byte)(p_76192_1_[i * 3 + 1] & 15);
- this.playersVisibleOnMap.put("icon-" + i, new MapData.MapCoord(b2, b3, b0, b1));
+ this.playersVisibleOnMap.put(java.util.UUID.nameUUIDFromBytes(("icon-" + i).getBytes(org.apache.commons.codec.Charsets.US_ASCII)), new MapData.MapCoord(b2, b3, b0, b1));
}
}
else if (p_76192_1_[0] == 2)
2015-03-22 17:38:04 +00:00
@@ -265,7 +283,7 @@
if (mapinfo == null)
{
- mapinfo = new MapData.MapInfo(p_82568_1_);
+ mapinfo = new MapData.MapInfo(this, p_82568_1_); // Cauldron
this.playersHashMap.put(p_82568_1_, mapinfo);
this.playersArrayList.add(mapinfo);
}
@@ -300,10 +318,12 @@
private byte[] lastPlayerLocationOnMap;
public int field_82569_d;
private boolean field_82570_i;
+ final MapData mapDataObj; // Cauldron
private static final String __OBFID = "CL_00000578";
- public MapInfo(EntityPlayer p_i2138_2_)
+ public MapInfo(MapData mapData, EntityPlayer p_i2138_2_)
{
+ this.mapDataObj = mapData; // Cauldron
this.entityplayerObj = p_i2138_2_;
for (int i = 0; i < this.field_76209_b.length; ++i)
@@ -328,20 +348,37 @@
int i;
int i1;
+ // Spigot start
+ boolean custom = this.mapDataObj.mapView.renderers.size() > 1 || !(this.mapDataObj.mapView.renderers.get(0) instanceof org.bukkit.craftbukkit.map.CraftMapRenderer);
+ org.bukkit.craftbukkit.map.RenderData render = (custom) ? this.mapDataObj.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayerObj.getBukkitEntity()) : null; // CraftBukkit
+
if (--this.ticksUntilPlayerLocationMapUpdate < 0)
{
this.ticksUntilPlayerLocationMapUpdate = 4;
- abyte = new byte[MapData.this.playersVisibleOnMap.size() * 3 + 1];
+ abyte = new byte[((custom) ? render.cursors.size() : this.mapDataObj.playersVisibleOnMap.size()) * 3 + 1]; // CraftBukkit
abyte[0] = 1;
i = 0;
-
- for (Iterator iterator = MapData.this.playersVisibleOnMap.values().iterator(); iterator.hasNext(); ++i)
+
+ // CraftBukkit start
+
+ // Spigot start
+ for (Iterator iterator = ((custom) ? render.cursors.iterator() : this.mapDataObj.playersVisibleOnMap.values().iterator()); iterator.hasNext(); ++i)
{
- MapData.MapCoord mapcoord = (MapData.MapCoord)iterator.next();
- abyte[i * 3 + 1] = (byte)(mapcoord.iconSize << 4 | mapcoord.iconRotation & 15);
- abyte[i * 3 + 2] = mapcoord.centerX;
- abyte[i * 3 + 3] = mapcoord.centerZ;
+ org.bukkit.map.MapCursor cursor = (custom) ? (org.bukkit.map.MapCursor) iterator.next() : null;
+
+ if (cursor != null && !cursor.isVisible())
+ {
+ continue;
+ }
+
+ MapCoord deco = (custom) ? null : (MapCoord) iterator.next();
+ abyte[i * 3 + 1] = (byte)(((custom) ? cursor.getRawType() : deco.iconSize) << 4 | ((custom) ? cursor.getDirection() : deco.iconRotation) & 15);
+ abyte[i * 3 + 2] = (byte)((custom) ? cursor.getX() : deco.centerX);
+ abyte[i * 3 + 3] = (byte)((custom) ? cursor.getY() : deco.centerZ);
}
+
+ // Spigot end
+ // CraftBukkit end
boolean flag = !p_76204_1_.isOnItemFrame();