1
0
forked from xjboss/KCauldronX

Initial commit (Forge 1291).

This commit is contained in:
gamerforEA
2015-03-22 20:38:04 +03:00
commit 16773ead6a
611 changed files with 64826 additions and 0 deletions

View File

@ -0,0 +1,9 @@
--- ../src-base/minecraft/net/minecraft/world/storage/ISaveHandler.java
+++ ../src-work/minecraft/net/minecraft/world/storage/ISaveHandler.java
@@ -27,4 +27,6 @@
File getMapFileFromName(String p_75758_1_);
String getWorldDirectoryName();
+
+ java.util.UUID getUUID(); // CraftBukkit
}

View File

@ -0,0 +1,116 @@
--- ../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;
@@ -24,11 +32,21 @@
public List playersArrayList = new ArrayList();
private Map playersHashMap = new HashMap();
public Map playersVisibleOnMap = new LinkedHashMap();
+
+ // 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,7 +125,7 @@
{
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);
}
@@ -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();

View File

@ -0,0 +1,233 @@
--- ../src-base/minecraft/net/minecraft/world/storage/SaveHandler.java
+++ ../src-work/minecraft/net/minecraft/world/storage/SaveHandler.java
@@ -10,6 +10,7 @@
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.StartupQuery;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
@@ -19,6 +20,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.UUID;
+
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+// CraftBukkit end
+import cpw.mods.fml.common.registry.GameData; // Cauldron
+
public class SaveHandler implements ISaveHandler, IPlayerFileData
{
private static final Logger logger = LogManager.getLogger();
@@ -27,6 +35,8 @@
private final File mapDataDir;
private final long initializationTime = MinecraftServer.getSystemTimeMillis();
private final String saveDirectoryName;
+ private UUID uuid = null; // CraftBukkit
+ private static boolean initializedBukkit = false; // Cauldron
private static final String __OBFID = "CL_00000585";
public SaveHandler(File p_i2146_1_, String p_i2146_2_, boolean p_i2146_3_)
@@ -65,7 +75,7 @@
catch (IOException ioexception)
{
ioexception.printStackTrace();
- throw new RuntimeException("Failed to check session lock, aborting");
+ throw new RuntimeException("Failed to check session lock for world " + this.worldDirectory + ", aborting"); // Cauldron
}
}
@@ -85,7 +95,7 @@
{
if (datainputstream.readLong() != this.initializationTime)
{
- throw new MinecraftException("The save is being accessed from another location, aborting");
+ throw new MinecraftException("The save folder for world " + this.worldDirectory + " is being accessed from another location, aborting"); // Cauldron
}
}
finally
@@ -95,7 +105,10 @@
}
catch (IOException ioexception)
{
- throw new MinecraftException("Failed to check session lock, aborting");
+ // Cauldron start
+ ioexception.printStackTrace();
+ throw new MinecraftException("Failed to check session lock for world " + this.worldDirectory + ", aborting");
+ // Cauldron end
}
}
@@ -120,6 +133,7 @@
nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
worldInfo = new WorldInfo(nbttagcompound1);
FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, nbttagcompound);
+ this.initBukkitData(worldInfo); // Cauldron
return worldInfo;
}
catch (StartupQuery.AbortedException e)
@@ -143,6 +157,7 @@
nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
worldInfo = new WorldInfo(nbttagcompound1);
FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, nbttagcompound);
+ this.initBukkitData(worldInfo); // Cauldron
return worldInfo;
}
catch (StartupQuery.AbortedException e)
@@ -154,7 +169,7 @@
exception.printStackTrace();
}
}
-
+ this.initBukkitData(worldInfo); // Cauldron
return null;
}
@@ -282,6 +297,18 @@
if (nbttagcompound != null)
{
+ // CraftBukkit start
+ if (p_75752_1_ instanceof EntityPlayerMP)
+ {
+ CraftPlayer player = (CraftPlayer) p_75752_1_.getBukkitEntity(); // Cauldron
+ // Only update first played if it is older than the one we have
+ long modified = new File(playersDirectory, p_75752_1_.getCommandSenderName() + ".dat").lastModified();
+ if (modified < player.getFirstPlayed()) {
+ player.setFirstPlayed(modified);
+ }
+ }
+ // CraftBukkit end
+
p_75752_1_.readFromNBT(nbttagcompound);
}
@@ -289,6 +316,27 @@
return nbttagcompound;
}
+ // CraftBukkit start
+ public NBTTagCompound getPlayerData(String par1Str)
+ {
+ try
+ {
+ File file1 = new File(this.playersDirectory, par1Str + ".dat");
+
+ if (file1.exists())
+ {
+ return CompressedStreamTools.readCompressed(new FileInputStream(file1));
+ }
+ }
+ catch (Exception exception)
+ {
+ logger.warn("Failed to load player data for " + par1Str);
+ }
+
+ return null;
+ }
+ // CraftBukkit end
+
public IPlayerFileData getSaveHandler()
{
return this;
@@ -320,4 +368,97 @@
{
return this.saveDirectoryName;
}
+
+ // CraftBukkit start
+ public UUID getUUID()
+ {
+ if (uuid != null)
+ {
+ return uuid;
+ }
+
+ File file1 = new File(this.worldDirectory, "uid.dat");
+
+ if (file1.exists())
+ {
+ DataInputStream dis = null;
+
+ try
+ {
+ dis = new DataInputStream(new FileInputStream(file1));
+ return uuid = new UUID(dis.readLong(), dis.readLong());
+ }
+ catch (IOException ex)
+ {
+ logger.warn("Failed to read " + file1 + ", generating new random UUID", ex);
+ }
+ finally
+ {
+ if (dis != null)
+ {
+ try
+ {
+ dis.close();
+ }
+ catch (IOException ex)
+ {
+ // NOOP
+ }
+ }
+ }
+ }
+
+ uuid = UUID.randomUUID();
+ DataOutputStream dos = null;
+
+ try
+ {
+ dos = new DataOutputStream(new FileOutputStream(file1));
+ dos.writeLong(uuid.getMostSignificantBits());
+ dos.writeLong(uuid.getLeastSignificantBits());
+ }
+ catch (IOException ex)
+ {
+ logger.warn("Failed to write " + file1, ex);
+ }
+ finally
+ {
+ if (dos != null)
+ {
+ try
+ {
+ dos.close();
+ }
+ catch (IOException ex)
+ {
+ // NOOP
+ }
+ }
+ }
+
+ return uuid;
+ }
+
+ public File getPlayerDir()
+ {
+ return playersDirectory;
+ }
+ // CraftBukkit end
+
+ // Cauldron start
+ public void initBukkitData(WorldInfo worldInfo)
+ {
+ // inject bukkit materials before plugins load
+ if (!this.initializedBukkit && (worldInfo == null || worldInfo.getDimension() == 0))
+ {
+ GameData.injectBlockBukkitMaterials();
+ GameData.injectItemBukkitMaterials();
+ // since we modify bukkit enums, we need to guarantee that plugins are
+ // loaded after all mods have been loaded by FML to avoid race conditions.
+ MinecraftServer.getServer().server.loadPlugins();
+ MinecraftServer.getServer().server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
+ this.initializedBukkit = true;
+ }
+ }
+ // Cauldron end
}

