Java Code Examples for net.minecraftforge.registries.IForgeRegistry#register()

The following examples show how to use net.minecraftforge.registries.IForgeRegistry#register() . 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: TransIconHerobrineButWithBetterPantsSubMod.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg) {
    reg.register(EntityEntryBuilder.create()
            .entity(TransIconHerobrineButWithBetterPantsEntity.class)
            .factory(TransIconHerobrineButWithBetterPantsEntity::new)
            .name(CommunityGlobals.MOD_ID + ".trans_icon_herobrine_but_with_better_pants")
            .id(new ResourceLocation(CommunityGlobals.MOD_ID, "trans_icon_herobrine_but_with_better_pants"), CommunityGlobals.entity_id++)
            .tracker(128, 3, true)
            .spawn(EnumCreatureType.CREATURE, 3, 0, 1, Biome.REGISTRY)
            .egg(0xAA7D66, 0x32394D)
            .build()
    );

    reg.register(EntityEntryBuilder.create()
            .entity(NotchButWithWorsererPantsEntity.class)
            .factory(NotchButWithWorsererPantsEntity::new)
            .name(CommunityGlobals.MOD_ID + ".notch_but_with_worserer_pants")
            .id(new ResourceLocation(CommunityGlobals.MOD_ID, "notch_but_with_worserer_pants"), CommunityGlobals.entity_id++)
            .tracker(80, 3, true)
            .spawn(EnumCreatureType.CREATURE, 3, 2, 3, Biome.REGISTRY)
            .egg(0xAAAAAA, 0xAAAAAA)
            .build()
    );
}
 
Example 2
Source File: ItemNugget.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public void registerRecipes(IForgeRegistry<IRecipe> registry) {
    for (AgriNuggetType type : AgriNuggetType.values()) {
        // 1) Ore Dictionary registration.
        AgriCore.getLogger("agricraft").info("Registering in Ore Dictionary: {0}", type.nugget);
        ItemStack oneNugget = new ItemStack(this, 1, type.ordinal());
        OreDictionary.registerOre(type.nugget, oneNugget);

        // 2) Conditional recipes. Only if the ingot exists, because AgriCraft doesn't add its own.
        ItemStack ingot = OreDictUtil.getFirstOre(type.ingot).orElse(ItemStack.EMPTY);
        if (!ingot.isEmpty()) {
            AgriCore.getLogger("agricraft").info("Adding a recipe to convert nine {0} into one {1}", type.nugget, type.ingot);
            final ResourceLocation group = new ResourceLocation(AgriCraft.instance.getModId(), "combine_nugget");
            final ResourceLocation name = new ResourceLocation(AgriCraft.instance.getModId(), "combine_nugget_" + type.name().toLowerCase());
            final ShapedOreRecipe recipe = new ShapedOreRecipe(
                    group,
                    ingot,
                    "nnn",
                    "nnn",
                    "nnn",
                    'n', type.nugget
            );
            recipe.setRegistryName(name);
            AgriCore.getLogger("agricraft").info("Registering nugget recipe: {0}!", recipe.getRegistryName());
            registry.register(recipe);
        }
    }
}
 
Example 3
Source File: SubmodGnomes.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Block registerBlock(IForgeRegistry<Block> registry, Block newBlock, String name)
{
	name = appendPrefix(name);
	newBlock.setTranslationKey(name);
	newBlock.setRegistryName(name);
	registry.register(newBlock);
	return newBlock;
}
 
Example 4
Source File: SubmodGnomes.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg)
{
	reg.register(EntityEntryBuilder.create()
			.name(CommunityGlobals.MOD_ID + "." + "wood_gnome")
			.entity(EntityGnomeWood.class)
			.id(new ResourceLocation(CommunityGlobals.MOD_ID, "wood_gnome"), CommunityGlobals.entity_id++)
			.tracker(80, 3, false)
			.spawn(EnumCreatureType.CREATURE, 10, 1, 4, BiomeDictionary.getBiomes(BiomeDictionary.Type.FOREST))
			.egg(0xd3753f, 0x774725)
			.build());
}
 
Example 5
Source File: SubmodExplodingChickens.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg)
{
	reg.register(EntityEntryBuilder.create()
			.name(CommunityGlobals.MOD_ID + "." + "exploding_chicken")
			.entity(EntityExplodingChicken.class)
			.id(new ResourceLocation(CommunityGlobals.MOD_ID, "exploding_chicken"), CommunityGlobals.entity_id++)
			.tracker(80, 3, true)
			.spawn(EnumCreatureType.CREATURE, 3, 1, 4, most_biomes)
			.egg(16711680, 10592673)
			.build());
}
 
Example 6
Source File: NeatNetherBlocks.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ItemBlock registerItemBlock(Block block, IForgeRegistry<Item> r)
{
	ItemBlock ib = new ItemBlock(block);
	ib.setRegistryName(block.getRegistryName());

	r.register(ib);

	return ib;
}
 
