Java Code Examples for net.minecraft.util.ResourceLocation#getResourceDomain()

The following examples show how to use net.minecraft.util.ResourceLocation#getResourceDomain() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TemplateManager.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: MachineItemBlock.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public String getCreatorModId(ItemStack itemStack) {
    MetaTileEntity metaTileEntity = getMetaTileEntity(itemStack);
    if (metaTileEntity == null) {
        return GTValues.MODID;
    }
    ResourceLocation metaTileEntityId = metaTileEntity.metaTileEntityId;
    return metaTileEntityId.getResourceDomain();
}
 
Example 3
Source File: GTItemElectromagnet.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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];
}
 
Example 4
Source File: NEIInitialization.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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());
        }
    }
}
 
Example 5
Source File: WikiUtils.java    From IGW-mod with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: CraftNamespacedKey.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
    return new NamespacedKey(minecraft.getResourceDomain(), minecraft.getResourcePath());
}
 
Example 7
Source File: AssetConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Asset toNova(ResourceLocation resource) {
	return new Asset(resource.getResourceDomain(), resource.getResourcePath()) {};
}
 
Example 8
Source File: AssetConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Texture toNovaTexture(ResourceLocation resource) {
	return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
 
Example 9
Source File: AssetConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Asset toNova(ResourceLocation resource) {
	return new Asset(resource.getResourceDomain(), resource.getResourcePath());
}
 
Example 10
Source File: AssetConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Texture toNovaTexture(ResourceLocation resource) {
	return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
 
Example 11
Source File: AssetConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Asset toNova(ResourceLocation resource) {
	return new Asset(resource.getResourceDomain(), resource.getResourcePath());
}
 
Example 12
Source File: AssetConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Asset toNovaTexture(ResourceLocation resource) {
	return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
 
Example 13
Source File: ModIdentifier.java    From OpenModsLib with MIT License 4 votes vote down vote up
private static ModContainer findModContainer(ResourceLocation id) {
	if (id == null) return null;

	String modId = id.getResourceDomain();
	return Loader.instance().getIndexedModList().get(modId);
}
 
Example 14
Source File: HitboxManager.java    From OpenModsLib with MIT License 4 votes vote down vote up
public Holder(ResourceLocation location) {
	this.location = new ResourceLocation(location.getResourceDomain(), "hitboxes/" + location.getResourcePath() + ".json");
}