CraftTweaker

CraftTweaker

151M Downloads

IEntity.setFire() is not accessible.

TheRooster opened this issue ยท 6 comments

commented

Intro:

Issue Description:

IEntity.setFire() does not appear to be accessible from event handlers (Specifically onPlayerAttackEntity())

What happens:

error on script load.
events.zs:2 > No such member in crafttweaker.entity.IEntity: setFire

What you expected to happen:

Target entity to be set on fire for a period of 10 seconds when attacked by a player.

Script used (Please Pastebin or gist your script, posting an unpasted or ungist'd script will automatically close this issue):

https://pastebin.com/XX2W8tzY

crafttweaker.log file (Please Pastebin or gist your file, posting an unpasted or ungist'd file will automatically close this issue):

https://pastebin.com/SieMti7M


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12.2
  • Forge: 14.23.4.2757
  • Crafttweaker: 1.12-4.1.9
  • Using a server: no - launching from multimc if that makes a difference
  • If yes, does the client have the exact same scripts?

Your most recent log file where the issue was present:

https://pastebin.com/npZFKYey

commented

Probably declared the annotations the other way round, try entity.fire = 10

commented

That leads to a null pointer exception:

Crafttweaker.log: https://pastebin.com/iiXuzmcH
Latest.log: https://pastebin.com/xaPMx7fr

commented

This issue is still present in version 4.1.10 for 1.12.2.

commented

@nihiltres Everything is working, remember while there may be a setter for entity.fire, there's no getter, as MC didn't expose one, so if you try anything like += that relies on a getter, it will fail as there's no get property

commented

I've tried entity.setFire(10) and entity.fire = 10. I get the error No such member in crafttweaker.entity.IEntityLivingBase: setFire (or a NPE if using the ZenSetter). Other similar ones in IEntity, like setAir(int) have the same problem, with corresponding error messages. I did a double-take and double- and triple-checked I wasn't somehow still using the previous version.

If there's some mistake I'm making, I'd be glad to have that corrected. Here's the snippet where the error is located:

traitMossfire.onHit =
	function (
			trait as Trait, tool as IItemStack,
			attacker as IEntityLivingBase, target as IEntityLivingBase,
			damage as float, isCritical as bool
		) {
			if (target.immuneToFire | target.wet) {return;}
			var chance = 0.2d;
			//if (false) {chance = (1.0d / 3.0d);} //TODO: Check for gem
			if (Math.random() < chance) {target.setFire(10);}
	};

Math.random() is provided by CraftTweaker Utils and just calls its Java equivalent. Yes, I've got every named class (and IEntity) imported. For what it's worth, this bit is loaded by ContentTweaker, for the obvious purpose of implementing a custom TiC trait.

commented

The issue is properly resolved in 4.1.11.