net.minecraft.item.SpawnEggItem Java Examples

The following examples show how to use net.minecraft.item.SpawnEggItem. 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: MixinSpawnEggItem.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public String getCreatorModId(ItemStack itemStack) {
	final Item item = itemStack.getItem();
	Identifier defaultId = Registry.ITEM.getDefaultId();
	Identifier id = Registry.ITEM.getId(item);

	if (defaultId.equals(id) && item != Registry.ITEM.get(defaultId)) {
		return null;
	} else {
		final String namespace = id.getNamespace();

		if ("minecraft".equals(namespace)) {
			final EntityType<?> type = ((SpawnEggItem) item).getEntityType(itemStack.getTag());
			id = Registry.ENTITY_TYPE.getId(type);
			defaultId = Registry.ENTITY_TYPE.getDefaultId();

			if (defaultId.equals(id) && type != Registry.ENTITY_TYPE.get(defaultId)) {
				return namespace;
			}

			return id.getNamespace();
		}

		return namespace;
	}
}
 
Example #2
Source File: SpawnEggItemAccessor.java    From multiconnect with MIT License 4 votes vote down vote up
@Accessor("SPAWN_EGGS")
static Map<EntityType<?>, SpawnEggItem> getSpawnEggs() {
    return MixinHelper.fakeInstance();
}