Created
May 25, 2014 19:06
-
-
Save keplersj/f5ec79b40a894df964e4 to your computer and use it in GitHub Desktop.
The Current JRuby Compiled Rubycraft class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package k2b6s9j.rubycraft; | |
import org.jruby.Ruby; | |
import org.jruby.RubyObject; | |
import org.jruby.runtime.Helpers; | |
import org.jruby.runtime.builtin.IRubyObject; | |
import org.jruby.javasupport.JavaUtil; | |
import org.jruby.RubyClass; | |
import cpw.mods.fml.common.Mod; | |
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | |
import cpw.mods.fml.common.event.FMLInitializationEvent; | |
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | |
@Mod(modid = "Rubycraft", name = "Rubycraft", version = "0.1") | |
public class Rubycraft extends RubyObject { | |
private static final Ruby __ruby__ = Ruby.getGlobalRuntime(); | |
private static final RubyClass __metaclass__; | |
static { | |
String source = new StringBuilder("require 'java'\n" + | |
"\n" + | |
"java_package 'k2b6s9j.rubycraft'\n" + | |
"\n" + | |
"java_import 'cpw.mods.fml.common.Mod'\n" + | |
"java_import 'cpw.mods.fml.common.event.FMLPreInitializationEvent'\n" + | |
"java_import 'cpw.mods.fml.common.event.FMLInitializationEvent'\n" + | |
"java_import 'cpw.mods.fml.common.event.FMLPostInitializationEvent'\n" + | |
"\n" + | |
"java_annotation 'Mod(modid = \"Rubycraft\", name = \"Rubycraft\", version = \"0.1\")'\n" + | |
"class Rubycraft\n" + | |
"\n" + | |
" @@itemRuby = Java::NetMinecraftItem::Item.new\n" + | |
" @@rubySword = Java::NetMinecraftItem::Item.new\n" + | |
" @@rubyPickaxe = Java::NetMinecraftItem::Item.new\n" + | |
" @@rubySpade = Java::NetMinecraftItem::Item.new\n" + | |
" @@rubyAxe = Java::NetMinecraftItem::Item.new\n" + | |
" #Dirty Hoe\n" + | |
" @@rubyHoe = Java::NetMinecraftItem::Item.new\n" + | |
"\n" + | |
" java_annotation 'Mod.EventHandler'\n" + | |
" java_signature 'void preInit(FMLPreInitializationEvent)'\n" + | |
" def preInit(event)\n" + | |
"\n" + | |
" @@itemRuby.set_unlocalized_name('Rubycraft:ruby')\n" + | |
" @@itemRuby.set_texture_name('Rubycraft:ruby')\n" + | |
" Java::CpwModsFmlCommonRegistry::GameRegistry.register_item(@@itemRuby, 'ruby')\n" + | |
"\n" + | |
" @@rubySword.set_unlocalized_name('Rubycraft:ruby_sword')\n" + | |
" @@rubySword.set_texture_name('Rubycraft:ruby_sword')\n" + | |
" Java::CpwModsFmlCommonRegistry::GameRegistry.register_item(@@rubySword, 'ruby_sword')\n" + | |
"\n" + | |
" @@rubyPickaxe.set_unlocalized_name('Rubycraft:ruby_pickaxe')\n" + | |
" @@rubyPickaxe.set_texture_name('Rubycraft:ruby_pickaxe')\n" + | |
" Java::CpwModsFmlCommonRegistry::GameRegistry.register_item(@@rubyPickaxe, 'ruby_pickaxe')\n" + | |
"\n" + | |
" @@rubySpade.set_unlocalized_name('Rubycraft:ruby_spade')\n" + | |
" @@rubySpade.set_texture_name('Rubycraft:ruby_spade')\n" + | |
" Java::CpwModsFmlCommonRegistry::GameRegistry.register_item(@@rubySpade, 'ruby_spade')\n" + | |
"\n" + | |
" @@rubyAxe.set_unlocalized_name('Rubycraft:ruby_axe')\n" + | |
" @@rubyAxe.set_texture_name('Rubycraft:ruby_axe')\n" + | |
" Java::CpwModsFmlCommonRegistry::GameRegistry.register_item(@@rubyAxe, 'ruby_axe')\n" + | |
"\n" + | |
" @@rubyHoe.set_unlocalized_name('Rubycraft:ruby_hoe')\n" + | |
" @@rubyHoe.set_texture_name('Rubycraft:ruby_hoe')\n" + | |
" Java::CpwModsFmlCommonRegistry::GameRegistry.register_item(@@rubyHoe, 'ruby_hoe')\n" + | |
"\n" + | |
" printCopyrightInfo\n" + | |
"\n" + | |
" end\n" + | |
"\n" + | |
" def printCopyrightInfo\n" + | |
" puts 'Rubycraft'\n" + | |
" puts 'Copyright Kepler Sticka-Jones 2014'\n" + | |
" puts 'https://github.com/k2b6s9j/Rubycraft'\n" + | |
" end\n" + | |
"\n" + | |
" java_annotation 'Mod.EventHandler'\n" + | |
" java_signature 'void init(FMLInitializationEvent)'\n" + | |
" def init(event)\n" + | |
" end\n" + | |
"\n" + | |
" java_annotation 'Mod.EventHandler'\n" + | |
" java_signature 'void postInit(FMLPostInitializationEvent)'\n" + | |
" def postInit(event)\n" + | |
" end\n" + | |
"end\n" + | |
"").toString(); | |
__ruby__.executeScript(source, "mod/Rubycraft.rb"); | |
RubyClass metaclass = __ruby__.getClass("Rubycraft"); | |
if (metaclass == null) throw new NoClassDefFoundError("Could not load Ruby class: Rubycraft"); | |
metaclass.setRubyStaticAllocator(Rubycraft.class); | |
__metaclass__ = metaclass; | |
} | |
/** | |
* Standard Ruby object constructor, for construction-from-Ruby purposes. | |
* Generally not for user consumption. | |
* | |
* @param ruby The JRuby instance this object will belong to | |
* @param metaclass The RubyClass representing the Ruby class of this object | |
*/ | |
private Rubycraft(Ruby ruby, RubyClass metaclass) { | |
super(ruby, metaclass); | |
} | |
/** | |
* A static method used by JRuby for allocating instances of this object | |
* from Ruby. Generally not for user comsumption. | |
* | |
* @param ruby The JRuby instance this object will belong to | |
* @param metaclass The RubyClass representing the Ruby class of this object | |
*/ | |
public static IRubyObject __allocate__(Ruby ruby, RubyClass metaClass) { | |
return new Rubycraft(ruby, metaClass); | |
} | |
/** | |
* Default constructor. Invokes this(Ruby, RubyClass) with the classloader-static | |
* Ruby and RubyClass instances assocated with this class, and then invokes the | |
* no-argument 'initialize' method in Ruby. | |
*/ | |
public Rubycraft() { | |
this(__ruby__, __metaclass__); | |
Helpers.invoke(__ruby__.getCurrentContext(), this, "initialize"); | |
} | |
@Mod.EventHandler | |
public void preInit(FMLPreInitializationEvent event) { | |
IRubyObject ruby_arg_event = JavaUtil.convertJavaToRuby(__ruby__, event); | |
IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "preInit", ruby_arg_event); | |
return; | |
} | |
public Object printCopyrightInfo() { | |
IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "printCopyrightInfo"); | |
return (Object)ruby_result.toJava(Object.class); | |
} | |
@Mod.EventHandler | |
public void init(FMLInitializationEvent event) { | |
IRubyObject ruby_arg_event = JavaUtil.convertJavaToRuby(__ruby__, event); | |
IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "init", ruby_arg_event); | |
return; | |
} | |
@Mod.EventHandler | |
public void postInit(FMLPostInitializationEvent event) { | |
IRubyObject ruby_arg_event = JavaUtil.convertJavaToRuby(__ruby__, event); | |
IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "postInit", ruby_arg_event); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment