crabbedhaloablut has quit [Ping timeout: 244 seconds]
crabbedhaloablut has joined #jruby
lucerne has joined #jruby
lucerne has quit [Remote host closed the connection]
lucerne has joined #jruby
subbu|away is now known as subbu
lucerne has quit [Write error: Connection reset by peer]
lucerne has joined #jruby
lucerne has quit [Remote host closed the connection]
lucerne has joined #jruby
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #jruby
lucerne has quit [Remote host closed the connection]
lucerne has joined #jruby
lucerne has quit [Remote host closed the connection]
lucerne has joined #jruby
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #jruby
lucerne has quit [Read error: Connection reset by peer]
lucerne has joined #jruby
DrBob has joined #jruby
lucerne has quit [Read error: Connection reset by peer]
lucerne has joined #jruby
<RobertNicholas[m> what's the proper way to do a java.util.function.Supplier from the ruby end? e.g. java code normally looks like this:
<RobertNicholas[m> I thought maybe a proc like -> { @object }
<RobertNicholas[m> would work but it doesn't seem to
<RobertNicholas[m> () -> new Object()
<enebo[m]> The magic and perhaps problem for you is this only works if the argument is the last parameter of the java method
<enebo[m]> If it isn't you can do something like this (untried): https://gist.github.com/enebo/0d4a94669888555cc6621937220596cb
<RobertNicholas[m> it is actually the last argument which probably explains why it compiles
<enebo[m]> Robert Nicholas: I should point there is a simpler way of that last example but I don't love it since it can be confusing when you have n methods to impl since you only get one: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby#block-implementaiton-of-java-interfaces
<enebo[m]> Do you have a snippet? Nothing jumps out there are wrong
<enebo[m]> as not being supported I should say
<RobertNicholas[m> essentially new forge uses DeferredRegister for registering blocks / item ids, lemme grab a snippet for ya
<RobertNicholas[m> I left out loader.rb but essentially all it does is calls the functions found in mod_example.rb
<RobertNicholas[m> essentially I'm following this here:
<RobertNicholas[m> And trying to implement the differed registers from the ruby end
<enebo[m]> Robert Nicholas: put '&' in front of ->
<enebo[m]> I think you are passing the lambda as a parameter and not a block parameter
<RobertNicholas[m> if that's all it is 🤦‍♂️
<enebo[m]> @BLOCKS.register("bigboi") { @block }
<enebo[m]> lambda is good to prevent arity mismatches but I think an ordinary proc may work better here
<RobertNicholas[m> hmm no dice there either, it compiles and boots but am not actually seeing blocks getting registered (and showing up in game) gonna need to debug a bit more but thanks for pushing me the right direction :)
<enebo[m]> I think based on what the API said the snippet above should work unless somehow it is something with the lifecycle of Example going away before the API calls .get()
<enebo[m]> Perhaps putting a puts/log in there can also tell you if you see it being called
<RobertNicholas[m> so I switched it to this:
<RobertNicholas[m> so it's def being called
<enebo[m]> I mean the block itself
<enebo[m]> @block.get
<RobertNicholas[m> oh inside the block
<enebo[m]> I don't know if register is immediate or happens a bit later
<enebo[m]> seems like it would be a bit async to be wrapped in a function
<RobertNicholas[m> ahh interesting
<RobertNicholas[m> the block isn't being called at all
<RobertNicholas[m> ```@BLOCKS.register("bigboi") { puts "Block being registered: #{@block.get()}"}``` and the output never shows up
<enebo[m]> do you have the puts before the @block.get? I don't know what Block is but I was surprised to see .get there
<enebo[m]> Random guess is a NoMethodError would just appear like nothing happened and perhaps show up in a log somewhere or maybe even get swallowed
<enebo[m]> oh I see...@block.get will get called before the puts...try just a puts before it
<RobertNicholas[m> @block and @block.get should be the same thing essentially
<RobertNicholas[m> (there are multiple places in the forge docs where they're interchanged too)
<RobertNicholas[m> so just puts @block in the block?
<enebo[m]> just puts "HERE"; @block
<RobertNicholas[m> ah
<enebo[m]> rmove any possible evaluation ogf @block just to see if it fires
<enebo[m]> this assumes puts even displays in whatever context it is evaluated in
<enebo[m]> the hack around that would be to just put 'sdjkfsjkhfjkdhfsdfjk' into the block and you hopefully see a NoMethodError
<RobertNicholas[m> yeah the puts output is getting lost it seems
<RobertNicholas[m> not a bad Idea I'll try that
<RobertNicholas[m> REGISTERING BLOCKS / ITEMS COMPLETE
<RobertNicholas[m> @ITEMS.register("bigboiitem") {sdjkfsjkhfjkdhfsdfjk}
<RobertNicholas[m> if it is throwing one it's eating the error
<enebo[m]> hmm so it is not happening I would bet
<enebo[m]> " These events are fired after the mod constructors and before the loading of configs."
<enebo[m]> So could these somehow no longer exist by that ponit or something like that?
<enebo[m]> The other thought would be is there something which needs to be called in Java to kick something off
<RobertNicholas[m> I suppose it's possible
<enebo[m]> just a little brainstorming :)
<RobertNicholas[m> maybe the MinecraftForge::EVENT_BUS.register(self); needs to be in java
<enebo[m]> yeah and self is Example but is Example something appropriate to event bus?
<RobertNicholas[m> Example is just the class of the 'Mod'
<RobertNicholas[m> if called from java it would be the 'RubyCore' class
<enebo[m]> so reigster on eventbus just accepts Object?
<RobertNicholas[m> java docs help, but there are two register methods
<RobertNicholas[m> one takes in the mod event bus
<RobertNicholas[m> which on the ruby end is what this is ```@modEventBus = FMLJavaModLoadingContext.get().get_mod_event_bus();```
<enebo[m]> # Register ourselves for server and other game events we are interested in
<enebo[m]> MinecraftForge::EVENT_BUS.register(self);
<enebo[m]> it is an IEventBus interface but those do not seem to be in same javadocs
<enebo[m]> So this appears to want a class which has annotations. even if you to Example.java_class this class will have no annotations to process. I am not sure how the example related to RubyCore but I am guessing at some level you will have a java type which has some basic annotations which represent what Example will be or something like that?
<enebo[m]> This brings back some nightmares in bukkit and bootstrapping but bukkit was not so anno heavy so it was easier (I am guessing so anyways)
<RobertNicholas[m> sorry got pulled away
<RobertNicholas[m> you're right, that explains why it's not working
<RobertNicholas[m> I was hoping to get around the old method which also had a problem because of annotations but it looks like I'm going to have to write some type of bridge
<RobertNicholas[m> I think what I'll probably do is implement the registries in java and just have ruby able to call them to add things to them
<RobertNicholas[m> the hope was to have the java layer eventually be completely separate so I wouldn't have to maintain a java layer, and ruby layer of the same thing, and to leave more room for other libraries (e.g. fabric / sponge support would mean just adding a new file for each with the appropriate java_imports)
<RobertNicholas[m> what blocks jruby from supporting annotations? Am curious if there'd be a way it could, e.g. defining a @annotations variable in the class object that gets translated. Even if it meant each function / class with an annotation needed specified manually somewhere it'd be cool to have it
<RobertNicholas[m> update, turns out you were right about the cause before
<RobertNicholas[m> I moved the differed registers into the java side then tried to add to them from the ruby side and now the error isn't being splat
<RobertNicholas[m> "org.jruby.embed.InvokeFailedException: java.lang.IllegalStateException: Cannot register new entries to DeferredRegister after RegistryEvent.Register has been fired."