net.minecraftforge.registries.IForgeRegistryEntry Java Examples

The following examples show how to use net.minecraftforge.registries.IForgeRegistryEntry. 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: PokeMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static <T extends IForgeRegistryEntry<T>> T setup(final IForgeRegistryEntry<T> entry, final ResourceLocation registryName) {
	if (entry instanceof Item) {
		final Item item = (Item) entry;
		item.setTranslationKey(MOD_ID + "." + registryName.getPath());
		item.setCreativeTab(TAB);
	} else if (entry instanceof Block) {
		final Block block = (Block) entry;
		block.setTranslationKey(MOD_ID + "." + registryName.getPath());
		block.setCreativeTab(TAB);
	}
	return entry.setRegistryName(registryName);
}
 
Example #2
Source File: Squirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static <T extends IForgeRegistryEntry<T>> T setup(final IForgeRegistryEntry<T> entry, final ResourceLocation registryName) {
	if (entry instanceof Item) {
		final Item item = (Item) entry;
		item.setTranslationKey(MOD_ID + "." + registryName.getPath());
		item.setCreativeTab(TAB);
	} else if (entry instanceof Block) {
		final Block block = (Block) entry;
		block.setTranslationKey(MOD_ID + "." + registryName.getPath());
		block.setCreativeTab(TAB);
	}
	return entry.setRegistryName(registryName);
}
 
Example #3
Source File: SubModLoader.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void track(IForgeRegistryEntry... values)
{
    for (IForgeRegistryEntry e : values)
    {
        regEntryOrigin.put(e, CommunityMod.getActiveSubMod());
    }
}
 
Example #4
Source File: Things.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <S extends IForgeRegistryEntry<S>> Thing<S> get(Shape<S> shape, Material material)
{
    if (things.contains(shape,material))
    {
        return (Thing<S>) things.get(shape, material);
    }
    Thing<S> thing = new Thing<>(shape, material);
    things.put(shape, material, thing);
    return thing;
}
 
Example #5
Source File: CommonRegistryCallbacks.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static <T, E extends IForgeRegistryEntry<E>> Integer mapObjectToId(IForgeRegistry<E> registry, T object) {
	final Map<T, E> objectToEntryMap = CommonRegistryCallbacks.getObjectToEntryMap(registry);
	final E entry = objectToEntryMap.get(object);

	final BiMap<E, Integer> entryIdMap = CommonRegistryCallbacks.getEntryIdMap(registry);
	return entryIdMap.get(entry);
}
 
Example #6
Source File: SurvivalistMod.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static <R extends T, T extends IForgeRegistryEntry<T>> R withName(R obj, ResourceLocation name)
{
    obj.setRegistryName(name);
    return obj;
}
 
Example #7
Source File: MixinCarver.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<Carver> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #8
Source File: MultiRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void register(String name, IForgeRegistryEntry<?> entry) {
    if (entry.getRegistryName() == null) {
        entry.setRegistryName(new ResourceLocation(modId, name));
    }
    entries.put(entry.getRegistryType(), entry);
}
 
Example #9
Source File: MultiRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void register(String name, IForgeRegistryEntry<?>... entries) {
    for (IForgeRegistryEntry<?> entry : entries) {
        register(name, entry);
    }
}
 
Example #10
Source File: MixinEntityType.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<EntityType> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #11
Source File: MixinPotion.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<Potion> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #12
Source File: MixinFluid.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<Fluid> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #13
Source File: MixinBlockEntityType.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<BlockEntityType> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #14
Source File: MixinActivity.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<Activity> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #15
Source File: MixinChunkGeneratorType.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<ChunkGeneratorType> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #16
Source File: MixinPaintingMotive.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<PaintingMotive> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #17
Source File: ItemInventoryWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
public ItemInventoryWalker(IForgeRegistryEntry<?> entry) {
	super(entry);
}
 
Example #18
Source File: SurvivalistMod.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static <R extends T, T extends IForgeRegistryEntry<T>> R withName(R obj, String name)
{
    return withName(obj, new ResourceLocation(MODID, name));
}
 
Example #19
Source File: RegSitter.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private <T extends IForgeRegistryEntry<T>> DeferredRegister<T> createDeferred(IForgeRegistry<T> registry)
{
    DeferredRegister<T> deferred = DeferredRegister.create(registry, RegSitter.this.modId);
    registerList.add(deferred);
    return deferred;
}
 
Example #20
Source File: Things.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static <S extends IForgeRegistryEntry<S>> Thing<S> propose(Shape<S> shape, Material material, Supplier<S> factory)
{
    return get(shape, material).propose(factory);
}
 
Example #21
Source File: CommonRegistryCallbacks.java    From OpenModsLib with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T, E extends IForgeRegistryEntry<E>> Map<T, E> getObjectToEntryMap(IForgeRegistry<E> registry) {
	return registry.getSlaveMap(OBJECT_TO_ENTRY, Map.class);
}
 
Example #22
Source File: CommonRegistryCallbacks.java    From OpenModsLib with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static <E extends IForgeRegistryEntry<E>> BiMap<E, Integer> getEntryIdMap(IForgeRegistry<E> registry) {
	return registry.getSlaveMap(ENTRY_TO_ID, BiMap.class);
}
 
Example #23
Source File: NestedItemInventoryWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
public NestedItemInventoryWalker(IForgeRegistryEntry<Item> entry, String... tags) {
	super(entry);
	this.tags = tags;
}
 
Example #24
Source File: ResourceDataWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
public ResourceDataWalker(IForgeRegistryEntry<?> entry, String idTag) {
	this.entry = entry;
	this.idTag = idTag;
}
 
Example #25
Source File: ResourceDataWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
public ResourceDataWalker(IForgeRegistryEntry<?> entry) {
	this(entry, "id");
}
 
Example #26
Source File: ItemTagWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
public ItemTagWalker(IForgeRegistryEntry<?> entry) {
	super(entry);
}
 
Example #27
Source File: NestedItemStackWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
public NestedItemStackWalker(IForgeRegistryEntry<Item> entry, String... tags) {
	super(entry);
	this.tags = tags;
}
 
Example #28
Source File: PokeMod.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static <T extends IForgeRegistryEntry<T>> T setup(final IForgeRegistryEntry<T> entry, final String name) {
	return setup(entry, new ResourceLocation(MOD_ID, name));
}
 
Example #29
Source File: MixinContainerType.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<ContainerType> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #30
Source File: PokeMod.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static <T extends IForgeRegistryEntry<T>> List<T> getModEntries(final IForgeRegistry<T> registry) {
	return registry.getValues().stream()
			.filter(entry -> Objects.requireNonNull(entry.getRegistryName()).getNamespace().equals(MOD_ID))
			.collect(Collectors.toList());
}