Jump to content

Recommended Posts

Posted
[21:24:54] [Client thread/WARN] [FML]: ****************************************
[21:24:54] [Client thread/WARN] [FML]: * Registry Block: The object Block{doge:fishless_ice} has been registered twice for the same name doge:fishless_ice.
[21:24:54] [Client thread/WARN] [FML]: *  at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:307)
[21:24:54] [Client thread/WARN] [FML]: *  at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:288)
[21:24:54] [Client thread/WARN] [FML]: *  at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:120)
[21:24:54] [Client thread/WARN] [FML]: *  at cn.glycol.doge.event.RegistrationEvent.registerBlock(RegistrationEvent.java:76)
[21:24:54] [Client thread/WARN] [FML]: *  at cn.glycol.doge.event.RegistrationEvent.registerModel(RegistrationEvent.java:93)
[21:24:54] [Client thread/WARN] [FML]: *  at cn.glycol.doge.event.RegistrationEvent.onModelRegistration(RegistrationEvent.java:57)...
[21:24:54] [Client thread/WARN] [FML]: ****************************************

What's the right way to register a Block with ItemBlock, and register its model.

The document is... ummm

Posted (edited)

You don't register a Block from an ItemBlock; instead, you get an ItemBlock from a Block, then register the ItemBlock as an Item.

To get an (registered) ItemBlock from a Block (which I believe is what you are trying to do during ModelRegistryEvent), use Item::getItemFromBlock.

 

Please post your code so we can figure out what exactly went wrong.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted (edited)
@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);
	}
	
}

 

Edited by Taskkill
Posted
  On 6/17/2019 at 2:01 PM, diesieben07 said:

Also, you can't have ModelRegistryEvent there. It must be in a separate, client-only event handler.

Expand  

Does ModelRegistryEvent also trigger on the server side?

Some tips:

  Reveal hidden contents

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.