• 0

    posted a message on setupDecompWorkspace failed decompileMC was the cause

    Please post the full output from Gradle using Gist or Pastebin.

    Posted in: Modification Development
  • 0

    posted a message on [Solved]How Can I Add My Own Potion With My Own Effect
    Quote from Brogolem35»

    So, what I need to do?


    Set the registry names of your Potion instances when you create them instead of when you register them.
    Posted in: Modification Development
  • 0

    posted a message on [Solved]How Can I Add My Own Potion With My Own Effect

    A NullPointerException is thrown when you try to call a method on or access a field of a null value. The only value on line 56 of your ModPotionTypes class that could be null is potionName, which means that your Potion's registry name was null.


    My code requires that the Potion's registry name has been set before the PotionType is created, but your code doesn't do this.

    Posted in: Modification Development
  • 0

    posted a message on [Solved]How Can I Add My Own Potion With My Own Effect

    You didn't post the class that's causing the crash (ModPotionTypes). Please post this as well as the class where you create and register your Potions and the class that calls it.

    Posted in: Modification Development
  • 0

    posted a message on [Solved]How Can I Add My Own Potion With My Own Effect
    Quote from Brogolem35»

    I added some things from your source codes to the mine but it did crash. The crash report says line:56(78 for your code), 43(56) and 38(42) have problems. Can it be a Forge or Minecraft version problem?


    When asking for help with a crash, always post the FML log (logs/fml-client-latest.log in the game directory) and your code using Gist or Pastebin. It's hard to fix something when you don't know what the problem actually is.

    Make sure you apply syntax highlighting to your code when posting it with Gist or Pastebin. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
    Posted in: Modification Development
  • 0

    posted a message on [Solved]How Can I Add My Own Potion With My Own Effect

    Don't make your PotionType registration class (ModPotionTypes) extend PotionType or call PotionType.registerPotionType.


    Subscribe to RegistryEvent.Register<PotionType>, get the registry from the event with RegistryEvent.Register#getRegistry and register your PotionTypes by calling IForgeRegistry#register or IForgeRegistry#registerAll.


    You can see how I create and register my mod's PotionTypes here.

    Posted in: Modification Development
  • 1

    posted a message on NullPointer in packet from capability when reloading world
    Quote from Melonslise»

    Well the synchronize method is only called by my setCurrent() and setMaximum() methods in the capability so I'm not even sure why it's being called at login in the first place.

    Because CapabilityMana#readNBT calls CapabilityMana#setCurrent and CapabilityMana#setMaximum. It should set the values directly instead of using the setter methods.
    Posted in: Modification Development
  • 0

    posted a message on [Solved]How Can I Add My Own Potion With My Own Effect

    Assuming you've created and registered the Potion instances, you then need to create and register a PotionType for each brewable potion. For most vanilla Potions there are one to three PotionTypes: regular (e.g. Regeneration, 0:45) , long (e.g. Regeneration, 1:30) and strong (e.g. Regeneration II, 0:22).


    Both Potion and PotionType are implementations of IForgeRegistryEntry, so they should be registered during the appropriate registry events.


    Once you've created and registered the Potions and PotionTypes, use PotionHelper.addMix to add the brewing recipes (e.g. Awkward to Regular X, Regular X to Long X and Regular X to Strong X). For more advanced brewing recipes, you can use Forge's BrewingRecipeRegistry.

    Posted in: Modification Development
  • 1

    posted a message on NullPointer in packet from capability when reloading world

    It looks like you're sending the packet when your capability and the EntityPlayerMP it's attached to are being read from NBT, which is before EntityPlayerMP#connection is assigned a non-null value. This is too early, you should send the packet in PlayerEvent.PlayerLoggedInEvent instead.

    Posted in: Modification Development
  • 0

    posted a message on Make a block pick up items

    You still need to use World#getEntitiesWithinAABB to get the nearby item entities, but you need to create your own AABB from the TileEntity's position instead of using the Entity's AABB. Look at TileEntityHopper.getCaptureItems to see how the hopper does this.


    Make you TileEntity implement ITickable and search for items in the ITickable#update implementation.

    Posted in: Modification Development
  • 1

    posted a message on Help with capabilities

    The ICapabilityProvider (or ICapabilitySerializable) and the capability handler (ICapabiltiesMana) should be completely separate.


    The ICapabilityProvider should store an instance of the capability and return it from the getCapability method.


    It is possible to create an ICapabilityProvider that works for any capability, you just need to store the Capability object and the handler instance (and optionally the EnumFacing to pass to the IStorage methods and/or provide the capability handler for).


    I have a generic ICapabilityProvider implementation here and a generic ICapabilityProvider + INBTSerializable (what ICapabilitySerializable is equivalent to) implementation here.

    Posted in: Modification Development
  • 0

    posted a message on How to add items to loot tables with code[FORGE 1.12][SOLVED]
    • Create a LootEntryTable or LootEntryItem.
    • If needed, create the required LootConditions.
    • If needed, create a LootPool and pass the LootEntry and LootCondition instances to the constructor.
    • Use LootTable#getPool to get an existing LootPool or LootTable#addPool to add a new one.
    • If needed, use LootPool#addEntry to add a new LootEntry to an existing LootPool.
    Posted in: Modification Development
  • 0

    posted a message on setupDecompWorkspace failed decompileMC was the cause

    Which version of Minecraft are you using?


    The MDK already has this gradle.properties file in 1.10+, you can copy it to your ~/.gradle (%USERPROFILE%\.gradle on Windows) directory. This tells Gradle to run Java with a 3 GB heap.


    In future, please post the exact error message rather than paraphrasing it. Use Gist or Pastebin to post logs and code.

    Posted in: Modification Development
  • 1

    posted a message on Help with capabilities
    Quote from Melonslise»

    So from what I understood after reading the docs is that to get an instance of my capability I need to use the @CapabilityInject annotation.


    This is correct.




    The hasCapability method seems easy enough, however I can't call super like it says in the docs and I'm not sure why. The docs do a very bad job at describing the getCapability, but from what I understood it has to return it's provider class?



    You can only call the super method from the ICapabilityProvider methods if the super class also implements ICapabilityProvider, which generally won't be the case if you're creating an ICapabilityProvider class to attach capabilities to existing objects like entities.


    You only need to call the super method if the super class also implements ICapabilityProvider, e.g. when you're extending a vanilla implementation like Entity and overriding the ICapabilityProvider methods.


    In both of the ICapabilityProvider methods, you first need to check if the Capability argument is equal to (==) your Capability instance. If it is, return true from hasCapability or return an instance of your capability interface from getCapability.


    Due to limitations of Java's type system it doesn't know that T (the return type of getCapability) is your capability's interface, so you need to cast the instance you're returning to T by calling Capability#cast on your Capability instance.




    And lastly the de/serialize methods are supposed to call the corresponding storage methods of the capability?



    They don't have to, but it's generally easiest to do so.

    You can also use Capability#readNBT/writeNBT as shortcuts for IStorage#readNBT/writeNBT.
    Posted in: Modification Development
  • 0

    posted a message on Help with capabilities
    Quote from Melonslise»

    Ok last question. There seems to be two registry methods for the capability one of which takes a factory. Is there even a point in creating a factory if there is another method which takes an instance of the capability implementation?

    The choice is between a factory and a Class, not a factory and an instance. The Class overload simply calls the other overload with a factory that calls Class#newInstance (i.e. invokes the zero-parameter constructor).
    Posted in: Modification Development
  • To post a comment, please .