Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/27/17 in all areas

  1. FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dimension) Wasn't that hard for me to figure out, I knew that the method took a single integer named "dimension", returned a WorldServer object, and was named getXxxx(...)
    1 point
  2. 1 point
  3. 1) One time only: find the field (expensive) 2) One time only: store it in a publicly accessible location (cheap) 2) One time only: set the field accessible (expensive) 3) Every tick: set the value (cheap)
    1 point
  4. Edit: Disclaimer. I'm new to Forge modding, so I'm sure someone will come along and prove that what I said didn't quite work. I'm just offering my vision on this. It's worth a shot. It should be possible to call an event from your item class, as long as you register said event in the proper place. So if you don't want to duplicate the code elsewhere that's your sollution. Though it's not a bad practice to have all your eventhandlers in one place. you could always create a method that's accesible outside of your Item for specific tasks. An alternative sollution would be to have your item deplete X amount of it's 'energy' so to speak every X ticks. This would make sure that it would just drain whenever it was on, rather than when it's 'opened' and 'closed'. That way you wouldn't have to go out of your way to create a special event when the player logs on or off, because it wouldn't drain when the player was offline. For this you could implement an eventhandler with one of the subclasses of the TickEvent class. You could create a tickhandler that counts ticks, then executes your code after X ticks (like 200 for dropping charge every 10 seconds). If you are worried about performance, you could use a PlayerTickHandler which should only run on the client, then send a Packet to the server telling how much charge you have. The final thing I can imagine is adding a simple If statement to your Item file to check how long a player has been logged in. I've tried this in my Single player world and EntityPlayer.ticksExisted returns a low amount on playerlogin. So you could add a clause that doesn't deplete your item when ticksExisted is low. That seems like the easiest sollution. However I believe ticksExisted is also low after a player dies. so keep that in mind.
    1 point
  5. Don't make a new TileEntity! When the chest block is generated, this already has generated the TileEntity. You'll need to retrieve the TileEntity (with world.getBlockTileEntity()).
    1 point
×
×
  • Create New...

Important Information

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