Search in sources :

Example 11 with FabricItemSettings

use of net.fabricmc.fabric.api.item.v1.FabricItemSettings in project Reborn12K by SlayeRRROAR.

the class OreBlocks method register.

public static void register() {
    // BLOCK
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "topaz_ore"), TOPAZ_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "opal_ore"), OPAL_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "ruby_ore"), RUBY_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "sapphire_ore"), SAPPHIRE_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_topaz_ore"), DEEPSLATE_TOPAZ_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_opal_ore"), DEEPSLATE_OPAL_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_ruby_ore"), DEEPSLATE_RUBY_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_sapphire_ore"), DEEPSLATE_SAPPHIRE_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "manatite_ore"), MANATITE_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_manatite_ore"), DEEPSLATE_MANATITE_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_element_115_ore"), DEEPSLATE_ELEMENT_115_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "chromite_ore"), CHROMITE_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_chromite_ore"), DEEPSLATE_CHROMITE_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_uranium_ore"), DEEPSLATE_URANIUM_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "nether_uranium_ore"), NETHER_URANIUM_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "end_cobalt_ore"), END_COBALT_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "tin_ore"), TIN_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "silver_ore"), SILVER_ORE);
    Registry.register(Registry.BLOCK, new Identifier(Reborn12K.MOD_ID, "deepslate_silver_ore"), DEEPSLATE_SILVER_ORE);
    Reborn12K.LOGGER.info("Registering Ore Blocks for " + Reborn12K.MOD_ID);
    // ITEM
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "topaz_ore"), new BlockItem(TOPAZ_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "opal_ore"), new BlockItem(OPAL_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "ruby_ore"), new BlockItem(RUBY_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "sapphire_ore"), new BlockItem(SAPPHIRE_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_topaz_ore"), new BlockItem(DEEPSLATE_TOPAZ_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_opal_ore"), new BlockItem(DEEPSLATE_OPAL_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_ruby_ore"), new BlockItem(DEEPSLATE_RUBY_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_sapphire_ore"), new BlockItem(DEEPSLATE_SAPPHIRE_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "manatite_ore"), new BlockItem(MANATITE_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_manatite_ore"), new BlockItem(DEEPSLATE_MANATITE_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_element_115_ore"), new BlockItem(DEEPSLATE_ELEMENT_115_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "chromite_ore"), new BlockItem(CHROMITE_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_chromite_ore"), new BlockItem(DEEPSLATE_CHROMITE_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_uranium_ore"), new BlockItem(DEEPSLATE_URANIUM_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "nether_uranium_ore"), new BlockItem(NETHER_URANIUM_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "end_cobalt_ore"), new BlockItem(END_COBALT_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "tin_ore"), new BlockItem(TIN_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "silver_ore"), new BlockItem(SILVER_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Registry.register(Registry.ITEM, new Identifier(Reborn12K.MOD_ID, "deepslate_silver_ore"), new BlockItem(DEEPSLATE_SILVER_ORE, new FabricItemSettings().group(Reborn12KItemGroup.REBORN12K)));
    Reborn12K.LOGGER.info("Registering Ore Block Items for " + Reborn12K.MOD_ID);
}
Also used : Identifier(net.minecraft.util.Identifier) FabricItemSettings(net.fabricmc.fabric.api.item.v1.FabricItemSettings) BlockItem(net.minecraft.item.BlockItem)

Example 12 with FabricItemSettings

use of net.fabricmc.fabric.api.item.v1.FabricItemSettings in project recordable by burgerguy.

the class Recordable method onInitialize.

