hello i will try to have the item gategory same as the creative inventory for exemple : diamond sword -> combat ; stick -> materials is it possible ? if is it how can i get it ?
I Don't Think There Is A Method For This... But if you have enough free time, you can just make a switch statment for each item That exists in the game. Not a very efficient way, but still the only one i can think of.
@oriamrm @timtower @rushr93 Or you use lovely Reflection. The calls are not optimized, rely on version dependend imports and are only as a proof-of-concept. Code:java @EventHandler public void onPlayerHit(PlayerInteractEvent event) { if (!event.hasItem()) { return; } ReflectResponse<Object> value; if (event.getItem().getType().isBlock()) { // Block Block block = CraftMagicNumbers.getBlock(event.getMaterial()); value = ReflectionUtil.getFieldValue(Block.class, block, (field) -> field.getType() == CreativeModeTab.class); } else { // Item Item item = CraftMagicNumbers.getItem(event.getItem().getType()); value = ReflectionUtil.getFieldValue(Item.class, item, (field) -> field.getType() == CreativeModeTab.class); } if (value == null || !value.isValuePresent()) { event.getPlayer().sendMessage(TextUtils.colorize("&cTab not found!")); return; } String creativeTabName = getCreativeTabName(value); if (creativeTabName == null) { event.getPlayer().sendMessage(TextUtils.colorize("&cTab name not found!")); } else { event.getPlayer().sendMessage(TextUtils.colorize("&7The tab is: &a" + creativeTabName + "&7.")); } } private String getCreativeTabName(ReflectResponse<Object> value) { if (value.isValuePresent()) { CreativeModeTab tab = (CreativeModeTab) value.getValue(); ReflectResponse<Object> name = ReflectionUtil.getFieldValue(CreativeModeTab.class, tab, new MemberPredicate<Field>() .withModifiers(Modifier.FINAL, Modifier.PRIVATE).and(field -> field.getType() == String.class)); if (name.isValuePresent()) { String category = (String) name.getValue(); return category; } } return null; } Output: (@timtower Does the file upload here only doesn't work for me? Could easily be the case.)
@timtower Nah, just a bit of digging in the client and server code. Thanks though It is a nice concept, but I can't really find any application for it xD Ah, I see. It has worked but since a month or so it doesn't anymore. I will check with a clean browser and if it doesn't work make a thread about it. Thanks @rushr93 If you don't really understand what I did, I can probably make a SSCCE for it, you can use.