下面列出了net.minecraft.util.ResourceLocation#getResourceDomain ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Template getBuiltinTemplate(World world, ResourceLocation templateId) {
if (templateMap.containsKey(templateId)) {
return templateMap.get(templateId);
}
Template template = new Template();
String resourcePath = "/assets/" + templateId.getResourceDomain() + "/structures/" + templateId.getResourcePath() + ".nbt";
InputStream inputStream = TemplateManager.class.getResourceAsStream(resourcePath);
if (inputStream != null) {
try {
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(inputStream);
if (!nbttagcompound.hasKey("DataVersion", 99)) {
nbttagcompound.setInteger("DataVersion", 500);
}
DataFixer dataFixer = world.getMinecraftServer().getDataFixer();
template.read(dataFixer.process(FixTypes.STRUCTURE, nbttagcompound));
} catch (IOException exception) {
GTLog.logger.error("Failed to load builtin template {}", templateId, exception);
} finally {
IOUtils.closeQuietly(inputStream);
}
} else {
GTLog.logger.warn("Failed to find builtin structure with path {}", resourcePath);
}
templateMap.put(templateId, template);
return template;
}
@Nullable
@Override
public String getCreatorModId(ItemStack itemStack) {
MetaTileEntity metaTileEntity = getMetaTileEntity(itemStack);
if (metaTileEntity == null) {
return GTValues.MODID;
}
ResourceLocation metaTileEntityId = metaTileEntity.metaTileEntityId;
return metaTileEntityId.getResourceDomain();
}
@SideOnly(Side.CLIENT)
public ModelResourceLocation createResourceLocationForStack(ItemStack stack) {
int damage = stack.getItemDamage();
ResourceLocation location = this.getRegistryName();
String name = stack.getUnlocalizedName();
this.model[damage] = new ModelResourceLocation(location.getResourceDomain()
+ name.substring(name.indexOf(".") + 1) + damage, "inventory");
return this.model[damage];
}
private static void loadModSubsets() {
ProgressBar bar = ProgressManager.push("Mod Subsets", ForgeRegistries.ITEMS.getKeys().size());
HashMap<String, ItemStackSet> modSubsets = new HashMap<>();
for (Item item : ForgeRegistries.ITEMS) {
try {
ResourceLocation ident = item.getRegistryName();
bar.step(ident.toString());
if (ident == null) {
LogHelper.error("Failed to find identifier for: " + item);
continue;
}
String modId = ident.getResourceDomain();
ItemInfo.itemOwners.put(item, modId);
ItemStackSet itemset = modSubsets.computeIfAbsent(modId, k -> new ItemStackSet());
itemset.with(item);
} catch (Throwable t) {
LogHelper.errorError("Failed to process mod subset item %s %s", t, String.valueOf(item), String.valueOf(item.getRegistryName()));
}
}
ProgressManager.pop(bar);
API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
for (Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
if (mc == null) {
LogHelper.error("Missing container for " + entry.getKey());
} else {
API.addSubset("Mod." + mc.getName(), entry.getValue());
}
}
}
public static String getOwningModId(ItemStack stack){
String modid = "minecraft";
if(stack.getItem() == null) {
IGWLog.warning("Found an ItemStack with a null item! This isn't supposed to happen!");
} else {
ResourceLocation id = Item.REGISTRY.getNameForObject(stack.getItem());
if(id != null && id.getResourceDomain() != null) modid = id.getResourceDomain().toLowerCase();
}
return modid;
}
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
return new NamespacedKey(minecraft.getResourceDomain(), minecraft.getResourcePath());
}
@Override
public Asset toNova(ResourceLocation resource) {
return new Asset(resource.getResourceDomain(), resource.getResourcePath()) {};
}
public Texture toNovaTexture(ResourceLocation resource) {
return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
@Override
public Asset toNova(ResourceLocation resource) {
return new Asset(resource.getResourceDomain(), resource.getResourcePath());
}
public Texture toNovaTexture(ResourceLocation resource) {
return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
@Override
public Asset toNova(ResourceLocation resource) {
return new Asset(resource.getResourceDomain(), resource.getResourcePath());
}
public Asset toNovaTexture(ResourceLocation resource) {
return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
private static ModContainer findModContainer(ResourceLocation id) {
if (id == null) return null;
String modId = id.getResourceDomain();
return Loader.instance().getIndexedModList().get(modId);
}
public Holder(ResourceLocation location) {
this.location = new ResourceLocation(location.getResourceDomain(), "hitboxes/" + location.getResourcePath() + ".json");
}