Vampirism - Become a vampire!

Vampirism - Become a vampire!

16M Downloads

[Bug] Farmland doesn't protect against sunlight

Twisted-Code opened this issue · 10 comments

commented

Versions

  • Minecraft: 1.15.2
  • Forge: 3.1.2.36
  • Vampirism: 1.7.0.beta.1
  • ModPack: the self authored one I mentioned in my previous two issues (i.e. this pack)

Issue Description

Farmland doesn't protect against sunlight, i.e. if you stand under farmland during the day as a vampire and have no other blocks between you and the sky, you get the yellow glare and any other weaknesses corresponding to your level.

Reproduce Steps

hoe some minecraft:dirt
stand under it
/vampirism level vampirism:vampire 4
/time set day
die!

Additional Information

commented

(I suspect this has something to do with a bug you fixed some time ago (years I guess?) involving farmland protecting against sunlight when standing on it, but that's just an educated guess.)

commented

i can only confirm that farmland doesn't protect you when the farmland is below ocean level (y=64)

commented

Maybe farmland is considered as transparent by MC

if (iblockstate.getOpacity(world, blockpos) > 0) {

will have to check if that is true and if there is an alternative solution

commented

Block#propagatesSkylightDown could do the trick

commented

And since there could be water even above see level, we should skip the

if (pos.getY() >= world.getSeaLevel()) {
or are there any reasons to keep it?

commented

That's a performance tradeoff.
Thereby we don't have to go though the entire vertical stack for every entity every x ticks to check for water blocks.
Vanilla uses a static light map that is only updated on block changes AFAIK, but that's probably not worth it for Vampirism.
Maybe there is a better solution involving propagatesSkylightDown but I don't know.
Also there might be a better sweet spot for the tradeoff

commented

ok, investigated a little more and found out, that we cant do anything about this, since there is no difference between the glass block and the farm block. So the only ways is to whitelist the farmlandblock by a simple if, creating a whitelisted block tag (for modcompat) or leave it be.

commented

Mhhh, can't find anything on first sight either. However, there must be a way to distinhush them as it works for vanilla's light level calculations.
Other blocks that have the same issue are single half slabs.

commented

But even the light doesn't work right for them, if you build yourself up with a slab / farmland over you there is still light.

But maybe the Block#isSolid method can help, because solid is set false for only blocks that can pass through light.
So if (iblockstate.getOpacity(world, blockpos) > 0 || iblockstate.isSolid()) (search for usages of Block.Properties#notSolid)

commented