net.minecraft.world.World.loadData()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中net.minecraft.world.World.loadData()方法的一些代码示例,展示了World.loadData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.loadData()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:loadData

World.loadData介绍

暂无

代码示例

代码示例来源:origin: SleepyTrousers/EnderIO

  1. @Override
  2. @Nullable
  3. public WorldSavedData loadData(@Nonnull Class<? extends WorldSavedData> clazz, @Nonnull String dataID) {
  4. return wrapped.loadData(clazz, dataID);
  5. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Nullable
  2. public static POBox getPOBox(World world, IMailAddress address) {
  3. if (cachedPOBoxes.containsKey(address)) {
  4. return cachedPOBoxes.get(address);
  5. }
  6. POBox pobox = (POBox) world.loadData(POBox.class, POBox.SAVE_NAME + address);
  7. if (pobox != null) {
  8. cachedPOBoxes.put(address, pobox);
  9. }
  10. return pobox;
  11. }

代码示例来源:origin: vadis365/TheErebus

  1. @Nullable
  2. @SideOnly(Side.CLIENT)
  3. public static MapData loadMapData(int mapId, World worldIn)
  4. {
  5. String s = "map_" + mapId;
  6. return (MapData)worldIn.loadData(MapData.class, s);
  7. }

代码示例来源:origin: amadornes/MCMultiPart

  1. @Override
  2. public WorldSavedData loadData(Class<? extends WorldSavedData> clazz, String dataID) {
  3. return getActualWorld().loadData(clazz, dataID);
  4. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public TradeStation getTradeStation(World world, IMailAddress address) {
  3. if (cachedTradeStations.containsKey(address)) {
  4. return (TradeStation) cachedTradeStations.get(address);
  5. }
  6. TradeStation trade = (TradeStation) world.loadData(TradeStation.class, TradeStation.SAVE_NAME + address);
  7. // Only existing and valid mail orders are returned
  8. if (trade != null && trade.isValid()) {
  9. cachedTradeStations.put(address, trade);
  10. getPostOffice(world).registerTradeStation(trade);
  11. return trade;
  12. }
  13. return null;
  14. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public ICircuitLibrary getCircuitLibrary(World world, String playerName) {
  3. CircuitLibrary library = (CircuitLibrary) world.loadData(CircuitLibrary.class, "CircuitLibrary_" + playerName);
  4. if (library == null) {
  5. library = new CircuitLibrary(playerName);
  6. world.setData("CircuitLibrary_" + playerName, library);
  7. }
  8. return library;
  9. }

代码示例来源:origin: GregTechCE/GregTech

  1. public static WorldENet getWorldENet(World world) {
  2. WorldENet eNetWorldData = (WorldENet) world.loadData(WorldENet.class, DATA_ID);
  3. if(eNetWorldData == null) {
  4. eNetWorldData = new WorldENet(DATA_ID);
  5. world.setData(DATA_ID, eNetWorldData);
  6. }
  7. eNetWorldData.world = world;
  8. return eNetWorldData;
  9. }

代码示例来源:origin: GregTechCE/GregTech

  1. public static WorldFluidPipeNet getWorldPipeNet(World world) {
  2. WorldFluidPipeNet netWorldData = (WorldFluidPipeNet) world.loadData(WorldFluidPipeNet.class, DATA_ID);
  3. if(netWorldData == null) {
  4. netWorldData = new WorldFluidPipeNet(DATA_ID);
  5. world.setData(DATA_ID, netWorldData);
  6. }
  7. netWorldData.world = world;
  8. return netWorldData;
  9. }

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

  1. public static GenPositionWorldData getWorldPositionData(World world) {
  2. GenPositionWorldData data = (GenPositionWorldData) world.loadData(GenPositionWorldData.class, Reference.WORLD_DATA_MO_GEN_POSITIONS);
  3. if (data == null) {
  4. data = new GenPositionWorldData(Reference.WORLD_DATA_MO_GEN_POSITIONS);
  5. world.setData(Reference.WORLD_DATA_MO_GEN_POSITIONS, data);
  6. }
  7. return data;
  8. }

代码示例来源:origin: ForestryMC/Binnie

  1. @Override
  2. public IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  3. String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
  4. BotanistTracker tracker = (BotanistTracker) world.loadData(BotanistTracker.class, filename);
  5. if (tracker == null) {
  6. tracker = new BotanistTracker(filename);
  7. world.setData(filename, tracker);
  8. }
  9. return tracker;
  10. }

代码示例来源:origin: ForestryMC/Binnie

  1. public static GeneTracker getTracker(World world, @Nullable GameProfile player) {
  2. String filename = "GeneTracker." + ((player == null) ? "common" : player.getId());
  3. GeneTracker tracker = (GeneTracker) world.loadData(GeneTracker.class, filename);
  4. if (tracker == null) {
  5. tracker = new GeneTracker(filename, player);
  6. world.setData(filename, tracker);
  7. } else {
  8. tracker.username = player;
  9. }
  10. return tracker;
  11. }

代码示例来源:origin: Ellpeck/ActuallyAdditions

  1. private static WorldData getInternal(World world, boolean forceLoad) {
  2. if (forceLoad || data == null) {
  3. if (!world.isRemote) {
  4. WorldSavedData savedData = world.loadData(WorldData.class, DATA_TAG);
  5. if (savedData == null) {
  6. ActuallyAdditions.LOGGER.info("No WorldData found, creating...");
  7. WorldData newData = new WorldData(DATA_TAG);
  8. world.setData(DATA_TAG, newData);
  9. data = newData;
  10. } else {
  11. data = (WorldData) savedData;
  12. ActuallyAdditions.LOGGER.info("Successfully loaded WorldData!");
  13. }
  14. } else {
  15. data = new WorldData(DATA_TAG);
  16. ActuallyAdditions.LOGGER.info("Created temporary WorldData to cache data on the client!");
  17. }
  18. }
  19. return data;
  20. }

代码示例来源:origin: AntiqueAtlasTeam/AntiqueAtlas

  1. /** Loads data for the given atlas ID or creates a new one. */
  2. public MarkersData getMarkersData(int atlasID, World world) {
  3. String key = getMarkersDataKey(atlasID);
  4. MarkersData data = null;
  5. if (world.isRemote) {
  6. // Since atlas data doesn't really belong to a single world-dimension,
  7. // it can be cached. This should fix #67
  8. data = markersDataClientCache.get(key);
  9. }
  10. if (data == null) {
  11. data = (MarkersData) world.loadData(MarkersData.class, key);
  12. if (data == null) {
  13. data = new MarkersData(key);
  14. world.setData(key, data);
  15. }
  16. if (world.isRemote) markersDataClientCache.put(key, data);
  17. }
  18. return data;
  19. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public IPostOffice getPostOffice(World world) {
  3. if (cachedPostOffice != null) {
  4. return cachedPostOffice;
  5. }
  6. PostOffice office = (PostOffice) world.loadData(PostOffice.class, PostOffice.SAVE_NAME);
  7. // Create office if there is none yet
  8. if (office == null) {
  9. office = new PostOffice();
  10. world.setData(PostOffice.SAVE_NAME, office);
  11. }
  12. office.setWorld(world);
  13. cachedPostOffice = office;
  14. return office;
  15. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public IArboristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  3. String filename = "ArboristTracker." + (player == null ? "common" : player.getId());
  4. ArboristTracker tracker = (ArboristTracker) world.loadData(ArboristTracker.class, filename);
  5. // Create a tracker if there is none yet.
  6. if (tracker == null) {
  7. tracker = new ArboristTracker(filename);
  8. world.setData(filename, tracker);
  9. }
  10. tracker.setUsername(player);
  11. tracker.setWorld(world);
  12. return tracker;
  13. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public ILepidopteristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  3. String filename = "LepidopteristTracker." + (player == null ? "common" : player.getId());
  4. LepidopteristTracker tracker = (LepidopteristTracker) world.loadData(LepidopteristTracker.class, filename);
  5. // Create a tracker if there is none yet.
  6. if (tracker == null) {
  7. tracker = new LepidopteristTracker(filename);
  8. world.setData(filename, tracker);
  9. }
  10. tracker.setUsername(player);
  11. tracker.setWorld(world);
  12. return tracker;
  13. }

代码示例来源:origin: ForestryMC/ForestryMC

  1. @Override
  2. public IApiaristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  3. String filename = "ApiaristTracker." + (player == null ? "common" : player.getId());
  4. ApiaristTracker tracker = (ApiaristTracker) world.loadData(ApiaristTracker.class, filename);
  5. // Create a tracker if there is none yet.
  6. if (tracker == null) {
  7. tracker = new ApiaristTracker(filename);
  8. world.setData(filename, tracker);
  9. }
  10. tracker.setUsername(player);
  11. tracker.setWorld(world);
  12. return tracker;
  13. }

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

  1. @Nonnull
  2. public static StructureData getStructureData() {
  3. World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);
  4. if(world == null) {
  5. throw new RuntimeException("Overworld returned null");
  6. }
  7. StructureData data = (StructureData)world.loadData(StructureData.class, DATA_ID);
  8. if(data == null) {
  9. data = new StructureData(DATA_ID);
  10. data.markDirty(); //Is this really needed
  11. world.setData(DATA_ID, data);
  12. }
  13. return data;
  14. }

代码示例来源:origin: AntiqueAtlasTeam/AntiqueAtlas

  1. @SubscribeEvent(priority=EventPriority.HIGHEST)
  2. public void onWorldLoad(WorldEvent.Load event) {
  3. if (!event.getWorld().isRemote) {
  4. data = (ExtBiomeData) event.getWorld().loadData(ExtBiomeData.class, DATA_KEY);
  5. if (data == null) {
  6. data = new ExtBiomeData(DATA_KEY);
  7. data.markDirty();
  8. event.getWorld().setData(DATA_KEY, data);
  9. }
  10. }
  11. }

代码示例来源:origin: AntiqueAtlasTeam/AntiqueAtlas

  1. @SubscribeEvent(priority=EventPriority.HIGHEST)
  2. public void onWorldLoad(WorldEvent.Load event) {
  3. if (!event.getWorld().isRemote && event.getWorld().provider.getDimension() == 0) {
  4. data = (GlobalMarkersData) event.getWorld().loadData(GlobalMarkersData.class, DATA_KEY);
  5. if (data == null) {
  6. data = new GlobalMarkersData(DATA_KEY);
  7. data.markDirty();
  8. event.getWorld().setData(DATA_KEY, data);
  9. }
  10. }
  11. }

相关文章

World类方法