Нужна помощь с блоком

У меня есть 2 вопроса:1. Как сделать чтобы на блоке срабатывала удача?
2. Как сделать чтобы из блока падал опыт?
Версия 1.7.10
 
DGrayMan888 написал(а):
1. Как сделать чтобы на блоке срабатывала удача?
Отсыпь. Или объясни.

DGrayMan888 написал(а):
2. Как сделать чтобы из блока падал опыт?
Код:
public int getExpDrop(IBlockAccess world, BlockPos pos, int fortune)
{
        return 999;
}
 
TaoGunner написал(а):
Отсыпь. Или объясни.
У меня из блока руды падает один предмет, даже если использую кирку на удачу, а нужно чтобы как из других руд. И ещё вопрос ( сильно много вопросов задаю ): что тут не так у меня всё равно опыт не падает, ткните носом, пожалуйста
5220aaf1f5a3.jpg
 
Попробуй:
Код:
    @Override
    public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
        ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
//тут пусть работает твоя фантазия
        return drops;
    }
 
С удачей разобрался декомпилировав applied energistics 2 и найдя код в руде кварца.
P.S. Теперь с крафтом возникла проблема:
Код:
GameRegistry.addRecipe(new ItemStack(UltraSuperOres.rubypickaxe, 1), 
                new Object[]{ "XXX", " Y ", " Y ",
                ('X'), UltraSuperOres.ruby, ('Y'), Items.stick});

Запускаю, крашит
Репорт:
Код:
---- Minecraft Crash Report ----
// Uh... Did I do that?

Time: 19.08.15 17:43
Description: Initializing game

java.lang.NullPointerException: Initializing game
 at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:236)
 at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250)
 at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245)
 at com.dgrayman888.ultrasuperores.UltraSuperOres.preLoad(UltraSuperOres.java:32)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
 at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
 at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
 at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
 at com.google.common.eventbus.EventBus.post(EventBus.java:275)
 at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
 at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
 at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
 at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
 at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
 at com.google.common.eventbus.EventBus.post(EventBus.java:275)
 at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
 at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556)
 at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
 at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
 at net.minecraft.client.Minecraft.run(Minecraft.java:942)
 at net.minecraft.client.main.Main.main(Main.java:164)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
 at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
 at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
 at GradleStart.main(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
 at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:236)
 at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250)
 at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245)
 at com.dgrayman888.ultrasuperores.UltraSuperOres.preLoad(UltraSuperOres.java:32)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
 at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
 at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
 at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
 at com.google.common.eventbus.EventBus.post(EventBus.java:275)
 at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
 at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
 at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
 at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
 at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
 at com.google.common.eventbus.EventBus.post(EventBus.java:275)
 at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
 at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556)
 at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
 at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

-- Initialization --
Details:
Stacktrace:
 at net.minecraft.client.Minecraft.run(Minecraft.java:942)
 at net.minecraft.client.main.Main.main(Main.java:164)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
 at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
 at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
 at GradleStart.main(Unknown Source)