@Override
public void onInitialize() {
    try {
        // add the entire LMDB code source to the path, so all subsequent classes are loaded by Knot
        // and all assigned mixins are applied to them
        URI lmdbJarUri = this.getClass().getClassLoader().getResource("org/lmdbjava").toURI();
        try (FileSystem fs = FileSystems.newFileSystem(lmdbJarUri, Map.of("create", "true"))) {
            for (Path jarRootDir : fs.getRootDirectories()) {
                FabricLauncherBase.getLauncher().addToClassPath(jarRootDir);
            }
        }
    } catch (Throwable t) {
        LOGGER.error("Unable to force load LMDB into Knot", t);
    }
    // block registry
    Registry.register(Registry.BLOCK, RecorderBlock.IDENTIFIER, RecorderBlock.INSTANCE);
    Registry.register(Registry.BLOCK, RecordPlayerBlock.IDENTIFIER, RecordPlayerBlock.INSTANCE);
    // item registry
    Registry.register(Registry.ITEM, RecorderBlock.IDENTIFIER, new BlockItem(RecorderBlock.INSTANCE, new FabricItemSettings().group(CreativeModeTab.TAB_MISC)));
    Registry.register(Registry.ITEM, RecordPlayerBlock.IDENTIFIER, new BlockItem(RecordPlayerBlock.INSTANCE, new FabricItemSettings().group(CreativeModeTab.TAB_MISC)));
    Registry.register(Registry.ITEM, CopperRecordItem.IDENTIFIER, CopperRecordItem.INSTANCE);
    // block entity registry
    Registry.register(Registry.BLOCK_ENTITY_TYPE, RecorderBlockEntity.IDENTIFIER, RecorderBlockEntity.INSTANCE);
    Registry.register(Registry.BLOCK_ENTITY_TYPE, RecordPlayerBlockEntity.IDENTIFIER, RecordPlayerBlockEntity.INSTANCE);
    // color provider registry
    ColorProviderRegistry.ITEM.register(CopperRecordItem::getColor, CopperRecordItem.INSTANCE);
    // event registry
    ServerLifecycleEvents.SERVER_STARTING.register(server -> {
        // kinda conc, but should be fine for now
        ((ScoreDatabaseContainer) server).setScoreDatabase(new ScoreDatabase(server.getWorldPath(LevelResource.ROOT).resolve(SCORE_DATABASE_FILE_NAME)));
    });
    ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
        ((ScoreDatabaseContainer) server).getScoreDatabase().close();
    });
    // force stop all recorders, fixing block state
    ServerWorldEvents.UNLOAD.register((server, serverLevel) -> {
        ((ScoreRecorderRegistryContainer) serverLevel).getScoreRecorderRegistry().removeAndCloseAll();
    });
    // these are in the server tick because some packet handling is done outside the world tick
    // (irr)
    ServerTickEvents.START_SERVER_TICK.register(server -> {
        for (ServerLevel serverLevel : server.getAllLevels()) {
            ((ScoreRecorderRegistryContainer) serverLevel).getScoreRecorderRegistry().tick();
        }
    });
    // networking registry
    ServerPlayNetworking.registerGlobalReceiver(REQUEST_SCORE_ID, (server, player, handler, buffer, responseSender) -> {
        long scoreId = buffer.readLong();
        ScoreDatabase scoreDatabase = ((ScoreDatabaseContainer) server).getScoreDatabase();
        try (ScoreDatabase.ScoreRequest scoreRequest = scoreDatabase.requestScore(scoreId);
            MemoryStack memoryStack = MemoryStack.stackPush()) {
            ByteBuffer scoreData = scoreRequest.getData();
            int packetSize = scoreData != null ? Long.BYTES + scoreData.capacity() : Long.BYTES;
            FriendlyByteBuf newPacketBuffer = new FriendlyByteBuf(Unpooled.wrappedBuffer(memoryStack.malloc(packetSize)));
            newPacketBuffer.resetWriterIndex();
            newPacketBuffer.writeLong(scoreId);
            if (scoreData != null) {
                newPacketBuffer.writeBytes(scoreData);
            } else {
                LOGGER.info("Player " + player + " requested invalid score id " + scoreId);
            }
            responseSender.sendPacket(Recordable.SEND_SCORE_ID, newPacketBuffer);
        }
    });
}
Also used : Path(java.nio.file.Path) FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) ServerLevel(net.minecraft.server.level.ServerLevel) ScoreDatabase(com.github.burgerguy.recordable.server.database.ScoreDatabase) ScoreDatabaseContainer(com.github.burgerguy.recordable.server.database.ScoreDatabaseContainer) FabricItemSettings(net.fabricmc.fabric.api.item.v1.FabricItemSettings) URI(java.net.URI) BlockItem(net.minecraft.world.item.BlockItem) ByteBuffer(java.nio.ByteBuffer) CopperRecordItem(com.github.burgerguy.recordable.shared.item.CopperRecordItem) MemoryStack(org.lwjgl.system.MemoryStack) FileSystem(java.nio.file.FileSystem)

