I'm newbie in forge modding, don't know how people writing mods, when I ever can't find "tutorial about replacing default block in the world" or "how do i know when game world is loaded".
So, I want to create Fire Sensor — block, which will create the file in the special folder when detect a fire. I need it for emulate real-life sensors with special software.
Ok, I created and registered block:
@EventHandler
public void PreInit(FMLPreInitializationEvent event) {
Sensor fire_sensor = new Sensor("fire", space); // here is type of of sensor and space, where we are looking for fire
GameRegistry.registerBlock(fire_sensor, "fire_sensor");
}
Within "Sensor" class I put this experimental code:
private int iterator = 0;
@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer nick, int p1, float p5, float p6, float p7) {
System.out.println(this.iterator++);
return false;
}
@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer nick, int p1, float p5, float p6, float p7) {
System.out.println(this.iterator++);
return false;
}
I placed two blocks in the world and click RMB on first and console show me "1". When I will click on another block, I will see "2", "3" and so on. But I need individual Iterator for every block. How I can do that?
So, I want to create Fire Sensor — block, which will create the file in the special folder when detect a fire. I need it for emulate real-life sensors with special software.
Ok, I created and registered block:
@EventHandler public void PreInit(FMLPreInitializationEvent event) { Sensor fire_sensor = new Sensor("fire", space); // here is type of of sensor and space, where we are looking for fire GameRegistry.registerBlock(fire_sensor, "fire_sensor"); }Within "Sensor" class I put this experimental code:
private int iterator = 0; @Override public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer nick, int p1, float p5, float p6, float p7) { System.out.println(this.iterator++); return false; } @Override public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer nick, int p1, float p5, float p6, float p7) { System.out.println(this.iterator++); return false; }I placed two blocks in the world and click RMB on first and console show me "1". When I will click on another block, I will see "2", "3" and so on. But I need individual Iterator for every block. How I can do that?
I hope you understand me, sorry my English.
Useful. But it works for TileEntity and not working for Block.