Hardcore Torches (Forge)

Hardcore Torches (Forge)

25.2k Downloads

Dropped entities burn out

WolfieWaffle opened this issue ยท 2 comments

commented

when you drop the torch make it burn out

commented

I have implemented this somewhat. Its a bit untidy code, (see attached)

It is done through some events using ItemEntity lifespan and age to count the fuel burnt.
When player drops an item fuel is converted to lifespan.
When player picks up an item lifespan-age is used to set fuel value
I then use ItemExpireEvent to change the lit torch to burnt or stick as per config.
lifespan and age are auto saved by ItemEntity on world save/load.

I chose to do it this way expecting that it is easier (lag) wise than using onEntityItemUpdate in TorchItem class to change fuel each tick. Though I didn't test this theory.
It doesn't handle smoldering torches well though. I just multiply the lifespan by 3 then divide by 3 when picked up.

I also used onEntityItemUpdate in TorchItem class to transform the torch when in rain or dropped in water.
Handled similar to playerTick event for torches.

I guess though there is some cheat if ItemEntity are unloaded chunk wise since they may not be updated.
Not sure if this is the case with block torch anyway.
Perhaps could have a timestamp on the torches and check against world time when they are loaded.

I have only done some basic testing of these changes. There may be bugs
HardcoreTorches_01.txt
.

commented

Hm, I'm not sure about the lifespan method since it means torches can last dropped on the ground for extra time. I might just make it edit the NBT each tick instead to be as vanilla as possible.

But I will include the rain and water changes in the next update when I remember to