Jump to content

Taskkill

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by Taskkill

  1. 2 minutes ago, WOTBLITZ said:

    No, the slot is handled in the server.  Are you making a client-side only mod? If not create a keybinding and check if it is pressed on the client and then send a packet to tell the server that, that key has been pressed and don't forget which player pressed the key. on the server get the inventory from the player and move the items around there. 

    How to do at the server ?

  2. @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);
    	}
    	
    }

     

  3. [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

  4. 2 minutes ago, Cadiboo said:

    That method formats/translates a translation key. Example: item.dirt.name -> Dirt.

    I know. You don't understand what I mean. Maybe It's because of my poor English.

    The book, just when I open it, it'll read the I18n keys and automatically translate to the content.

  5. Just now, Cadiboo said:

    What do you mean

    ? I18n is an API for internationalising messages.

     

     

     

    Ummm, I wanna a book that can auto get the content from I18n from the key given by ItemStack(or NBT).

  6. 5 minutes ago, DavidM said:

    Someone's been meming around with Leeroy ; )

     

    As far as I know (correct me if I'm wrong), the NBT structure of pages in a book is not simply a list of strings.

     

    The page structures in the NBT of a written book is something like:

    
    ["{\"text\":\"Text on page 1\"}", "{\"text\":\"Text on page 2\"}"]

    As you can see, the page structures are similar to that of a json object, but represented in the form of strings.

    Therefore, instead of just appending the content to the NBT list, try adding strings in the format shown above.

    
    nbtList.add(String.format("{\"text\":\"%s\"}", pageText)); // Adds a page to the book. "pageText" specifies the text on the page.

     

    I am pretty sure there are alternatives to creating a written book by manually adding NBTs, but I don't really know any. Sorry.

     

    P.S. 兄弟看逗鱼时刻吗?;)

    You're right, thanks!

    (看啊,交个朋友?)

    • Haha 1
  7. The problem happens when I create my custom Written Book.

    This is my book builder.

    public static class BookBuilder {
    		
    		NBTTagList pages = new NBTTagList();
    		NBTTagCompound nbt = new NBTTagCompound();
    		
    		public BookBuilder(String title) {
    			this.setTitle(title);
    		}
    		
    		public BookBuilder addPage(String content) {
    			pages.appendTag(new NBTTagString(content));
    			return this;
    		}
    		
    		public BookBuilder setTitle(String title) {
    			nbt.setString("title", title);
    			return this;
    		}
    		
    		public BookBuilder setAuthor(String author) {
    			nbt.setString("author", author);
    			return this;
    		}
    		
    		public ItemStack toBook() {
    			ItemStack book = new ItemStack(Items.WRITTEN_BOOK);
    			nbt.setTag("pages", pages);
    			book.setTagCompound(nbt);
    			return book;
    		}
    		
    	}

    And use it to create a ItemStack.

    ItemStack book = new WrittenBookHelper.BookBuilder(I18n.format("item.LeeroyJenkins.meme.title"))
    						.setAuthor("Taskeren")
    						.addPage(I18n.format("item.LeeroyJenkins.meme.0"))
    						.addPage(I18n.format("item.LeeroyJenkins.meme.1"))
    						.toBook();

    Result is that I got a book with only the text before the first space.

    For example, 

    item.LeeroyJenkins.meme.1=在炉石传说中,卡牌描述的内容为“At least we got Angry Chicken(至少我们还有愤怒的小鸡)”以及繁体中文中的火车王叫做“炸鸡勇者”。

    The book can only have

    在炉石传说中,卡牌描述的内容为“At

     

    Missing the text after the first space.

    Is there a better BookBuilder? Or how can I let it works as I expect?

    Finally, please excuse my poor English.

×
×
  • Create New...

Important Information

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