@ObjectHolder(Doge.MODID)
public class ModObjects {
public static final Item doge = null;
public static final Block fishless_ice = null;
public static final ItemSpell inf_food_bag = null;
public static final ItemSpell double_death = null;
public static final ItemSpell expelliarmus = null;
public static final ItemSpell modearkar = null;
public static final ItemSpell alohomora = null;
public static final ItemSpell polymorph = null;
}
import static cn.glycol.doge.ModObjects.*;
@Mod.EventBusSubscriber
public class RegistrationEvent {
private static RegistryEvent.Register<Item> itemEvent;
private static RegistryEvent.Register<Block> blockEvent;
@SubscribeEvent
public static void onItemRegistration(RegistryEvent.Register<Item> evt) {
itemEvent = evt;
registerItem(new ItemDoge());
registerBlockItem(fishless_ice);
registerSpell("inf_food_bag", new SpellInfFoodBag());
registerSpell("double_death", new SpellDoubleDeath());
registerSpell("expelliarmus", new SpellExpelliarmus());
registerSpell("modearkar" , new SpellModearkar());
registerSpell("alohomora" , new SpellAlohomora());
registerSpell("polymorph" , new SpellPolymorph());
}
@SubscribeEvent
public static void onBlockRegistration(RegistryEvent.Register<Block> evt) {
blockEvent = evt;
registerBlock(new BlockFishlessIce());
}
@SubscribeEvent
public static void onModelRegistration(ModelRegistryEvent evt) {
registerModel(doge);
registerModel(fishless_ice);
registerModel(inf_food_bag);
registerModel(double_death);
registerModel(expelliarmus);
registerModel(modearkar);
registerModel(alohomora);
registerModel(polymorph);
}
private static void registerItem(Item item) {
if(itemEvent != null) itemEvent.getRegistry().register(item);
}
private static void registerSpell(String registry, IModSpell spell) {
registerItem(new ItemSpell(registry, spell));
}
private static void registerBlock(Block block) {
if(blockEvent != null) blockEvent.getRegistry().register(block);
}
private static void registerBlockItem(Block block) {
registerItem(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
private static void registerModel(Item item) {
registerModel(item, 0);
}
private static void registerModel(Item item, int metadata) {
LogManager.getLogger().info("注册模型 {} {}", item.getRegistryName(), metadata);
ModelLoader.setCustomModelResourceLocation(item, metadata, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
private static void registerModel(Block block) {
registerBlock(block);
}
private static void registerModel(Block block, int metadata) {
registerModel(Item.getItemFromBlock(block), metadata);
}
}