Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Choonster

Moderators
  • Joined

  • Last visited

Posts posted by Choonster

  1. ·

    Edited by Choonster

    9 minutes ago, Bektor said:

    Hm... It doesn't really bring me anywhere.. Setting the breakpoint at line 80 will just result into it that eclipse shows me that neither the world, nor the chunkPollutionHolder or the chunkPollution values are null.

    Putting in this line of code results into this:

    
    System.err.println(message.pollution); //output :0.0
    System.err.println(message); // output: MessageChunkPollution@3fbdd7c8

     

    That's strange. Can you reliably reproduce the NullPointerException, or has it only happened once?

     

    Try removing the breakpoint on the line that throws the exception and replacing it with an exception breakpoint for NullPointerException. If the breakpoint is hit and the exception is being thrown on the same line as before, look at what's null.

     

    Quote

    Opening the chunkPollutionHolder shows me that the keySet and the values from the HashMap are null while the entrySet contains values.

     

    That's normal, keySet and values are only created when they're first requested.

  2. You're using the state that's equivalent to metadata 0, which is the default state (standard dirt). Coarse Dirt is a different variant of Blocks.DIRT.

     

    Don't use metadata values. Use Block#getDefaultState to get the default state, then use IBlockState#withProperty to get the IBlockState with BlockDirt.VARIANT set to BlockDirt.DirtType.COARSE_DIRT.

  3. 10 hours ago, Bektor said:

    I'm sending a message to the player via ChunkWatchEvent.Watch to test if the code, but now I'm getting the following error inside of the message handler:

     

    The IChunkPollution for that chunk was null.

     

    Are you creating a default IChunkPollution in ChunkEvent.Load when the Chunk doesn't already have one? This is required for client-side chunks, since ChunkDataEvent.Load only fires on the server.

  4. 20 minutes ago, Bektor said:

    Does the ChunkWatchEvent.Watch gets only called once, for example the player goes into this chunk and the event gets called and then never again until the player goes into this chunk again? So it does not get called like every 20 ticks when a player is in this chunk.

     

    It gets fired once when the player starts watching the chunk and won't be fired for that player and chunk again until they stop watching it and then start watching it again. It's not fired constantly while a player is in the chunk.

     

    23 minutes ago, Bektor said:

    I'm also wondering how I should access my capability from a block to let this block update the value stored in the chunk, as I've only worked with capabilities where the data is directly saved to the block and thus every block had it own instance of in that case the EnergyStorage class.

    And how do I access the value stored in the chunk in events like CropGrowEvent or SaplingGrowTreeEvent to do something within those events when the value reaches a critical point.

     

    Access the holder capability through the World and then use it to get the energy storage for the chunk. I created helper methods in CapabilityChunkEnergy to get the IChunkEnergy for a Chunk or World and ChunkPos.

  5. 3 minutes ago, IvanSteklow said:

    Yes, here is code where it called:

     

    I believe diesieben07 meant "Is it actually called at runtime"? Set a breakpoint in each of the GuiHandler methods and try to open your GUI, are the breakpoints hit?

     

    In the code on GitHub, GuiHandler#getClientGuiElement always returns null. It should return a new GuiBlockBreaker instance when the ID matches.

  6. Please post the latest version of your code and the latest FML log (logs/fml-client-latest.log in the game directory).

     

    It's not the direct cause of the error, but you're passing a ResourceLocation to EntityRenderer#enableLightmap (when you invoke it via the Method) even though the method doesn't have any parameters. EntityRenderer#enableLightmap is also a public method, so there's no need to invoke it via reflection.

     

    When you do use reflection, mark the field containing the Field/Method object as final.

  7. 12 hours ago, CommanderNeville said:

    Caused by: java.lang.NoSuchMethodException: net.minecraft.client.renderer.EntityRenderer.field_110922_T()
        at java.lang.Class.getDeclaredMethod(Unknown Source) ~[?:1.8.0_121]
        at net.minecraftforge.fml.relauncher.ReflectionHelper.findMethod(ReflectionHelper.java:180) ~[forgeSrc-1.10.2-12.18.3.2316.jar:?]
        at com.commander.mgln.entity.ModLightMap.<clinit>(ModLightMap.java:21) ~[ModLightMap.class:?]

     

    The error says you're asking for a method named field_110922_T, but the code you posted doesn't use this name. Did an old version of your code use this name?

     

    Try rebuilding the mod in your IDE to ensure it's using the latest version.

  8. 1 minute ago, Bektor said:

    Oh, yeah. So basically you are directly sending the new data to the client while with the forge implementation each block/item has to ask for the current value when it wants to display it, correct?

     

    Any mod that displays an energy value on the client needs to sync it somehow.

     

    If it's an energy bar in a GUI, this is usually handled through the Container (which syncs the value when it changes). If it's rendered outside of a GUI, it could either be always synced when the value changes or synced on demand when the value needs to be rendered.

  9. ·

    Edited by Choonster

    8 minutes ago, Bektor said:

    Just one question, why do you send a packet to the client instead of changing the value directly in your ChunkEnergy class? I mean, you basically build your system on top of the existing one from forge and the one from forge changes the energy direclty without sending an packet which does this.

     

    The server and client(s) each have their own IChunkEnergy/IChunkEnergyHolder instances. The server handles any modifications to the energy amount and syncs the new value to the relevant clients so they can render it on screen (with the Chunk Energy Display item held).

     

    If there was no packet, the client-side GUI wouldn't be able to display the current energy amount.

     

    Forge's energy capability doesn't have any kind of automatic client-server syncing built-in.

  10. 5 hours ago, Jay Avery said:

    From the comment, it looks like a single version string should be interpreted as a valid version range - shouldn't it?

     

    You're right, I missed that.

     

     

    5 hours ago, Jay Avery said:

    And I don't understand how, even if I wrote the version range in the wrong format, it ends up letting me connect to a non-forge server. I would expect it to just not allow connecting to any server if it doesn't understand the version range I've given? :S

     

    Looking into the code further, it appears that using a single version rather than one or more version ranges creates a VersionRange with a single Restriction (Restriction.EVERYTHING) that matches everything and completely ignores the version you passed it.

     

    In addition to this, NetworkModHolder.DefaultNetworkChecker (the default implementation used to check if the remote mod list is compatible with the local mods) allows the client to connect to a server without the mod installed.

     

    I'm not sure of the reason behind either of these.

     

    You can work around the latter by providing your own NetworkChecker, just annotate a method with @NetworkCheckHandler. See the doc comment for the required signature.

  11. 8 minutes ago, Draco18s said:

    While true, I recommend against it due to the potential to confuse the scope ("my packet handler runs, but it doesn't recieve the data, but I know I'm sending it!") as the modder tried to reference the packet data not from the object passed, but through container scope, even through the objects were different instances.   Keeping them in separate files helps the fledgling modder. 

     

    If the handler is a static nested class (which it should be), attempting to access instance fields of the message results in a compilation error.

  12. When you use nested classes depends on your code style. There's not really a specific area where you need to use them, they mostly behave just like normal classes.

     

    One common use is nesting the IMessageHandler in the corresponding IMessage class to keep the message and its handler together.

  13. 46 minutes ago, Is.M.L said:

    Thank you. Unfortunately, Forge is not even an option. I want to add functionality to my client directly. And there would be no incompatibilities, because I only add, don't change or remove anything.

     

    If you're not using Forge, why are you asking for help on the Forge forums?

     

    If you want to modify the base classes directly, you need to use MCP. Your edits will likely make the mod incompatible with Forge and any other JAR mod that changes the same classes.

  14. In short: You don't. Forge exists to allow compatibility between mods, editing base classes leads to incompatibilities.

     

    You can usually achieve what you want in some other way, e.g. with an event or by replacing a field. If you tell us what you're trying to achieve, we can tell you how to do it.

     

    It is possible to modify base classes using ASM, but this is highly discouraged and you won't get any help with it here.

  15. 1 minute ago, IvanSteklow said:
    
    java.lang.ArrayIndexOutOfBoundsException: 0
    	at ivansteklow.ishelper.init.MainCmd.execute(MainCmd.java:47) ~[MainCmd.class:?]

     

     

    This log shows me this string, but I can't see any error in code:

    
    if(args[0].equals("killa") || args[0].equals("killall")){

     

     

    args was length 0, so attempting to access index 0 threw an ArrayIndexOutOfBoundsException.

     

    You're already checking if the length is 0 before printing the help text, you just need to return from the function after doing that instead of trying to access index 0.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.