为什么我在使用 ItemSpatialMark 时不能使用 setUnlocalizedName(String) return undefined
Why can't I use setUnlocalizedName(String) return undefined when I use ItemSpatialMark
package itsjustlogic.logicmod;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "logic", name = "Logic's Mod", version = "1.0")
public class LogicsMod {
public static Item itemSpatialMark;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
//Item/Block init and reg
//Config handling
itemSpatialMark = new ItemSpatialMark().setUnlocalizedName("ItemSpatialMark");
GameRegistry.registerItem(itemSpatialMark, itemSpatialMark.getUnlocalizedName().substring(5));
}
@EventHandler
public void init(FMLInitializationEvent event){
//Proxy, TileEntity, entity, GUI, and Packet Reg
}
@EventHandler
public void postInit(FMLPostInitializationEvent event){
}
}
错误:未定义 ItemSpatialMark 类型的方法 setUnlocalizedName(String)
我知道这是一个基本问题,可能有一个简单的解决方法,但我是使用 Forge 进行编码的新手。请帮助:(
在你的 ItemSpacialMark
class 中,确保你像这样扩展 net.minecraft.item.Item
class,
public class ItemSpacialMark extends Item { // Your code here }
并且,最好通过像这样将参数传递给构造函数来在 setUnlocalizedName(String name)
方法中分配名称,
public ItemSpacialMark(String unlocalizedName){
setRegistryName("reg-name");
setUnlocalizedName(unlocalizedName);
}
并且,在调用构造函数时,
itemSpacialMark = new ItemSpacialMark("some name");
package itsjustlogic.logicmod;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "logic", name = "Logic's Mod", version = "1.0")
public class LogicsMod {
public static Item itemSpatialMark;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
//Item/Block init and reg
//Config handling
itemSpatialMark = new ItemSpatialMark().setUnlocalizedName("ItemSpatialMark");
GameRegistry.registerItem(itemSpatialMark, itemSpatialMark.getUnlocalizedName().substring(5));
}
@EventHandler
public void init(FMLInitializationEvent event){
//Proxy, TileEntity, entity, GUI, and Packet Reg
}
@EventHandler
public void postInit(FMLPostInitializationEvent event){
}
}
错误:未定义 ItemSpatialMark 类型的方法 setUnlocalizedName(String)
我知道这是一个基本问题,可能有一个简单的解决方法,但我是使用 Forge 进行编码的新手。请帮助:(
在你的 ItemSpacialMark
class 中,确保你像这样扩展 net.minecraft.item.Item
class,
public class ItemSpacialMark extends Item { // Your code here }
并且,最好通过像这样将参数传递给构造函数来在 setUnlocalizedName(String name)
方法中分配名称,
public ItemSpacialMark(String unlocalizedName){
setRegistryName("reg-name");
setUnlocalizedName(unlocalizedName);
}
并且,在调用构造函数时,
itemSpacialMark = new ItemSpacialMark("some name");