View File

@ -0,0 +1,24 @@
--- ../src-base/minecraft/net/minecraft/world/storage/SaveHandlerMP.java
+++ ../src-work/minecraft/net/minecraft/world/storage/SaveHandlerMP.java
@@ -3,6 +3,8 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.File;
+import java.util.UUID;
+
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.MinecraftException;
import net.minecraft.world.WorldProvider;
@@ -50,4 +52,12 @@
{
return null;
}
+
+ // Cauldron start
+ @Override
+ public UUID getUUID()
+ {
+ return this.getUUID();
+ }
+ // Cauldron end
}

View File

@ -0,0 +1,48 @@
--- ../src-base/minecraft/net/minecraft/world/storage/WorldInfo.java
+++ ../src-work/minecraft/net/minecraft/world/storage/WorldInfo.java
@@ -117,6 +117,7 @@
this.thunderTime = p_i2157_1_.getInteger("thunderTime");
this.thundering = p_i2157_1_.getBoolean("thundering");
this.hardcore = p_i2157_1_.getBoolean("hardcore");
+ this.dimension = p_i2157_1_.getInteger("dimension"); // Cauldron
if (p_i2157_1_.hasKey("initialized", 99))
{
@@ -193,6 +194,7 @@
this.allowCommands = p_i2159_1_.allowCommands;
this.initialized = p_i2159_1_.initialized;
this.theGameRules = p_i2159_1_.theGameRules;
+ this.dimension = p_i2159_1_.dimension; // Cauldron
}
public NBTTagCompound getNBTTagCompound()
@@ -234,6 +236,7 @@
p_76064_1_.setBoolean("allowCommands", this.allowCommands);
p_76064_1_.setBoolean("initialized", this.initialized);
p_76064_1_.setTag("GameRules", this.theGameRules.writeGameRulesToNBT());
+ p_76064_1_.setInteger("dimension", this.dimension); // Cauldron
if (p_76064_2_ != null)
{
@@ -282,6 +285,21 @@
return this.playerTag;
}
+ // Cauldron start
+ /**
+ * Sets the Dimension.
+ */
+ public void setDimension(int dim)
+ {
+ this.dimension = dim;
+ }
+
+ public int getDimension()
+ {
+ return this.dimension;
+ }
+ // Cauldron end
+
public int getVanillaDimension()
{
return this.dimension;