Example 13 with FabricItemSettings

use of net.fabricmc.fabric.api.item.v1.FabricItemSettings in project fabric-webstream by mindstorm38.

the class WebStreamerMod method onInitialize.

@Override
public void onInitialize() {
    DISPLAY_BLOCK = new DisplayBlock();
    DISPLAY_ITEM = new DisplayBlockItem(DISPLAY_BLOCK, new FabricItemSettings().group(ItemGroup.REDSTONE));
    Registry.register(Registry.BLOCK, "webstreamer:display", DISPLAY_BLOCK);
    Registry.register(Registry.ITEM, "webstreamer:display", DISPLAY_ITEM);
    DISPLAY_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, "webstreamer:display", FabricBlockEntityTypeBuilder.create(DisplayBlockEntity::new, DISPLAY_BLOCK).build());
    DisplayNetworking.registerDisplayUpdateReceiver();
    LOGGER.info("WebStreamer started.");
}
Also used : DisplayBlockItem(fr.theorozier.webstreamer.display.DisplayBlockItem) FabricItemSettings(net.fabricmc.fabric.api.item.v1.FabricItemSettings) DisplayBlock(fr.theorozier.webstreamer.display.DisplayBlock)

Example 14 with FabricItemSettings

use of net.fabricmc.fabric.api.item.v1.FabricItemSettings in project Spelunker by Leximon.

the class SpelunkerMod method onInitialize.

@Override
public void onInitialize() {
    AMETHYST_DUST = Registry.register(Registry.ITEM, identifier("amethyst_dust"), new Item(new FabricItemSettings().group(ItemGroup.MISC)));
    STATUS_EFFECT_SPELUNKER = Registry.register(Registry.STATUS_EFFECT, identifier("spelunker"), new SpelunkerStatusEffect());
    SPELUNKER_POTION = Registry.register(Registry.POTION, identifier("spelunker"), new Potion(new StatusEffectInstance(STATUS_EFFECT_SPELUNKER, 20 * 90)));
    LONG_SPELUNKER_POTION = Registry.register(Registry.POTION, identifier("long_spelunker"), new Potion(new StatusEffectInstance(STATUS_EFFECT_SPELUNKER, 20 * 90 * 2)));
    // register recipes
    if (SpelunkerConfig.allowPotionBrewing) {
        BrewingRecipeRegistryAccessor.spelunkerRegisterPotionRecipe(Potions.NIGHT_VISION, AMETHYST_DUST, SPELUNKER_POTION);
        BrewingRecipeRegistryAccessor.spelunkerRegisterPotionRecipe(Potions.LONG_NIGHT_VISION, AMETHYST_DUST, LONG_SPELUNKER_POTION);
        BrewingRecipeRegistryAccessor.spelunkerRegisterPotionRecipe(SPELUNKER_POTION, Items.REDSTONE, LONG_SPELUNKER_POTION);
    }
    // load config
    try {
        SpelunkerConfig.createDefaultConfig();
        SpelunkerConfig.loadConfig();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // add potion to loot tables
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        for (SpelunkerConfig.LootTableEntry entry : SpelunkerConfig.lootTables) {
            if (entry.id().equals(id)) {
                LootNumberProvider rollProvider;
                if (entry.min() == entry.max())
                    rollProvider = ConstantLootNumberProvider.create(entry.min());
                else
                    rollProvider = UniformLootNumberProvider.create(entry.min(), entry.max());
                table.pool(FabricLootPoolBuilder.builder().rolls(rollProvider).with(ItemEntry.builder(Items.POTION).apply(() -> SetPotionLootFunction.builder(SPELUNKER_POTION).build()).weight(entry.shortChance())).with(ItemEntry.builder(Items.POTION).apply(() -> SetPotionLootFunction.builder(LONG_SPELUNKER_POTION).build()).weight(entry.longChance())).with(ItemEntry.builder(Items.AIR).weight(100 - (entry.shortChance() + entry.longChance()))));
            }
        }
        if (AMETHYST_CLUSTER_LOOT_TABLE.equals(id) && SpelunkerConfig.allowPotionBrewing) {
            table.pool(FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).withCondition(MatchToolLootCondition.builder(ItemPredicate.Builder.create().enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, NumberRange.IntRange.ANY))).invert().build()).with(ItemEntry.builder(AMETHYST_DUST).weight(1)).with(ItemEntry.builder(Items.AIR).weight(9)));
        }
    });
}
Also used : Item(net.minecraft.item.Item) SpelunkerConfig(de.leximon.spelunker.core.SpelunkerConfig) EnchantmentPredicate(net.minecraft.predicate.item.EnchantmentPredicate) Potion(net.minecraft.potion.Potion) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) FabricItemSettings(net.fabricmc.fabric.api.item.v1.FabricItemSettings) UniformLootNumberProvider(net.minecraft.loot.provider.number.UniformLootNumberProvider) ConstantLootNumberProvider(net.minecraft.loot.provider.number.ConstantLootNumberProvider) LootNumberProvider(net.minecraft.loot.provider.number.LootNumberProvider) IOException(java.io.IOException)

