Sign in to follow this  
cantorsdust

[WIP] NoDecay, now with configurable blacklist

Recommended Posts

IF YOU GET A CRASH USING 1.3, PLEASE UPDATE TO 1.4


 


 


 


I'm pleased to release my second mod, NoDecay, using Ago's Modloader.  The source code is blatantly stolen adapted from Ulviirala's BetterGamemasters.


 



Version 1.4 of NoDecay.

 

NoDecay

 

A mod for Wurm Unlimited. Disables damage or quality loss taken on decay checks for items, bridges, fences, floors, and walls. It does so by adding modloader code. NoItemDecayFunction ensures that every non-blacklisted item's decayTime value is set to the maximum value on the item's creation. The game ignores max value decayTime values when running its decay() function and its two poll(). The other functions NoBridgeDecayFunction and siblings replace the hasNoDecay() function to always return true, making the game believe that that structure is protected by a GM.

 

It should remain up to date for any Wurm Unlimited version.

 

Changelog:

 

1.4

I'm an idiot and made a stack overflow error. Now configurable blacklist should work properly.

 

1.3:

Added configurable blacklist. See .properties file for instructions.

 

1.2:

Fixed mod by instead intercepting getDecayTime rather than createItemTemplate. Much cleaner, and should actually work!

 

1.1:

Added corpses as decayable items.


 

 

PLEASE NOTE THAT I HAVE NOT HAD TIME TO EXTENSIVELY TEST THIS YET.  I WELCOME ANY FEEDBACK!

 

 

Installation instructions:

 

1.  Make sure you have Ago's Modloader

2.  Unzip NoDecay.zip to the Wurm Unlimited Dedicated Server folder so that modloader.bat and the mods folder are in the same directory as WurmServerLauncher.exe.

4.  Start the game.

 


 


Edited by cantorsdust

Share this post


Link to post
Share on other sites

People like to leave wood scraps laying everywhere, IMO, those should decay. Maybe a suggestion for the long term would be a whitelist / blacklist for specific items? I do like the idea of this mod, I don't always get back to my forges in time, and find my high ql ore has taken damage :(


 


Edit: Oh, stumps should still decay.


Edited by zaaephod

Share this post


Link to post
Share on other sites

I like the idea of being able to specify what items still decay. In my case I would likely want dirt piles, log piles, wood scraps to decay.


 


Otherwise the map is going to get real dirty really quickly.


 


Possibly makes sense to go from the other direction and specify what doesn't decay?


Share this post


Link to post
Share on other sites

People like to leave wood scraps laying everywhere, IMO, those should decay. Maybe a suggestion for the long term would be a whitelist / blacklist for specific items? I do like the idea of this mod, I don't always get back to my forges in time, and find my high ql ore has taken damage :(

 

Edit: Oh, stumps should still decay.

 

A customizable list is actually a good idea.  I can work on that.

Share this post


Link to post
Share on other sites

Can you also add an option for ondeed/offdeed?  I'd like things to decay as normal if they are off deed so that junk doesn't stick around.  But stuff on deed I'd like to prevent decay (with an exceptions list).

Share this post


Link to post
Share on other sites

Received a report from one of my server participants that when picking up dirt and transferring it to a large crate the dirt would disappear. Turning off the mod and restarting the server changed things back to normal. 


 


I haven't verified this myself yet. Might be a good test case to include.


 


~Nappy


Share this post


Link to post
Share on other sites

How about an option to let "normal" decay as it is, but completely remove the monthly 5% decay inside bulk containers (the infamous rolftax). I've poked around a bit, and I think I have found where it is handled:

 

com.wurmonline.server.items
Item.class
poll()
 

if(this.getWeightGrams() < var22.getVolume()) {    Items.destroyItem(this.getWurmId());    decayed = true;} else {    float var23 = 0.05F;    decayed = this.setWeight((int)((float)this.getWeightGrams() - (float)(this.getWeightGrams() * timesSinceLastUsed) * 0.05F), true);}

(as decompiled by IntelliJ). This whole block should be commented, so we exit the procedure without changing the weight nor deleting those with weight < weight_of_one_full_item.

But I'd like to possibility to turn off the other decay outside of the FSBs/BSBs, that's just life.

Share this post


Link to post
Share on other sites

Received a report from one of my server participants that when picking up dirt and transferring it to a large crate the dirt would disappear. Turning off the mod and restarting the server changed things back to normal. 

 

