-
Posts
6 -
Joined
-
Last visited
Everything posted by Infinituum
-
[1.19.3] Getting correct drops from blocks
Infinituum replied to Infinituum's topic in Modder Support
Ok you're right, sorry. I've already figured it out by myself, next time I'll show some of my code. Thanks anyway -
I was trying to create a Quarry Block and I think I have the basic logic implemented correctly (I've already created a Block class and a BlockEntity class (and all the logic inside it)). The main problem is that I can't figure out how to get the Block drops like it was mined with the correct tool. I'm using `Level.destroyBlock()` and I think I should use `BlockState.getDrops()` to get the drops but I don't know how to use LootContext to get the result I want. Does anyone know how to do it?
-
[1.19.3] Problems with Custom OreGen and PlacedFeature
Infinituum replied to Infinituum's topic in Modder Support
Oh thanks, I wasn't totally understanding what was going on but now I think I can fix it. Thank you so much -
I was following some tutorials on yt and noticed that a lot has changed from 1.19.2 to 1.19.3. My IDE doesn't show me any error but when I try to load the game the error I get is: Registration.java: public class Registration { private Registration() {} private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID); private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); private static final DeferredRegister<Codec<? extends IGlobalLootModifier>> GLM = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, MODID); private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MODID); private static final DeferredRegister<PlacedFeature> PLACED_FEATURES = DeferredRegister.create(Registries.PLACED_FEATURE, MODID); public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops())); public static final RegistryObject<Block> EXAMPLE_CARROT_CROP = BLOCKS.register("example_carrot_crop", () -> new ExCarrotCropBlock(BlockBehaviour.Properties.of(Material.PLANT).noCollission().randomTicks().instabreak().sound(SoundType.CROP).noOcclusion())); public static final RegistryObject<Block> EXAMPLE_ORE = BLOCKS.register("example_ore", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(2.0f))); public static final RegistryObject<Block> DEEPSLATE_EXAMPLE_ORE = BLOCKS.register("deepslate_example_ore", () -> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(2.0f))); public static final RegistryObject<Block> EXAMPLE_ADVANCED_BLOCK = BLOCKS.register("example_advanced_block", ExampleAdvancedBlock::new); public static final RegistryObject<BlockEntityType<ExampleAdvancedBlockEntity>> EXAMPLE_ADVANCED_BLOCK_ENTITY = BLOCK_ENTITIES.register("example_advanced_block_entity", () -> BlockEntityType.Builder.of(ExampleAdvancedBlockEntity::new, EXAMPLE_ADVANCED_BLOCK.get()).build(null)); public static final RegistryObject<Item> EXAMPLE_INGOT = ITEMS.register("example_ingot", () -> new Item(new Item.Properties())); public static final RegistryObject<Item> EXAMPLE_FOOD = ITEMS.register("example_food", () -> new Item(new Item.Properties().food(new FoodProperties.Builder().nutrition(6).saturationMod(0.6F).build()))); public static final RegistryObject<Item> EXAMPLE_CARROT = ITEMS.register("example_carrot", () -> new BlockItem(EXAMPLE_CARROT_CROP.get(), new Item.Properties().food(new FoodProperties.Builder().nutrition(6).saturationMod(0.6F).build()))); public static final RegistryObject<Item> EXAMPLE_PICKAXE = ITEMS.register("example_pickaxe", () -> new PickaxeItem(new ExampleToolTier(), 0, 0, new Item.Properties().stacksTo(1))); public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties())); public static final RegistryObject<Item> EXAMPLE_ADVANCED_BLOCK_ITEM = ITEMS.register("example_advanced_block", () -> new BlockItem(EXAMPLE_ADVANCED_BLOCK.get(), new Item.Properties())); public static final RegistryObject<Item> EXAMPLE_ORE_ITEM = ITEMS.register("example_ore", () -> new BlockItem(EXAMPLE_ORE.get(), new Item.Properties())); public static final RegistryObject<Item> DEEPSLATE_EXAMPLE_ORE_ITEM = ITEMS.register("deepslate_example_ore", () -> new BlockItem(DEEPSLATE_EXAMPLE_ORE.get(), new Item.Properties())); public static final RegistryObject<Item> RAW_EXAMPLE_ORE = ITEMS.register("raw_example_ore", () -> new Item(new Item.Properties())); public static final RegistryObject<Codec<GrassLootModifier>> GRASS_MOD = GLM.register("grass", GrassLootModifier.CODEC); public static final RegistryObject<MenuType<ExampleAdvancedBlockMenu>> EXAMPLE_ADVANCED_BLOCK_CONTAINER = CONTAINERS.register("example_advanced_block_container", () -> IForgeMenuType.create((id, inv, data) -> new ExampleAdvancedBlockMenu(id, data.readBlockPos(), inv, inv.player))); public static final Supplier<List<OreConfiguration.TargetBlockState>> OVERWORLD_EXAMPLE_ORE = Suppliers.memoize(() -> List.of( OreConfiguration.target(new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), EXAMPLE_ORE.get().defaultBlockState()), OreConfiguration.target(new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES), DEEPSLATE_EXAMPLE_ORE.get().defaultBlockState()) )); public static final RegistryObject<PlacedFeature> EXAMPLE_ORE_PLACED = PLACED_FEATURES.register("example_ore_placed", () -> new PlacedFeature(Holder.direct(new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_EXAMPLE_ORE.get(), 7))), CustomOrePlacements.commonOrePlacement(7, HeightRangePlacement.triangle( VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80) ) ) ) ); public static void init() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(bus); BLOCK_ENTITIES.register(bus); ITEMS.register(bus); GLM.register(bus); CONTAINERS.register(bus); PLACED_FEATURES.register(bus); } } The method `init` is called directly from the ExampleMod constructor (main entry point of the mod). The `CustomOrePlacements` class is basically a copy of some of the private methods from the `OrePlacements` class. I've already placed a json file inside `resources/data/examplemod/forge/biome_modifier`: { "type": "forge:add_features", "biomes": "#minecraft:is_overworld", "features": "examplemod:example_ore_placed", "step": "underground_ores" } I was wondering if someone could explain what's wrong with the code and how to fix this problem.
-
[1.19] Questions about ContainerMenus and Slot methods
Infinituum replied to Infinituum's topic in Modder Support
Ok, now I understand, thank you so much! -
I have a few questions about Menus and Slots: What is `slot.onQuickCraft` used for? What is `slot.onTake` used for? When do I have to use `slot.onTake` instead of `slot.setChanged`? I've already looked at the documentation but I was wondering if someone could give me a further explanation on this three methods. I'm assuming there is some kind of logic on what to do when a certain action is triggered (correct me if I'm wrong, like for example taking items from result slot and dropping exp) : how is that implemented?