use of net.minecraftforge.fml.RegistryObject in project Structurize by ldtteam.
the class IBlockCollection method create.
/**
* Constructs and registers each block in the collection
* See interface comments for the preferred content.
* @param registrar the DeferredRegistry instance to apply the block to
* @param itemRegistrar the DeferredRegistry instance to apply the item to
* @param group the item group (or creative tab) to place this block in
* @param creationListener gets fired for each block being registered with specific block type, used for client rendering register
* @param types a selection of each block type that is part of the collection
* @return each registered block in the collection
*/
default List<RegistryObject<Block>> create(DeferredRegister<Block> registrar, DeferredRegister<Item> itemRegistrar, ItemGroup group, BiConsumer<BlockType, RegistryObject<Block>> creationListener, BlockType... types) {
List<RegistryObject<Block>> results = new LinkedList<>();
for (BlockType type : types) {
// J9+ has incompatibilities with J8-compiled default interfaces that use lambda generated suppliers.
// Do not replace the anonymous suppliers below with a lambda.
RegistryObject<Block> block = registrar.register(type.withSuffix(getName(), getPluralName()), new Supplier<Block>() {
@Override
public Block get() {
return type.constructor.apply(getProperties());
}
});
itemRegistrar.register(type.withSuffix(getName(), getPluralName()), new Supplier<Item>() {
@Override
public Item get() {
return new BlockItem(block.get(), new Item.Properties().tab(group));
}
});
creationListener.accept(type, block);
results.add(block);
}
return results;
}
use of net.minecraftforge.fml.RegistryObject in project ResourcefulBees by Resourceful-Bees.
the class RegistryHandler method registerBee.
private static void registerBee(String name, float sizeModifier) {
final RegistryObject<EntityType<? extends CustomBeeEntity>> customBeeEntity = ENTITY_TYPES.register(name + "_bee", () -> EntityType.Builder.<ResourcefulBee>of((type, world) -> new ResourcefulBee(type, world, name), ModConstants.BEE_MOB_CATEGORY).sized(0.7F * sizeModifier, 0.6F * sizeModifier).build(name + "_bee"));
ModItems.ITEMS.register(name + "_bee_spawn_egg", () -> new BeeSpawnEggItem(customBeeEntity, 0xffcc33, 0x303030, name, new Item.Properties().tab(ItemGroupResourcefulBees.RESOURCEFUL_BEES)));
ModEntities.getModBees().put(name, customBeeEntity);
}
use of net.minecraftforge.fml.RegistryObject in project trofers by ochotonida.
the class LootTables method addBlockLootTables.
private void addBlockLootTables() {
CopyNbt.Builder copyNbtBuilder = CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY).copy("Trophy", "BlockEntityTag.Trophy");
for (RegistryObject<TrophyBlock> trophy : ModBlocks.TROPHIES) {
ResourceLocation location = new ResourceLocation(Trofers.MODID, "blocks/" + trophy.getId().getPath());
LootTable.Builder lootTable = LootTable.lootTable().withPool(LootPool.lootPool().add(ItemLootEntry.lootTableItem(trophy.get()).apply(copyNbtBuilder)));
lootTables.add(Pair.of(() -> builder -> builder.accept(location, lootTable), LootParameterSets.BLOCK));
}
}
use of net.minecraftforge.fml.RegistryObject in project Wings by pau101.
the class Proxy method setup.
protected void setup(FMLCommonSetupEvent event) {
CapabilityManager.INSTANCE.register(Flight.class, SimpleStorage.ofVoid(), FlightDefault::new);
CapabilityManager.INSTANCE.register(InSomniable.class, SimpleStorage.ofVoid(), InSomniable::new);
event.enqueueWork(() -> {
BiConsumer<IItemProvider, RegistryObject<Item>> reg = (item, obj) -> {
BrewingRecipeRegistry.addRecipe(new PotionMix(Potions.SLOW_FALLING, Ingredient.of(item), new ItemStack(obj.get())));
BrewingRecipeRegistry.addRecipe(new PotionMix(Potions.LONG_SLOW_FALLING, Ingredient.of(item), new ItemStack(obj.get())));
};
reg.accept(Items.FEATHER, WingsItems.ANGEL_WINGS_BOTTLE);
reg.accept(Items.RED_DYE, WingsItems.PARROT_WINGS_BOTTLE);
reg.accept(WingsItems.BAT_BLOOD_BOTTLE.get(), WingsItems.BAT_WINGS_BOTTLE);
reg.accept(Items.BLUE_DYE, WingsItems.BLUE_BUTTERFLY_WINGS_BOTTLE);
reg.accept(Items.LEATHER, WingsItems.DRAGON_WINGS_BOTTLE);
reg.accept(Items.BONE, WingsItems.EVIL_WINGS_BOTTLE);
reg.accept(Items.OXEYE_DAISY, WingsItems.FAIRY_WINGS_BOTTLE);
reg.accept(Items.BLAZE_POWDER, WingsItems.FIRE_WINGS_BOTTLE);
reg.accept(Items.ORANGE_DYE, WingsItems.MONARCH_BUTTERFLY_WINGS_BOTTLE);
reg.accept(Items.SLIME_BALL, WingsItems.SLIME_WINGS_BOTTLE);
});
}
use of net.minecraftforge.fml.RegistryObject in project relics by SSKirillSS.
the class ItemRegistry method syncItemLists.
public static void syncItemLists() {
registeredRelics = ITEMS.getEntries().stream().filter(RegistryObject::isPresent).map(RegistryObject::get).filter(item -> item instanceof RelicItem).map(item -> (RelicItem<?>) item).collect(Collectors.toList());
registeredRunes = ITEMS.getEntries().stream().filter(RegistryObject::isPresent).map(RegistryObject::get).filter(item -> item instanceof RuneItem).map(item -> (RuneItem) item).collect(Collectors.toList());
slotModifiers = ForgeRegistries.ITEMS.getEntries().stream().map(Map.Entry::getValue).filter(entry -> entry instanceof RelicItem).map(item -> (RelicItem<?>) item).filter(relic -> relic.getSlotModifiers(new ItemStack(relic)) != null).filter(relic -> !relic.getSlotModifiers(new ItemStack(relic)).getModifiers().isEmpty()).collect(Collectors.toList());
attributeModifiers = ForgeRegistries.ITEMS.getEntries().stream().map(Map.Entry::getValue).filter(entry -> entry instanceof RelicItem).map(item -> (RelicItem<?>) item).filter(relic -> relic.getAttributeModifiers(new ItemStack(relic)) != null).filter(relic -> !relic.getAttributeModifiers(new ItemStack(relic)).getAttributes().isEmpty()).collect(Collectors.toList());
}
Aggregations