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

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

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

World.loadData介绍

暂无

代码示例

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

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

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

@Nullable
public static POBox getPOBox(World world, IMailAddress address) {
  if (cachedPOBoxes.containsKey(address)) {
    return cachedPOBoxes.get(address);
  }
  POBox pobox = (POBox) world.loadData(POBox.class, POBox.SAVE_NAME + address);
  if (pobox != null) {
    cachedPOBoxes.put(address, pobox);
  }
  return pobox;
}

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

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

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

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

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

@Override
public TradeStation getTradeStation(World world, IMailAddress address) {
  if (cachedTradeStations.containsKey(address)) {
    return (TradeStation) cachedTradeStations.get(address);
  }
  TradeStation trade = (TradeStation) world.loadData(TradeStation.class, TradeStation.SAVE_NAME + address);
  // Only existing and valid mail orders are returned
  if (trade != null && trade.isValid()) {
    cachedTradeStations.put(address, trade);
    getPostOffice(world).registerTradeStation(trade);
    return trade;
  }
  return null;
}

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

@Override
public ICircuitLibrary getCircuitLibrary(World world, String playerName) {
  CircuitLibrary library = (CircuitLibrary) world.loadData(CircuitLibrary.class, "CircuitLibrary_" + playerName);
  if (library == null) {
    library = new CircuitLibrary(playerName);
    world.setData("CircuitLibrary_" + playerName, library);
  }
  return library;
}

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

public static WorldENet getWorldENet(World world) {
  WorldENet eNetWorldData = (WorldENet) world.loadData(WorldENet.class, DATA_ID);
  if(eNetWorldData == null) {
    eNetWorldData = new WorldENet(DATA_ID);
    world.setData(DATA_ID, eNetWorldData);
  }
  eNetWorldData.world = world;
  return eNetWorldData;
}

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

public static WorldFluidPipeNet getWorldPipeNet(World world) {
  WorldFluidPipeNet netWorldData = (WorldFluidPipeNet) world.loadData(WorldFluidPipeNet.class, DATA_ID);
  if(netWorldData == null) {
    netWorldData = new WorldFluidPipeNet(DATA_ID);
    world.setData(DATA_ID, netWorldData);
  }
  netWorldData.world = world;
  return netWorldData;
}

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

public static GenPositionWorldData getWorldPositionData(World world) {
  GenPositionWorldData data = (GenPositionWorldData) world.loadData(GenPositionWorldData.class, Reference.WORLD_DATA_MO_GEN_POSITIONS);
  if (data == null) {
    data = new GenPositionWorldData(Reference.WORLD_DATA_MO_GEN_POSITIONS);
    world.setData(Reference.WORLD_DATA_MO_GEN_POSITIONS, data);
  }
  return data;
}

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

@Override
public IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
  BotanistTracker tracker = (BotanistTracker) world.loadData(BotanistTracker.class, filename);
  if (tracker == null) {
    tracker = new BotanistTracker(filename);
    world.setData(filename, tracker);
  }
  return tracker;
}

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

public static GeneTracker getTracker(World world, @Nullable GameProfile player) {
  String filename = "GeneTracker." + ((player == null) ? "common" : player.getId());
  GeneTracker tracker = (GeneTracker) world.loadData(GeneTracker.class, filename);
  if (tracker == null) {
    tracker = new GeneTracker(filename, player);
    world.setData(filename, tracker);
  } else {
    tracker.username = player;
  }
  return tracker;
}

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

private static WorldData getInternal(World world, boolean forceLoad) {
  if (forceLoad || data == null) {
    if (!world.isRemote) {
      WorldSavedData savedData = world.loadData(WorldData.class, DATA_TAG);
      if (savedData == null) {
        ActuallyAdditions.LOGGER.info("No WorldData found, creating...");
        WorldData newData = new WorldData(DATA_TAG);
        world.setData(DATA_TAG, newData);
        data = newData;
      } else {
        data = (WorldData) savedData;
        ActuallyAdditions.LOGGER.info("Successfully loaded WorldData!");
      }
    } else {
      data = new WorldData(DATA_TAG);
      ActuallyAdditions.LOGGER.info("Created temporary WorldData to cache data on the client!");
    }
  }
  return data;
}

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

