Jump to content

badkraft

Members
  • Posts

    40
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by badkraft

  1. What MC version are (were) you modding?
  2. I used reflection to set the `Item.category` to `null` which removes the item from a `CreativeModeTab`. Here's the class: import com.mojang.logging.LogUtils; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import org.slf4j.Logger; import java.lang.reflect.Field; public class ItemReflector { private static final Logger LOGGER = LogUtils.getLogger(); private static final String CATEGORY = "category"; private static final Class<Item> CLASS = Item.class; private final Field category; public ItemReflector() { LOGGER.debug("Reflecting (" + CLASS + ")"); Field catField = null; try { catField = getField(CATEGORY); } catch (NoSuchFieldException e) { LOGGER.error(e.getMessage(), e); } category = catField; } public void setItemCategory(Item item, CreativeModeTab tab) { try{ category.set(item, tab); } catch (IllegalAccessException e) { LOGGER.error(e.getMessage(), e); } } private Field getField(String fieldName) throws NoSuchFieldException { Field field = CLASS.getDeclaredField(fieldName); field.setAccessible(true); return field; } } ... then, to implement: // snipped irrelevant code import com.mojang.logging.LogUtils; import net.minecraft.world.item.*; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.registries.RegistryObject; import org.slf4j.Logger; public class ItemInit { private static final Logger LOGGER = LogUtils.getLogger(); private final ItemReflector reflector; // get a handle on items we want to remove from tabs @ObjectHolder("minecraft:wooden_axe") public static Item WOODEN_AXE = null; public ItemInit() { reflector = new ItemReflector(); } public void removeItems() { String itemName; String categoryName; reflector.setItemCategory(WOODEN_AXE, null); LOGGER.debug("Removed Item [" + (WOODEN_AXE.getItemCategory() == null) + "]"); } } Now, what this does *NOT* do is remove the item from searching. You can still find the item by searching for "wooden". As soon as I figure that out, I'll update the answer.
  3. Rather than iterating all of the items you want to remove, you can set up place holders in your mod code: // get a handle on items we want to remove from tabs @ObjectHolder("minecraft:wooden_sword") public static Item WOODEN_SWORD = null; ... now, in your event, instead of iterating the collection, you can test whether the item is assigned: LOGGER.debug("Item :: WOODEN SWORD [" + (WOODEN_SWORD != null) + "]"); My log produces the following line:
  4. I want to get a list of existing item categories, mostly for investigative purposes. Once I have a collection of categories, I want to list items in each category. From my understanding, the categories correspond to tabs on the Creative Tab UI. This will help me understand how things are organized and then how to manipulate those (vanilla) items. I use logger a lot when I'm investigating like this. What is the method for getting and using the MC logger utility? And, I've got a class to handle events. This is what I'm using for my mod events; however, This event does not appear to be raised. I'm not finding my log statement anywhere in my debug. or latest. logs. @Mod.EventBusSubscriber(Dist.CLIENT) public final class InitializationHandler { private static final Logger LOGGER = LogUtils.getLogger(); @SubscribeEvent public static void onInitializedEvent(FMLCommonSetupEvent event) { LOGGER.debug("*** *** ON INITIALIZED EVENT *** ***"); } } Solved the event handler issue in the decorator: @Mod.EventBusSubscriber(modid = Foundations.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) Now I'm still wanting to list all the categories with items...
  5. `getCreativeTags()` or `getCreativeTabs()`? Isn't reflection a viable option? It doesn't seem complicated.
  6. Maybe you should re-read what I said about documentation. You think it's modders who write documentation? You think I think modders write documentation? Oh brother you really think highly of yourself.
  7. I'm working from 1.18.2 ... but I'll see if I can find how to check for SilkTouch and giving that effect to the item. Thanks for the hint for searching on Tiers. I think you misunderstand my comment regarding documentation. It would be nice if there were some concerted efforts toward documentation. But I get it. Documentation is everyone's least favorite task. I'm slowly making my way through some code.
  8. I'm creating an item (medallion) with some variant abilities (kind of like a wand). I want to be able to `shift`+`left-click` on a block and get a silk touch affect. Also, if I'm trying to implement `Tier`, how do I get the `Supplier<Ingeredient>` to fulfill the implementation requirement? ...also, why is it so difficult to find good documentation?
  9. I'm looking at another project's source (IntelliJ, Java 8). Gradle is giving an error on sync'ing: compile fg.deobf("curse.maven:iron-chests:3043892") results in the error org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find curse.maven:iron-chests:3043892. I'm looking at the `build.gradle` file and according to this documentation, I should have something either: repositories { maven { url "https://cursemaven.com" } } or: repositories { maven { url "https://cursemaven.com" content { includeGroup "curse.maven" } } } I'm not finding either of these in the `build.gradle` file except under other items - buildscript {...} & publishing {...}. There is a commented repositories{...} item but I'm not sure what version of gradle we're using.
  10. Is there some sort of documentation you could point us to that might give more information? This is hardly a helpful answer.
  11. I have a dev environment set up (Eclipse) and I've included BC and IronChest2. These were easy as I didn't have to do anything special since the downloads were .java. However, the TE mod (AE and RF also) are compiled. So I was wondering what I need to do in my dev environment to have the TE mod load when I run FML from Eclipse. If I need to decompile the TE source, how would I do that? I'm new to java but well experienced in programming concepts and referencing libs, etc. Thanks for any help.
  12. wow ... thanks. That led me in the right direction ... even better though ... I'm not using CodeChicken. I've now stitched in not only BuildCraft but IronChest2. After I finish the basics for my mod, I'm going to integrate Applied Energistics and build off my Forging ideas. I have tested and there are some minor things ... like I'm somehow missing the lang file ... nothing major though. I'm going to be looking for a team to join and help out w/ some modpacks. Thanks, again. Edit: thought I'd explain what I did 1: download buildcraft zip file: https://github.com/BuildCraft/BuildCraft/archive/nightly.zip 2: copy zip file directory BuildCraft-nightly.zip\BuildCraft-nightly\common\buildcraft 3: paste to your project location 4: copy zip file directory BuildCraft-nightly.zip\BuildCraft-nightly\buildcraft_resources\assets\buildcraft 5: paste to your project assets location This is not exhaustive and there are some minor issues - can't find proper names, etc.
  13. I am creating my mod and don't want to re-create all the wonderful stuff in BuildCraft. So how can I include BuildCraft to load in my development environment? Thanks, ~bk
  14. Is it possible, as an alternative to System.out.println for observing values, to use some of the net.minecraft.logging package? BTW, I'm new to Java but a long time C#/.Net software engineer. So picking up Java is not difficult. Some idioms are just a little different while others are way different. Regardless, it is a challenge; but modding MC results in immediate reward for my learning. I get to bring to the table my knowledge of patterns, inheritance and interfaces. Cheers, ~bk
×
×
  • Create New...

Important Information

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