I haven't verified this myself yet. Might be a good test case to include.

 

~Nappy

 

Well I'm going back to the drawing board.  It would appear that there are 4 different createItemTemplate functions in ItemTemplateCreator that I'm trying to intercept, and they all have variables in a different order.  This requires a major rework.  The mod as it stands right now is probably not working.

 

Edit:  Fixed.  I intercepted getDecayTime rather than createItemTemplate, should work much better:)

 

Still working on the blacklist.

Edited by cantorsdust

Share this post


Link to post
Share on other sites

Can we get no decay for items in inventory like meals?

 

They shouldn't be decaying now.  Let me know if they are.

 

In other news, ago has been kind enough to give me a tip on how to implement a blacklist.  I'm away on interviews today and tomorrow, but possibly will update tomorrow night.

  • Like 1

Share this post


Link to post
Share on other sites

Does this affect the fixed 5% monthly item loss (wrongly labelled as "decay") from bulk containers?


Share this post


Link to post
Share on other sites

Does this affect the fixed 5% monthly item loss (wrongly labelled as "decay") from bulk containers?

90% sure that it does. I believe the bulk storage decay code is contained within an if (decayTime < max.long) somewhere in either the devay() or poll() functions. My code replaces all getDecayTime() calls to return max.long except in the above specified cases. I'm not at home right now so I can't check the code for sure. I can confirm tonight.

Edited by cantorsdust

Share this post


Link to post
Share on other sites

90% sure that it does. I believe the bulk storage decay code is contained within an if (decayTime < max.long) somewhere in either the devay() or poll() functions. My code replaces all getDecayTime() calls to return max.long except in the above specified cases. I'm not at home right now so I can't check the code for sure. I can confirm tonight.

 

100% sure that it does.  Relevant code is poll() in com.wurmonline.server.items.Item (pastebin).  Bulk storage is handled within an if(this.template.getDecayTime() != 9223372036854775807L) block, and my mod has getDecayTime() return the checked value if the item's templateId doesn't match the few excluded values above.

Share this post


Link to post
Share on other sites

whats the status on the black/white list for what can/cant decay?

 

Working on it.  My primary problem is passing the blacklist from the properties file to javassist.  It would appear that javassist will not take dynamically-generated values (as a user made blacklist must be).  So I talked to ago and implemented a hacky workaround where the blacklist gets passed to a Hashset which is then checked by a static method.  Problem now is I can't figure out how to call the static method.  So I'm talking to ago again.

Share this post


Link to post
Share on other sites

100% sure that it does.  Relevant code is poll() in com.wurmonline.server.items.Item (pastebin).  Bulk storage is handled within an if(this.template.getDecayTime() != 9223372036854775807L) block, and my mod has getDecayTime() return the checked value if the item's templateId doesn't match the few excluded values above.

Doesn't this process items that themselves aren't supposed to decay ( as per TimeConstants.class "long DECAYTIME_NEVER = 9223372036854775807L" ), not the contents of said items?

 

The code that I pasted in post #10 here is included in a  "if(this.isBulkItem() && this.getBulkNums() > 0)" . Unless you want to flag all items that one can put in a bulk container as DECAYTIME_NEVER, I am afraid you'll have to check what the original code is doing with all the calls to isBulkItem() in the else part of the if you brought up.

 

But then I figured that we are looking at two different poll(). You are looking at the one with "!= 9223372036854775807L". It looks like this one handles "decay" as in "damage". My poll() is the one above yours, with a "== 9223372036854775807L" . This one handles "decay" in terms of "quantity decrease", with its isBulkItem() and reductions by 0.05.

 

Too bad we can't fast forward time to check things out.

Share this post


Link to post
Share on other sites

Doesn't this process items that themselves aren't supposed to decay ( as per TimeConstants.class "long DECAYTIME_NEVER = 9223372036854775807L" ), not the contents of said items?

 

The code that I pasted in post #10 here is included in a  "if(this.isBulkItem() && this.getBulkNums() > 0)" . Unless you want to flag all items that one can put in a bulk container as DECAYTIME_NEVER, I am afraid you'll have to check what the original code is doing with all the calls to isBulkItem() in the else part of the if you brought up.

 

But then I figured that we are looking at two different poll(). You are looking at the one with "!= 9223372036854775807L". It looks like this one handles "decay" as in "damage". My poll() is the one above yours, with a "== 9223372036854775807L" . This one handles "decay" in terms of "quantity decrease", with its isBulkItem() and reductions by 0.05.

 

