public static SpaceStationWorldData getMPSpaceStationData( World var0, int var1, EntityPlayer player) { final String var2 = SpaceStationWorldData.getSpaceStationID(var1); SpaceStationWorldData var3 = (SpaceStationWorldData) var0.loadItemData(SpaceStationWorldData.class, var2); if (var3 == null) { var3 = new SpaceStationWorldData(var2); var0.setItemData(var2, var3); var3.dataCompound = new NBTTagCompound(); if (player != null) { var3.owner = player.getGameProfile().getName().replace(".", ""); } var3.spaceStationName = "Station: " + var3.owner; if (player != null) { var3.allowedPlayers.add(player.getGameProfile().getName()); } var3.markDirty(); } if (var3.getSpaceStationName().replace(" ", "").isEmpty()) { var3.setSpaceStationName("Station: " + var3.owner); var3.markDirty(); } return var3; }
private void func_143027_a(World world) { if (this.itemData == null) { this.itemData = world.loadItemData(MapGenStructureData.class, this.getStructureName()); if (this.itemData == null) { this.itemData = new MapGenStructureData(this.getStructureName()); world.setItemData(this.getStructureName(), this.itemData); } else { NBTTagCompound var2 = this.itemData.getTag(); for (String var4 : var2.getKeySet()) { NBTBase var5 = var2.getTag(var4); if (var5.getType() == 10) { NBTTagCompound var6 = (NBTTagCompound) var5; if (var6.hasKey("ChunkX") && var6.hasKey("ChunkZ")) { int x = var6.getInteger("ChunkX"); int z = var6.getInteger("ChunkZ"); StructureStart var9 = MapGenStructureIO.func_143035_a(var6); if (var9 != null) { this.structureMap.put(ChunkPos.toLong(x, z), var9); } } } } } } }
public static OrbitSpinSaveDataVenus initWorldData(World world) { OrbitSpinSaveDataVenus worldData = (OrbitSpinSaveDataVenus) world.loadItemData(OrbitSpinSaveDataVenus.class, OrbitSpinSaveDataVenus.saveDataID); if (worldData == null) { worldData = new OrbitSpinSaveDataVenus(""); world.setItemData(OrbitSpinSaveDataVenus.saveDataID, worldData); if (world.provider instanceof WorldProviderVenusOrbit) { worldData.dim = world.provider.dimensionId; ((WorldProviderVenusOrbit) world.provider).writeToNBT(worldData.datacompound); } worldData.markDirty(); } else if (world.provider instanceof WorldProviderVenusOrbit) { worldData.dim = world.provider.dimensionId; worldData.datacompound = null; if (worldData.alldata != null) { worldData.datacompound = worldData.alldata.getCompoundTag("" + worldData.dim); } if (worldData.datacompound == null) { worldData.datacompound = new NBTTagCompound(); } } return worldData; }
public static int createNewMap(World world, byte scale) { int id = world.getUniqueDataId("height_map"); HeightMapData data = new HeightMapData(id, false); data.scale = scale; data.markDirty(); world.setItemData(data.mapName, data); return id; }
private static WorldCrystalNetworkData initNetworkData(World world) { WorldCrystalNetworkData data = (WorldCrystalNetworkData) world.loadItemData(WorldCrystalNetworkData.class, IDENTIFIER); if (data == null) { data = new WorldCrystalNetworkData(); world.setItemData(IDENTIFIER, data); } return data; }
private static PylonLocationData initNetworkData(World world) { PylonLocationData data = (PylonLocationData) world.loadItemData(PylonLocationData.class, IDENTIFIER); if (data == null) { data = new PylonLocationData(); world.setItemData(IDENTIFIER, data); } return data; }
@ForgeSubscribe public void onMapDataResponse(MapDataResponseEvent evt) { World world = getPlayerWorld(evt.player); for (Map.Entry<Integer, HeightMapData> e : evt.maps.entrySet()) { HeightMapData mapData = e.getValue(); world.setItemData(mapData.mapName, mapData); } }
public static void requestMapData(World world, int mapId) { if (world.isRemote) { MapDataRequestEvent evt = new MapDataRequestEvent(); evt.mapIds.add(mapId); evt.sendToServer(); HeightMapData stub = new HeightMapData(mapId, true); world.setItemData(stub.mapName, stub); } }
public static EnderLetterHandler get(World worldObj) { EnderLetterHandler handler = (EnderLetterHandler) worldObj.loadItemData(EnderLetterHandler.class, ID); if (handler == null) { handler = new EnderLetterHandler(); worldObj.setItemData(ID, handler); } return handler; }
public static MapData func_150912_a(int p_150912_0_, World p_150912_1_) { String var2 = "map_" + p_150912_0_; MapData var3 = (MapData) p_150912_1_.loadItemData(MapData.class, var2); if (var3 == null) { var3 = new MapData(var2); p_150912_1_.setItemData(var2, var3); } return var3; }
@Mod.EventHandler public void serverStarted(FMLServerStartedEvent event) { if (ImmersiveNetHandler.INSTANCE == null) ImmersiveNetHandler.INSTANCE = new ImmersiveNetHandler(); if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { World world = MinecraftServer.getServer().getEntityWorld(); if (!world.isRemote) { IELogger.info("WorldData loading"); IESaveData worldData = (IESaveData) world.loadItemData(IESaveData.class, IESaveData.dataName); if (worldData == null) { IELogger.info("WorldData not found"); worldData = new IESaveData(IESaveData.dataName); world.setItemData(IESaveData.dataName, worldData); } else IELogger.info("WorldData retrieved"); IESaveData.setInstance(world.provider.dimensionId, worldData); } } }
public MapData getMapData(ItemStack par1ItemStack, World par2World) { String var3 = "map_" + par1ItemStack.getItemDamage(); MapData var4 = (MapData) par2World.loadItemData(MapData.class, var3); if (var4 == null && !par2World.isClient) { par1ItemStack.setItemDamage(par2World.getUniqueDataId("map")); var3 = "map_" + par1ItemStack.getItemDamage(); var4 = new MapData(var3); var4.scale = 3; int var5 = 128 * (1 << var4.scale); var4.xCenter = Math.round((float) par2World.getWorldInfo().getSpawnX() / (float) var5) * var5; var4.zCenter = Math.round((float) (par2World.getWorldInfo().getSpawnZ() / var5)) * var5; var4.dimension = (byte) par2World.provider.dimensionId; var4.markDirty(); par2World.setItemData(var3, var4); } return var4; }
/** Called when item is crafted/smelted. Used only by maps so far. */ public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().getBoolean("map_is_scaling")) { MapData var4 = Items.filled_map.getMapData(par1ItemStack, par2World); par1ItemStack.setItemDamage(par2World.getUniqueDataId("map")); MapData var5 = new MapData("map_" + par1ItemStack.getItemDamage()); var5.scale = (byte) (var4.scale + 1); if (var5.scale > 4) { var5.scale = 4; } var5.xCenter = var4.xCenter; var5.zCenter = var4.zCenter; var5.dimension = var4.dimension; var5.markDirty(); par2World.setItemData("map_" + par1ItemStack.getItemDamage(), var5); } }
/** Retrieve a space station data entry, creating if necessary (with provided data) */ public static SpaceStationWorldData getStationData( World world, int stationID, int homeID, int providerIdDynamic, int providerIdStatic, EntityPlayer player) { int providerType = DimensionManager.getProviderType(stationID); boolean foundMatch = false; // Loop through all registered satellites, checking for a provider ID match. If none is found, // this method is // being called on an incorrect for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) { if (satellite.getDimensionIdStatic() == providerType || satellite.getDimensionID() == providerType) { foundMatch = true; break; } } if (!foundMatch) { return null; } else { final String stationIdentifier = SpaceStationWorldData.getSpaceStationID(stationID); SpaceStationWorldData stationData = (SpaceStationWorldData) world.loadItemData(SpaceStationWorldData.class, stationIdentifier); if (stationData == null) { stationData = new SpaceStationWorldData(stationIdentifier); world.setItemData(stationIdentifier, stationData); stationData.dataCompound = new NBTTagCompound(); if (player != null) { stationData.owner = player.getGameProfile().getName().replace(".", ""); } stationData.spaceStationName = "Station: " + stationData.owner; if (player != null) { stationData.allowedPlayers.add(player.getGameProfile().getName()); } if (homeID == -1) { throw new RuntimeException("Space station being created on bad home planet ID!"); } else { stationData.homePlanet = homeID; } if (providerIdDynamic == -1 || providerIdStatic == -1) { throw new RuntimeException("Space station being created on bad provider IDs!"); } else { stationData.dimensionIdDynamic = providerIdDynamic; stationData.dimensionIdStatic = providerIdStatic; } stationData.markDirty(); } if (stationData.getSpaceStationName().replace(" ", "").isEmpty()) { stationData.setSpaceStationName("Station: " + stationData.owner); stationData.markDirty(); } return stationData; } }
public static void setMapData(World world, HeightMapData data) { world.setItemData(data.mapName, data); }