Example 15 with FabricItemSettings

use of net.fabricmc.fabric.api.item.v1.FabricItemSettings in project Apollo-MC by RyanGar46.

the class BlockManager method register.

public static void register() {
    Apollo.LOGGER.info("Registering blocks");
    registerBlock(FUEL, "fuel");
    registerBlock(LAUNCH_PAD, "launchpad", ItemGroupManager.APOLLO);
    registerBlock(LUNAR_COBBLESTONE, "lunar_cobblestone", ItemGroupManager.MOON);
    registerBlock(LUNAR_IRON_ORE, "lunar_iron_ore", ItemGroupManager.MOON);
    registerBlock(LUNAR_SOIL, "lunar_soil", ItemGroupManager.MOON);
    registerBlock(LUNAR_STONE, "lunar_stone", ItemGroupManager.MOON);
    registerBlock(METEORITE, "meteorite", new FabricItemSettings().fireproof().group(ItemGroupManager.APOLLO));
    registerBlock(OIL, "oil");
    registerBlock(REINFORCED_IRON_BLOCK, "reinforced_iron_block", new FabricItemSettings().fireproof().group(ItemGroupManager.APOLLO));
}
Also used : FabricItemSettings(net.fabricmc.fabric.api.item.v1.FabricItemSettings)

Aggregations

FabricItemSettings (net.fabricmc.fabric.api.item.v1.FabricItemSettings)26 Identifier (net.minecraft.util.Identifier)12 BlockItem (net.minecraft.item.BlockItem)9 FabricBlockSettings (net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings)6 ResourceLocation (net.minecraft.resources.ResourceLocation)4 Item (net.minecraft.world.item.Item)4 Block (net.minecraft.world.level.block.Block)4 SimpleItem (com.simplycmd.featherlib.registry.SimpleItem)3 FlammableBlockRegistry (net.fabricmc.fabric.api.registry.FlammableBlockRegistry)3 Item (net.minecraft.item.Item)3 Items (net.minecraft.world.item.Items)3 Blocks (net.minecraft.world.level.block.Blocks)3 MaterialColor (net.minecraft.world.level.material.MaterialColor)3 BCLib (ru.bclib.BCLib)3 NamedBlockTags (ru.bclib.api.tag.NamedBlockTags)3 NamedCommonBlockTags (ru.bclib.api.tag.NamedCommonBlockTags)3 NamedCommonItemTags (ru.bclib.api.tag.NamedCommonItemTags)3 NamedItemTags (ru.bclib.api.tag.NamedItemTags)3 TagAPI (ru.bclib.api.tag.TagAPI)3 TagLocation (ru.bclib.api.tag.TagAPI.TagLocation)3