Too bad we can't fast forward time to check things out.

 

Please see this pastebin for the content of the other poll method.  You will find that the isBulkItem() code is contained within an else block only called when if(this.template.getDecayTime() == 9223372036854775807L) is false.  It will also never be called.  Your bulk storage bins are also safe from decay.

 

In other news,

 

BLACKLIST UPDATE in NoDecay v1.4!

 

Not fully tested, would appreciate any feedback.  Please see instructions in .properties file for how to configure.

 

 

edit:  Next up is implementing no decay only if on deed.  This may require more work, as currently the game checks for the item template's decayTime and doesn't directly reference the item itself.  Meaning getDecayTime() applies for all items of the same type, not one particular item.  Meaning it's not obvious if one particular item is on deed or not.

Edited by cantorsdust

Share this post


Link to post
Share on other sites
23 hours ago, cantorsdust said:

You will find that the isBulkItem() code is contained within an else block only called when if(this.template.getDecayTime() == 9223372036854775807L) is false.  It will also never be called.  Your bulk storage bins are also safe from decay.

But normally it will always be called, since none of my bulkitems are on DECAYTIME_NEVER - normally. In other words, what I am trying to find out is if the mod can be set up to decay everything normally wherever it makes sense, but allow me to remove this idiotic 5% tax on bulk items. I can't imagine flagging every piece of trash I want to get rid of. I don't mind if some forgotten pile of logs decays, makes sense. But I don't want it to "decay" in a container when turned to bulk. In other words, I wouldn't want to mess with normal game flow but it'd be nice if we could fix some game bugs or stupid design decisions, like was done with the stamina loss on horseback.

 

But if I understand it correctly there is a hammer that puts everything on DECAYTIME_NEVER. But if I am not mistaken we can let everything to decay but the bridges for instance with "noBridgeDecayOn=true" without enabling general nodecay with "noItemDecayOn=true", the latter being only for items as in "not buildable structures managed by other switches"? Also, is roof decay managed like floors with noFloorDecayOn too? So maybe, if it's not too task intensive, we can have a "noBulkItemDecay" switch?

Share this post


Link to post
Share on other sites

Wasn't the 5% tax removed in a game update this week? If so then the tax is already gone once you update your server.

 

 

Share this post


Link to post
Share on other sites

Found the reference - removed a lot of other comments however here is the specific line I was thinking of.

 

Patch Notes 2015-11-19

Fixes & Changes

 

  • Bulk item decay has been removed on deeds.

Share this post


Link to post
Share on other sites

Just tried this mod and found out that nothing in my forge will heat up anymore. turned the mod off and it works again

  • Like 2

Share this post


Link to post
Share on other sites

It didnt do this b4 this last update. it heats up on 1.2 just fine. we may have to add all burnable stuff like iron and copper. and things still take damage and is still repairable for some reason.

Share this post


Link to post
Share on other sites

Maybe we need to consider approaching the decay differently.

 

Instead of turning off decay on everything except what's in the list perhaps do the opposite.

 

Make a list of things that you want decay turned off for and then leave it on for everything else.

 

 

Share this post


Link to post
Share on other sites
On 21/11/2015 06:44:30, Nappy said:

Found the reference - removed a lot of other comments however here is the specific line I was thinking of.

 

Patch Notes 2015-11-19

Fixes & Changes

 

  • Bulk item decay has been removed on deeds.

Awesome, didn't notice this in the notes, thanks.

Share this post


Link to post
Share on other sites

Just want to make sure i have this right,
i add this to the mods folder (got by installing this http://forum.wurmonline.com/index.php?/topic/133085-released-server-mod-loader-priest-crops-seasons-server-packs-bag-of-holding/ ) on the server
no client side mods needed? *edit* does indeed seem to be client side only
and then any item droped to the ground thats not in the black list will stay forever? (the server i have is just me and a mate, storage is a major issue at mo, mainly as we dont have any idea what were doing and our tents are full lol)
does this also mean the tents will stay forever (the "few weeks" in the wurmapidia worried us...a lot)

EDIT
gave it a try, cool mod but there is a bug, iron ore in a camp fire and forge do not heat up. (tested with the mod and with out, with the mod enabled the ore does not heat, with the mod disabled it immidiatly starts to heat up the moment the server is back up.

Edited by mrgreaper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this