Example 7
Source File: CommonProxy.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
    GTLog.logger.info("Registering Blocks...");
    IForgeRegistry<Block> registry = event.getRegistry();

    registry.register(MACHINE);
    registry.register(CABLE);
    registry.register(FLUID_PIPE);

    registry.register(FOAM);
    registry.register(REINFORCED_FOAM);
    registry.register(PETRIFIED_FOAM);
    registry.register(REINFORCED_PETRIFIED_FOAM);
    registry.register(BOILER_CASING);
    registry.register(BOILER_FIREBOX_CASING);
    registry.register(METAL_CASING);
    registry.register(TURBINE_CASING);
    registry.register(MACHINE_CASING);
    registry.register(MUTLIBLOCK_CASING);
    registry.register(WIRE_COIL);
    registry.register(WARNING_SIGN);
    registry.register(GRANITE);
    registry.register(MINERAL);
    registry.register(CONCRETE);
    registry.register(LOG);
    registry.register(LEAVES);
    registry.register(SAPLING);
    registry.register(CRUSHER_BLADE);
    registry.register(SURFACE_ROCK_NEW);

    COMPRESSED.values().stream().distinct().forEach(registry::register);
    SURFACE_ROCKS.values().stream().distinct().forEach(registry::register);
    FRAMES.values().stream().distinct().forEach(registry::register);
    ORES.forEach(registry::register);
    FLUID_BLOCKS.forEach(registry::register);
}
 
Example 8
Source File: Potions.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
public void registerPotions(IForgeRegistry<PotionType> reg) {
  // wither potion

  Ingredient redstone = Ingredient.fromItem(Items.REDSTONE);
  Ingredient glowstone = Ingredient.fromItem(Items.GLOWSTONE_DUST);

  // Wither
  reg.register(withering);
  reg.register(witheringLong);

  Ingredient witheringDust = Ingredient.fromItem(EnderZoo.itemWitheringDust);
  registerPotionTypeConversion(PotionTypes.AWKWARD, witheringDust, withering);
  registerPotionTypeConversion(withering, redstone, witheringLong);

  // Confusion
  reg.register(confusion);
  reg.register(confusionLong);

  Ingredient confusionDust = Ingredient.fromItem(EnderZoo.itemConfusingDust);
  registerPotionTypeConversion(PotionTypes.AWKWARD, confusionDust, confusion);
  registerPotionTypeConversion(confusion, redstone, confusionLong);

  // Rising
  if (Config.floatingPotionEnabled) {
    reg.register(floating);
    reg.register(floatingLong);
    reg.register(floatingTwo);

    Ingredient owlEgg = Ingredient.fromItem(EnderZoo.itemOwlEgg);
    registerPotionTypeConversion(PotionTypes.AWKWARD, owlEgg, floating);
    registerPotionTypeConversion(floating, redstone, floatingLong);
    registerPotionTypeConversion(floating, glowstone, floatingTwo);
  }

}
 
Example 9
Source File: WillsAssortedThingsSubMod.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerItems(IForgeRegistry<Item> reg) {
    for (Block block : ModBlocks.blocks) {
        reg.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    }

    for (Item item : ModItems.items) {
        reg.register(item);
    }
}
 
Example 10
Source File: EnderUtilitiesBlocks.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void registerBlock(IForgeRegistry<Block> registry, BlockEnderUtilities block, boolean isDisabled)
{
    if (isDisabled == false)
    {
        block.setRegistryName(Reference.MOD_ID + ":" + block.getBlockName());
        registry.register(block);
    }
    else
    {
        block.setEnabled(false);
    }
}
 
Example 11
Source File: RegUtil.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static <T extends Item> T registerItem(IForgeRegistry<Item> reg, T item, String name) {
	item.setRegistryName(new ResourceLocation(CommunityGlobals.MOD_ID, name));
	item.setTranslationKey(CommunityGlobals.MOD_ID + '.' + name);
	item.setCreativeTab(CommunityGlobals.TAB);
	
	reg.register(item);
	
	return item;
}
 
Example 12
Source File: RegistryHandler.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@SubscribeEvent
public void onSoundEventRegister(Register<SoundEvent> e) {
    IForgeRegistry<SoundEvent> reg = e.getRegistry();
    reg.register(EntityOwl.SND_HOOT);
    reg.register(EntityOwl.SND_HOOT2);
    reg.register(EntityOwl.SND_HURT);
}
 
Example 13
Source File: RegUtil.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static <T extends Block> T registerBlock(IForgeRegistry<Block> reg, T block, String name) {
	block.setRegistryName(new ResourceLocation(CommunityGlobals.MOD_ID, name));
	block.setTranslationKey(CommunityGlobals.MOD_ID + '.' + name);
	block.setCreativeTab(CommunityGlobals.TAB);
	
	reg.register(block);
	
	return block;
}
 
