Posted March 20, 2019 (edited) New to Modding here and I have a question: How would I change the following code below to return "true" also if there was a Floor Above or you were under a bridge? private boolean hasRoof(VolaTile tile) { Floor[] floors = tile.getFloors(); for (Floor floor : floors) { if (floor.isRoof()) { return true; } } return false; } Edited March 20, 2019 by Xilanthus Share this post Link to post Share on other sites
Posted March 20, 2019 for (Floor floor : floors) { What is this nightmare? Share this post Link to post Share on other sites
Posted March 20, 2019 (edited) 37 minutes ago, Sn00 said: for (Floor floor : floors) { What is this nightmare? Enhanced For Loops of Arrays https://www.cis.upenn.edu/~matuszek/General/JavaSyntax/enhanced-for-loops.html Edited March 20, 2019 by Xilanthus Share this post Link to post Share on other sites
Posted March 20, 2019 (edited) -- Edited March 20, 2019 by kochinac not reading carefully Share this post Link to post Share on other sites
Posted March 20, 2019 Make a method in your mod that does what you want and it can be written with Java. You'll likely only have access to the MyTile object. Although, there are static methods in WU that let you look up information for a tile or volatile zone. Then use Javassist expression editor to replace the return value from the wurm method with the return value from your new method. Javassist page has a tutorial on this. You could use bytecode to change it also but that isn't the easists approach. Share this post Link to post Share on other sites
Posted March 20, 2019 what type is MyTile? if you can get a VolaTile out of it you can call vt.getStructure().isTypeBridge() Share this post Link to post Share on other sites
Posted March 20, 2019 5 minutes ago, joedobo said: ... there are static methods in WU that let you look up information for a tile or volatile zone... I am looking for a list of the static methods and what information is available about a tile. Is there a list somewhere? The code above is from an existing mod and I want to enhance it further. Share this post Link to post Share on other sites
Posted March 20, 2019 2 minutes ago, bdew said: what type is MyTile? if you can get a VolaTile out of it you can call vt.getStructure().isTypeBridge() It is a VolaTile - I corrected the code above. Share this post Link to post Share on other sites
Posted March 20, 2019 private boolean hasRoof(VolaTile tile) { if (tile.getStructure().isTypeBridge()) return true; Floor[] floors = tile.getFloors(); for (Floor floor : floors) { if (floor.isRoof()) { return true; } } return false; } Share this post Link to post Share on other sites
Posted March 20, 2019 (edited) WU vanilla code is very lacking when it comes to java docs. If you askin specific question in modding Discord (or here too) we can probably help advise on what method(s) would be best to get object xyz. Edited March 20, 2019 by joedobo Share this post Link to post Share on other sites
Posted March 21, 2019 (edited) 7 hours ago, bdew said: private boolean hasRoof(VolaTile tile) { if (tile.getStructure().isTypeBridge()) return true; Floor[] floors = tile.getFloors(); for (Floor floor : floors) { if (floor.isRoof()) { return true; } } return false; } This would return true if you were standing ON a bridge too. I only want it to return true if there is a bridge (or any structure for that matter (bridge, Roof, Upper Floor, etc)) above you. Edited March 21, 2019 by Xilanthus Share this post Link to post Share on other sites
Posted March 22, 2019 Is there a way to get the height of a floor element within a VolaTile and then compare the floor height to the height the character is standing at to see if the floor is above or below them? Share this post Link to post Share on other sites
Posted March 23, 2019 Look at the method getRealHeight of BridgePart Share this post Link to post Share on other sites