当前位置: 首页>>代码示例>>Java>>正文


Java ForgeRegistries类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.registry.ForgeRegistries的典型用法代码示例。如果您正苦于以下问题:Java ForgeRegistries类的具体用法?Java ForgeRegistries怎么用?Java ForgeRegistries使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ForgeRegistries类属于net.minecraftforge.fml.common.registry包,在下文中一共展示了ForgeRegistries类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
public static void register() {
	for(Block block : HarshenConfigs.BLOCKS.allComponants)
		if(HarshenConfigs.BLOCKS.isEnabled(block))
		{
			ForgeRegistries.BLOCKS.register(block);
			if(blocksWithItems.contains(block))
			{
				ItemBlock item = block instanceof IMetaItemBlock ? add(block) : new ItemBlock(block);
				item.setRegistryName(block.getRegistryName());
				item.setMaxStackSize(blockStackSize.get(block));
				ForgeRegistries.ITEMS.register(item);
			}
				
		}
			
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenBlocks.java

示例2: getEntity

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
public EntityLivingBase getEntity(ItemStack stack)
{
	if(stack.getItem() == Item.getItemFromBlock(Blocks.AIR)
			|| stack.equals(ItemStack.EMPTY))
	{
		this.entity = null;
		return null;
	}
	try
	{
		this.entity = (EntityLivingBase) ForgeRegistries.ENTITIES.getValue((ItemMonsterPlacer.getNamedIdFrom(stack))).newInstance(world);

	}
	catch (NullPointerException e) {
	}
	return this.entity;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:18,代码来源:TileEntityHarshenSpawner.java

示例3: addPotionsAction

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
private void addPotionsAction(AttributeMap map) {
    List<PotionEffect> effects = new ArrayList<>();
    for (String p : map.getList(ACTION_POTION)) {
        String[] splitted = StringUtils.split(p, ',');
        if (splitted == null || splitted.length != 3) {
            InControl.logger.log(Level.ERROR, "Bad potion specifier '" + p + "'! Use <potion>,<duration>,<amplifier>");
            continue;
        }
        Potion potion = ForgeRegistries.POTIONS.getValue(new ResourceLocation(splitted[0]));
        if (potion == null) {
            InControl.logger.log(Level.ERROR, "Can't find potion '" + p + "'!");
            continue;
        }
        int duration = 0;
        int amplifier = 0;
        try {
            duration = Integer.parseInt(splitted[1]);
            amplifier = Integer.parseInt(splitted[2]);
        } catch (NumberFormatException e) {
            InControl.logger.log(Level.ERROR, "Bad duration or amplifier integer for '" + p + "'!");
            continue;
        }
        effects.add(new PotionEffect(potion, duration, amplifier));
    }
    if (!effects.isEmpty()) {
        actions.add(event -> {
            EntityLivingBase living = getHelper(event);
            for (PotionEffect effect : effects) {
                PotionEffect neweffect = new PotionEffect(effect.getPotion(), effect.getDuration(), effect.getAmplifier());
                living.addPotionEffect(neweffect);
            }
        });
    }
}
 
开发者ID:McJty,项目名称:InControl,代码行数:35,代码来源:SummonAidRule.java

示例4: parseItemStack

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
private static ItemStack parseItemStack(String itemString)
{
    Matcher matcher = itemRegex.matcher(itemString);

    if (!matcher.matches())
    {
        ToolBelt.logger.warn("Could not parse item " + itemString);
        return ItemStack.EMPTY;
    }

    Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(matcher.group("item")));
    if (item == null)
    {
        ToolBelt.logger.warn("Could not parse item " + itemString);
        return ItemStack.EMPTY;
    }

    String anyString = matcher.group("meta");
    String metaString = matcher.group("meta");
    int meta = Strings.isNullOrEmpty(anyString)
            ? (Strings.isNullOrEmpty(metaString) ? 0 : Integer.parseInt(metaString))
            : OreDictionary.WILDCARD_VALUE;

    return new ItemStack(item, 1, meta);
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:26,代码来源:Config.java

示例5: register

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
@Override
public void register(IModRegistry registry)
{

    for(MagibenchRegistry.Tier t : PurMag.INSTANCE.getMagibenchRegistry().getTiers())
    {
        registry.addRecipeCatalyst(new ItemStack(ItemRegistry.magibench, 1, t.getTier()), MagibenchRecipeCategory.ID);
        registry.addRecipeCatalyst(new ItemStack(ItemRegistry.magibench, 1, t.getTier()), VanillaRecipeCategoryUid.CRAFTING);
    }
    registry.handleRecipes(AbstractMagibenchRecipeWrapper.class, recipe -> recipe, MagibenchRecipeCategory.ID);

    List<AbstractMagibenchRecipeWrapper> lst = new ArrayList<>();
    for(IRecipe rec : ForgeRegistries.RECIPES)
    {
        if(rec instanceof MagibenchRecipe)
            lst.add(new MagibenchShapedRecipeWrapper((MagibenchRecipe)rec, registry.getJeiHelpers().getStackHelper()));
        if(rec instanceof MagibenchShapelessRecipe)
            lst.add(new MagibenchShapelessRecipeWrapper((MagibenchShapelessRecipe)rec, registry.getJeiHelpers().getStackHelper()));
    }
    registry.addRecipes(lst, MagibenchRecipeCategory.ID);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(new MagibenchTransferInfo(MagibenchRecipeCategory.ID));
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(new MagibenchTransferInfo(VanillaRecipeCategoryUid.CRAFTING));
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:24,代码来源:PMJeiPlugin.java

示例6: initMaterialItems

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
public static void initMaterialItems() {
	haft_map.put(new ItemStack(Items.STICK), ModMaterials.HAFT_WOOD);
	haft_map.put(new ItemStack(Items.BONE), ModMaterials.HAFT_BONE);
	haft_map.put(new ItemStack(Items.BLAZE_ROD), ModMaterials.HAFT_BLAZE_ROD);
	haft_map.put(new ItemStack(Blocks.END_ROD), ModMaterials.HAFT_END_ROD);
	
	Item haft = ForgeRegistries.ITEMS.getValue(new ResourceLocation("betterwithmods:material"));
	Item witherBone = ForgeRegistries.ITEMS.getValue(new ResourceLocation("nex:item_bone_wither"));
	if(haft != null) haft_map.put(new ItemStack(haft, 1, 36), ModMaterials.HAFT_IMPROVED);
	if(witherBone != null) haft_map.put(new ItemStack(witherBone, 1, 0), ModMaterials.HAFT_WITHER_BONE);

	handle_map.put(new ItemStack(ModItems.handle, 1, 0), ModMaterials.HANDLE_CLOTH);
	handle_map.put(new ItemStack(ModItems.handle, 1, 1), ModMaterials.HANDLE_LEATHER);
	//handle_map.put(new ItemStack(ModItems.handle, 1, 2), ModMaterials.HANDLE_WOOD);
	//handle_map.put(new ItemStack(ModItems.handle, 1, 3), ModMaterials.HANDLE_BONE);
	handle_map.put(new ItemStack(Items.STICK, 1, 0), ModMaterials.HANDLE_WOOD);
	handle_map.put(new ItemStack(Items.BONE, 1, 0), ModMaterials.HANDLE_BONE);

	adornment_map.put(new ItemStack(Items.DIAMOND), ModMaterials.ADORNMENT_DIAMOND);
	adornment_map.put(new ItemStack(Items.EMERALD), ModMaterials.ADORNMENT_EMERALD);
	adornment_map.put(new ItemStack(Items.QUARTZ), ModMaterials.ADORNMENT_QUARTZ);
	adornment_map.put(new ItemStack(Items.PRISMARINE_CRYSTALS), ModMaterials.ADORNMENT_PRISMARINE);
	adornment_map.put(new ItemStack(Items.ENDER_PEARL), ModMaterials.ADORNMENT_ENDER_PEARL);
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:25,代码来源:ModRecipes.java

示例7: getProfessionIdsAndNamesSortedById

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
public static List<Map.Entry<Integer, String>> getProfessionIdsAndNamesSortedById()
{
	List<Map.Entry<Integer, String>> professions = new ArrayList<Map.Entry<Integer, String>>();

	for (VillagerRegistry.VillagerProfession profession : ForgeRegistries.VILLAGER_PROFESSIONS.getValues())
	{
		@SuppressWarnings("deprecation")
		int id = VillagerRegistry.getId(profession);
		String name = profession.getRegistryName().toString();
		professions.add(new AbstractMap.SimpleEntry<Integer, String>(id, name));
	}

	Collections.sort(professions, new Comparator<Map.Entry<Integer, String>>()
	{
		@Override
		public int compare(Map.Entry<Integer, String> o1, Map.Entry<Integer, String> o2)
		{
			return o1.getKey() - o2.getKey();
		}
	});

	return professions;

}
 
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:25,代码来源:VillagerRegistryHelper.java

示例8: register

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
/**
     * Attempt to register all entries from {@link #enumInstanceMap} to {@link ForgeRegistries}.
     * @see ForgeRegistries
     */
    public void register() {
        enumInstanceMap.forEach((instanceClass, enumMap) -> {
            if (IForgeRegistryEntry.class.isAssignableFrom(instanceClass))
                enumMap.values().stream().map(o -> (IForgeRegistryEntry<? extends IForgeRegistryEntry<?>>) o)
//                    .map(o -> new RegisterHandler(o))
                    .forEach(o -> {
//                    TODO RegisterManager.getInstance().putRegister(o);
                        if (o instanceof Item) {
                            ForgeRegistries.ITEMS.register((Item) o);
                            if (o instanceof OreDictated)
                                Arrays.stream(((OreDictated) o).getOreDictNames()).forEach(s -> OreDictionary.registerOre(s, (Item) o));
                        }
                        else if (o instanceof Block) {
                            ForgeRegistries.BLOCKS.register((Block) o);
                            if (o instanceof OreDictated)
                                Arrays.stream(((OreDictated) o).getOreDictNames()).forEach(s -> OreDictionary.registerOre(s, (Block) o));
                        }
                    });
            else if (Fluid.class.isAssignableFrom(instanceClass))
                enumMap.values().stream().map(o -> (Fluid) o).forEach(fluid -> {
                    FluidRegistry.registerFluid(fluid);
                    FluidRegistry.addBucketForFluid(fluid);
                });
        });
    }
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:30,代码来源:EnumLoader.java

示例9: loadLiqueurs

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
@Load
public void loadLiqueurs() {
    ForgeRegistries.ITEMS.getKeys().stream().filter(s -> s.getResourcePath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).forEach(liqueur -> {
        for (LiqueurType liqueurType : LiqueurTypes.values()) {
            if (liqueurType == LiqueurTypes.NORMAL)
                continue;
            ItemLiqueur typedLiqueur = new ItemLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur))));
            typedLiqueur.setLiqueurType(liqueurType);
            typedLiqueur.setRegistryName(liqueur.getRegistryName().getResourceDomain(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getResourcePath());
            typedLiqueur.setUnlocalizedName(liqueur.getUnlocalizedName());
            ForgeRegistries.ITEMS.register(typedLiqueur);
            OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur);
            OreDictionary.registerOre("listAllliqueur", typedLiqueur);
            OreDictionary.registerOre("listAllfoods", typedLiqueur);
            cachedLiqueurs.add(typedLiqueur);
        }
    });
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:19,代码来源:LiqueurLoader.java

示例10: registerItems

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
@Load
public void registerItems() {
    for (Field field : FCRItems.class.getFields()) {
        field.setAccessible(true);
        try {
            RegItem annoItem = field.getAnnotation(RegItem.class);
            if (annoItem == null)
                continue;

            Item item = (Item) field.get(null);
            ForgeRegistries.ITEMS.register(item.setRegistryName(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(annoItem.value())).setUnlocalizedName(NameBuilder.buildUnlocalizedName(annoItem.value())));

            Arrays.stream(annoItem.oreDict()).forEach(s -> OreDictionary.registerOre(s, item));
        } catch (Throwable e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register item " + field.toGenericString(), e);
        }
    }
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:19,代码来源:ItemLoader.java

示例11: registerBlocks

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
@Load
public void registerBlocks() {
    for (Field field : FCRBlocks.class.getFields()) {
        field.setAccessible(true);
        RegBlock anno = field.getAnnotation(RegBlock.class);
        if (anno==null) continue;

        try {
            Block block = (Block) field.get(null);
            ForgeRegistries.BLOCKS.register(block.setRegistryName(NameBuilder.buildRegistryName(anno.value())).setUnlocalizedName(NameBuilder.buildUnlocalizedName(anno.value())));

            //Register item block.
            Class<? extends ItemBlock> itemClass = anno.itemClass();
            Constructor<? extends ItemBlock> con = itemClass.getConstructor(Block.class);
            con.setAccessible(true);
            ForgeRegistries.ITEMS.register(con.newInstance(block).setRegistryName(block.getRegistryName()).setUnlocalizedName(block.getUnlocalizedName()));

            Arrays.asList(anno.oreDict()).forEach(s -> OreDictionary.registerOre(s, block));
        } catch (Exception e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register block " + field.toGenericString(), e);
        }
    }
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:24,代码来源:BlockLoader.java

示例12: initialize

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
public static void initialize() {
    NonNullList<ItemStack> stacks = NonNullList.create();
    for (Item i : ForgeRegistries.ITEMS) {
        CreativeTabs tab = i.getCreativeTab();
        if(tab != null) {
            i.getSubItems(tab, stacks);
        }
    }
    List<ItemStack> out = new LinkedList<>();
    for (ItemStack stack : stacks) {
        int burn = TileEntityFurnace.getItemBurnTime(stack); //Respects vanilla values.
        if(burn > 0) {
            out.add(stack);
        }
    }
    knownFuelStacks = ImmutableList.copyOf(out);
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:18,代码来源:FuelItemHelper.java

示例13: getDescriptor

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
public static IBlockStateDescriptor getDescriptor(String strElement) throws JsonParseException {
    int meta = -1;
    int indexMeta = strElement.indexOf('@');
    if(indexMeta != -1 && indexMeta != strElement.length() - 1) {
        try {
            meta = Integer.parseInt(strElement.substring(indexMeta + 1));
        } catch (NumberFormatException exc) {
            throw new JsonParseException("Expected a metadata number, got " + strElement.substring(indexMeta + 1), exc);
        }
        strElement = strElement.substring(0, indexMeta);
    }
    ResourceLocation res = new ResourceLocation(strElement);
    Block b = ForgeRegistries.BLOCKS.getValue(res);
    if(b == null || b == Blocks.AIR) {
        throw new JsonParseException("Couldn't find block with registryName '" + res.toString() + "' !");
    }
    if(meta == -1) {
        return new IBlockStateDescriptor(b);
    } else {
        return new IBlockStateDescriptor(b.getStateFromMeta(meta));
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:23,代码来源:BlockArray.java

示例14: fromNBT

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
@Override
public void fromNBT(NBTTagCompound tag)
{
    super.fromNBT(tag);

    if (tag.hasKey("Block"))
    {
        Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("Block")));

        if (block != null)
        {
            this.block = tag.hasKey("Meta") ? block.getStateFromMeta(tag.getByte("Meta")) : block.getDefaultState();
        }
    }

    if (tag.hasKey("Pos"))
    {
        int[] pos = tag.getIntArray("Pos");

        if (pos.length == 3)
        {
            this.blockPos = new BlockPos(pos[0], pos[1], pos[2]);
        }
    }
}
 
开发者ID:mchorse,项目名称:metamorph,代码行数:26,代码来源:BlockMorph.java

示例15: toNBT

import net.minecraftforge.fml.common.registry.ForgeRegistries; //导入依赖的package包/类
@Override
public void toNBT(NBTTagCompound tag)
{
    super.toNBT(tag);

    if (this.block != null)
    {
        tag.setString("Block", ForgeRegistries.BLOCKS.getKey(this.block.getBlock()).toString());
        tag.setByte("Meta", (byte) this.block.getBlock().getMetaFromState(this.block));
    }

    if (this.blockPos != null)
    {
        tag.setIntArray("Pos", new int[] {this.blockPos.getX(), this.blockPos.getY(), this.blockPos.getZ()});
    }
}
 
开发者ID:mchorse,项目名称:metamorph,代码行数:17,代码来源:BlockMorph.java


注:本文中的net.minecraftforge.fml.common.registry.ForgeRegistries类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。