/** Loads data for the given atlas ID or creates a new one. */
public MarkersData getMarkersData(int atlasID, World world) {
  String key = getMarkersDataKey(atlasID);
  MarkersData data = null;
  if (world.isRemote) {
    // Since atlas data doesn't really belong to a single world-dimension,
    // it can be cached. This should fix #67
    data = markersDataClientCache.get(key);
  }
  if (data == null) {
    data = (MarkersData) world.loadData(MarkersData.class, key);
    if (data == null) {
      data = new MarkersData(key);
      world.setData(key, data);
    }
    if (world.isRemote) markersDataClientCache.put(key, data);
  }
  return data;
}

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

@Override
public IPostOffice getPostOffice(World world) {
  if (cachedPostOffice != null) {
    return cachedPostOffice;
  }
  PostOffice office = (PostOffice) world.loadData(PostOffice.class, PostOffice.SAVE_NAME);
  // Create office if there is none yet
  if (office == null) {
    office = new PostOffice();
    world.setData(PostOffice.SAVE_NAME, office);
  }
  office.setWorld(world);
  cachedPostOffice = office;
  return office;
}

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

@Override
public IArboristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  String filename = "ArboristTracker." + (player == null ? "common" : player.getId());
  ArboristTracker tracker = (ArboristTracker) world.loadData(ArboristTracker.class, filename);
  // Create a tracker if there is none yet.
  if (tracker == null) {
    tracker = new ArboristTracker(filename);
    world.setData(filename, tracker);
  }
  tracker.setUsername(player);
  tracker.setWorld(world);
  return tracker;
}

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

@Override
public ILepidopteristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  String filename = "LepidopteristTracker." + (player == null ? "common" : player.getId());
  LepidopteristTracker tracker = (LepidopteristTracker) world.loadData(LepidopteristTracker.class, filename);
  // Create a tracker if there is none yet.
  if (tracker == null) {
    tracker = new LepidopteristTracker(filename);
    world.setData(filename, tracker);
  }
  tracker.setUsername(player);
  tracker.setWorld(world);
  return tracker;
}

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

@Override
public IApiaristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
  String filename = "ApiaristTracker." + (player == null ? "common" : player.getId());
  ApiaristTracker tracker = (ApiaristTracker) world.loadData(ApiaristTracker.class, filename);
  // Create a tracker if there is none yet.
  if (tracker == null) {
    tracker = new ApiaristTracker(filename);
    world.setData(filename, tracker);
  }
  tracker.setUsername(player);
  tracker.setWorld(world);
  return tracker;
}

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

@Nonnull
public static StructureData getStructureData() {
  World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);
  if(world == null) {
    throw new RuntimeException("Overworld returned null");
  }
  StructureData data = (StructureData)world.loadData(StructureData.class, DATA_ID);
  if(data == null) {
    data = new StructureData(DATA_ID);
    data.markDirty(); //Is this really needed
    world.setData(DATA_ID, data);
  }
  return data;
}

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

@SubscribeEvent(priority=EventPriority.HIGHEST)
public void onWorldLoad(WorldEvent.Load event) {
  if (!event.getWorld().isRemote) {
    data = (ExtBiomeData) event.getWorld().loadData(ExtBiomeData.class, DATA_KEY);
    if (data == null) {
      data = new ExtBiomeData(DATA_KEY);
      data.markDirty();
      event.getWorld().setData(DATA_KEY, data);
    }
  }
}

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

@SubscribeEvent(priority=EventPriority.HIGHEST)
public void onWorldLoad(WorldEvent.Load event) {
  if (!event.getWorld().isRemote && event.getWorld().provider.getDimension() == 0) {
    data = (GlobalMarkersData) event.getWorld().loadData(GlobalMarkersData.class, DATA_KEY);
    if (data == null) {
      data = new GlobalMarkersData(DATA_KEY);
      data.markDirty();
      event.getWorld().setData(DATA_KEY, data);
    }
  }
}

相关文章

微信公众号

最新文章

更多

World类方法