-- System Details --
Details:
 Minecraft Version: 1.7.10
 Operating System: Windows XP (x86) version 5.1
 Java Version: 1.7.0_80, Oracle Corporation
 Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
 Memory: 967138352 bytes (922 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
 JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
 AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
 IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 5 mods loaded, 5 mods active
 States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
 UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
 UCH FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) 
 UCH Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) 
 UCE ultrasuperores{0.0.1} [Ultra Super Ore's] (bin) 
 UCH examplemod{1.0} [Example Mod] (bin) 
 GL info: ' Vendor: 'NVIDIA Corporation' Version: '3.2.0' Renderer: 'GeForce GT 240/PCI/SSE2'
 Launched Version: 1.7.10
 LWJGL: 2.9.1
 OpenGL: GeForce GT 240/PCI/SSE2 GL version 3.2.0, NVIDIA Corporation
 GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

 Is Modded: Definitely; Client brand changed to 'fml,forge'
 Type: Client (map_client.txt)
 Resource Packs: []
 Current Language: English (US)
 Profiler Position: N/A (disabled)
 Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
 Anisotropic Filtering: Off (1)
-------------------------------------------------------------------------
P.S.S Спасибо всем
 
DGrayMan888 попробуй добавить твой рецепт в init или в postInit.
 
А еще рецепт должен быть написан в последнюю очередь.То есть в самом низу postinit / init
 
Ну у тебя в гл. классе есть метод 
Код:
public void init(FMLInitializationEvent event){
}
Есть?Вот туда и пиши свой рецепт.
 
Вместо init стоял preLoad, изменил. Крафт был там и написан, но если я ставлю вместо своего рубина предмет из майнкрафта, то всё работает. Также узнал, что не принимается только рубин из мода, с рудой крафт работает
 
DGrayMan888, есть предположение: ты не зарегистрировал предмет. Трудно предположить из-за чего ещё может быть краш, не видя код.
 
Скидываю коды:
Гл. класс
Код:
package com.dgrayman888.ultrasuperores;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

@Mod (modid = "ultrasuperores", name = "Ultra Super Ore's", version = "0.0.1")

public class UltraSuperOres {
    
    public static Block ruby_ore;
    
    public static Item ruby_pickaxe;
    
    public static Item ruby;
    
    public static Item copper_ingot;
    
    @EventHandler
    public void init(FMLPreInitializationEvent event)
    {
        ruby_ore = new Ruby_Ore();
        GameRegistry.registerBlock(ruby_ore, "Ruby_Ore");
        
        ruby_pickaxe = new Ruby_Pickaxe().setUnlocalizedName("ruby_pickaxe");
        GameRegistry.registerItem(ruby_pickaxe, "ruby_pickaxe");
        
        GameRegistry.addRecipe(new ItemStack(UltraSuperOres.ruby_pickaxe, 1), 
                new Object[]{ "XXX", " Y ", " Y ",
                ('X'), UltraSuperOres.ruby, ('Y'), Items.stick});
        
        ruby = new Ruby();
        GameRegistry.registerItem(ruby, "ruby");

        copper_ingot = new Copper_Ingot();
        GameRegistry.registerItem(copper_ingot, "copper_ingot");        
}
}
Предмет(Рубин)
Код:
package com.dgrayman888.ultrasuperores;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class Ruby extends Item {
    protected Ruby() {
    this.setCreativeTab(CreativeTabs.tabMaterials);
    this.setTextureName("ultrasuperores:ruby");
    this.setUnlocalizedName("ruby");
}
}
 
Код:
//--reg_item--//Сначала регистрация

        ruby_pickaxe = new Ruby_Pickaxe().setUnlocalizedName("ruby_pickaxe");
        GameRegistry.registerItem(ruby_pickaxe, "ruby_pickaxe");

        ruby = new Ruby();
        GameRegistry.registerItem(ruby, "ruby");

//--reg_recipe--//Потом их в рецепты.

        GameRegistry.addRecipe(new ItemStack(UltraSuperOres.ruby_pickaxe, 1), 
                new Object[]{ "XXX", " Y ", " Y ",
                ('X'), UltraSuperOres.ruby, ('Y'), Items.stick});

}
}

Код:
    public Ruby() {
    super();
    this.setCreativeTab(CreativeTabs.tabMaterials);
    this.setTextureName("ultrasuperores:ruby");
    this.setUnlocalizedName("ruby");
}
[merge_posts_bbcode]Добавлено: 20.08.2015 23:41:09[/merge_posts_bbcode]

DGrayMan888 написал(а):
Вместо init стоял preLoad
Ты просто переименовал метод, а мы имели ввиду:
FMLPreInitializationEvent,
FMLInitializationEvent,
FMLPostInitializationEvent,
 
Назад
Сверху