Umbrellas do not protect against sunlight when sitting in a boat
BTOptimizer opened this issue ยท 6 comments
My friend encountered an issue as a vampire where the umbrella does not protect him against sunlight while in a boat. To make sure this wasn't a multiplayer issue (as we play on a dedicated server that hosts MC Eternal), I went into singleplayer to test this out and sure enough it happened there too. To replicate: be a level 2+ vampire, hold an umbrella in either your main hand or off-hand in direct sunlight, and wait. Upon leaving the boat though, the umbrella protects you as intended.
The server we are playing on uses MC Eternal 1.3.5.3, which has Vampires Need Umbrellas 1.12.2-1.3 and Vampirism 1.12.2-1.6.2
I assume the player position is below the water surface and therefore the canSeeSky
check fails:
https://github.com/Focamacho/VampiresNeedUmbrellas/blob/4e1dd3550b503dc89f3e7a62186832d26043b821/src/main/java/com/focamacho/vampiresneedumbrellas/handlers/VampirismHandler.java#L55
There is a similar issue, if the player is below sea level and there is some water above the player.
See sundamage check here: https://github.com/TeamLapen/Vampirism/blob/7a057f6666b22da19bead370caaeeee6fd11e169/src/main/java/de/teamlapen/vampirism/util/Helper.java#L84
For performance reason the full check is only executed below sealevel, whereas above sealevel canSeeSky
is used.
Besides the other potential solutions, one option would be to apply the sunscreen effect regardless of the players position.
To prevent it being rendered all the time something similar to Vampirism's night vision could be done: https://github.com/TeamLapen/Vampirism/blob/1.12/src/main/java/de/teamlapen/vampirism/potion/VampirismNightVisionPotion.java
If you don't want to substitute Vampirisms sunscreen, we could at a check for a harcoded effect classname on our end (1.14+ only though).
Just an option, wanted to let you know, that we are happy to consider changes if you need something.
Hey @maxanier , thank you so much for your help! You're awesome!
About the solutions, I think it's better for me to use the same check as vampirism, this will avoid some other problems that may exist.
I can't apply the effect all the time as it would make it difficult to deal with the durability of the umbrella.
I'm thinking of using this:
private static boolean canApplyEffect(Entity entity) {
if(entity.world.isRemote || !(entity instanceof PlayerEntity)) return false;
VampirePlayer vampire = VampirePlayer.get((PlayerEntity)entity);
return (vampire.getTicksInSun() > 1);
}
What do you think? Thanks again for your help.
The damage happens when above water and sitting in a boat, however when you go underwater after dismounting, you're fine but the umbrella should protect you in the boat because you are technically above the water but in a vehicle (while mounted).
MC Eternal requires a lot of exploring and the sunscreen beacon only affects up to 32 blocks in a radius and with there being large bodies of water to sometimes cross, a level 2+ vampires' best bet at avoiding the sun is umbrellas due to the fact of Morpheus [skip the night via sleeping in a bed as a voting system] and Electroblob's Wizardry [ability to stop and start rain by using the Invoke Weather spell] being present in the pack.
Any help (if possible) on this is greatly appreciated and thank you two for the quick replies.
@focamacho
I think IVampirePlayer#isGettingSundamage()' is better suited (it returns the cached value).
ticksInSun` is just a counter based on that method.
You could also use this to only damage the item when its protect sundamage, but apply the effect all the time.
But I guess the outcome is pretty similar.