Example 14
Source File: WillsAssortedThingsSubMod.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void registerBlocks(IForgeRegistry<Block> reg) {
    for (Block block : ModBlocks.blocks) {
        reg.register(block);
    }
}
 
Example 15
Source File: CommonProxy.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
    GTLog.logger.info("Registering Items...");
    IForgeRegistry<Item> registry = event.getRegistry();

    for (MetaItem<?> item : MetaItems.ITEMS) {
        registry.register(item);
        item.registerSubItems();
    }
    ToolRecipeHandler.initializeMetaItems();

    registry.register(createItemBlock(MACHINE, MachineItemBlock::new));
    registry.register(createItemBlock(CABLE, ItemBlockCable::new));
    registry.register(createItemBlock(FLUID_PIPE, ItemBlockFluidPipe::new));

    registry.register(createItemBlock(BOILER_CASING, VariantItemBlock::new));
    registry.register(createItemBlock(BOILER_FIREBOX_CASING, VariantItemBlock::new));
    registry.register(createItemBlock(METAL_CASING, VariantItemBlock::new));
    registry.register(createItemBlock(TURBINE_CASING, VariantItemBlock::new));
    registry.register(createItemBlock(MACHINE_CASING, VariantItemBlock::new));
    registry.register(createItemBlock(MUTLIBLOCK_CASING, VariantItemBlock::new));
    registry.register(createItemBlock(WIRE_COIL, VariantItemBlock::new));
    registry.register(createItemBlock(WARNING_SIGN, VariantItemBlock::new));
    registry.register(createItemBlock(GRANITE, StoneItemBlock::new));
    registry.register(createItemBlock(MINERAL, StoneItemBlock::new));
    registry.register(createItemBlock(CONCRETE, StoneItemBlock::new));
    registry.register(createMultiTexItemBlock(LOG, state -> state.getValue(BlockGregLog.VARIANT).getName()));
    registry.register(createMultiTexItemBlock(LEAVES, state -> state.getValue(BlockGregLeaves.VARIANT).getName()));
    registry.register(createMultiTexItemBlock(SAPLING, state -> state.getValue(BlockGregSapling.VARIANT).getName()));
    registry.register(createItemBlock(CRUSHER_BLADE, ItemBlock::new));

    COMPRESSED.values()
        .stream().distinct()
        .map(block -> createItemBlock(block, CompressedItemBlock::new))
        .forEach(registry::register);
    FRAMES.values()
        .stream().distinct()
        .map(block -> createItemBlock(block, FrameItemBlock::new))
        .forEach(registry::register);
    ORES.stream()
        .map(block -> createItemBlock(block, OreItemBlock::new))
        .forEach(registry::register);
}
 
Example 16
Source File: SubModTightPants.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
  public void registerItems (IForgeRegistry<Item> reg) {
      
tightPants.setRegistryName(pantsId);
reg.register(tightPants);
  }
 
Example 17
Source File: ModContent.java    From EnderStorage with MIT License 4 votes vote down vote up
@SubscribeEvent
public static void onRegisterRecipeSerializers(RegistryEvent.Register<IRecipeSerializer<?>> event) {
    IForgeRegistry<IRecipeSerializer<?>> registry = event.getRegistry();
    registry.register(new CreateRecipe.Serializer().setRegistryName("create_recipe"));
    registry.register(new ReColourRecipe.Serializer().setRegistryName("recolour_recipe"));
}
 
Example 18
Source File: FatSheep.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void registerEntities(IForgeRegistry<EntityEntry> reg)
{
	reg.register(EntityEntryBuilder.create().name("Overgrown Sheep").entity(EntityOvergrownSheep.class).id(new ResourceLocation(CommunityGlobals.MOD_ID, "overgrown_sheep"), CommunityGlobals.entity_id++).tracker(80, 3, true).build());
}
 
Example 19
Source File: Sounds.java    From OpenModsLib with MIT License 4 votes vote down vote up
private static void registerSound(IForgeRegistry<SoundEvent> registry, String id) {
	final ResourceLocation resourceLocation = OpenMods.location(id);
	registry.register(new SoundEvent(resourceLocation).setRegistryName(resourceLocation));
}
 
Example 20
Source File: AdvancedRocketryBiomes.java    From AdvancedRocketry with MIT License 2 votes vote down vote up
/**
 * TODO: support id's higher than 255.  
 * Any biome registered through vanilla forge does not need to be registered here
 * @param biome Biome to register with AdvancedRocketry's Biome registry
 * @param iForgeRegistry 
 */
public void registerBiome(Biome biome, IForgeRegistry<Biome> iForgeRegistry) {
	registeredBiomes.add(biome);
	iForgeRegistry.register(biome);
}