Underwater visibility is increased even if the player is not wearing a Diving Helmet
LaGz4643 opened this issue · 9 comments
Describe the Bug
Wearing a Diving Helmet usually increases the distance of the underwater fog and allows the player to see further. However, since Create 0.5.1a, the visibility underwater is always increased no matter what the player is wearing in their head slot (even if the slot is empty). This issue occurs on both 1.18.2 and 1.19.2.
Reproduction Steps
- Swim underwater. A larger body of water like an ocean or river makes it easier to notice this issue.
- Notice the distance of the underwater fog.
- Equip a Diving Helmet.
- The distance of the fog does not change as it was already increased before you equipped the Diving Helmet.
Expected Result
The distance of the underwater fog should only be increased when wearing a Diving Helmet.
Screenshots and Videos
Water fog without Create installed:
Water fog with Create installed:
Crash Report or Log
No response
Operating System
Windows 11
Mod Version
0.5.1b
Minecraft Version
1.19.2
Forge Version
43.2.3
Other Mods
This issue occurs with only Create installed.
Additional Context
Towards the end of the getFogDensity
method in the ClientEvents
class, DivingHelmetItem.getWornItem()
is called, which returns the ItemStack in the entity's head slot. There is no check for what item this ItemStack is before modifying the water fog distance. There is only a null check, but DivingHelmetItem.getWornItem()
only returns null if the entity is not a LivingEntity
. This issue does not affect lava fog because there is a check if the ItemStack is a Netherite Diving Helmet before modifying the lava fog distance.
Same here!
I recently made a 1.19.2 modpack with like 300 mods and had to check EVERY. SINGLE. MOD. to find out what caused it lol
ɪ ɴᴇᴇᴅ sᴏᴍᴇ ʀᴇsᴛ
Ah, hope someone is already trying to fix this, otherwise i will maybe try to fix it in like half a week.
EDIT: It is an easy fix, so it would probably take like max 1 hour
Same here! I recently made a 1.19.2 modpack with like 300 mods and had to check EVERY. SINGLE. MOD. to find out what caused it lol ɪ ɴᴇᴇᴅ sᴏᴍᴇ ʀᴇsᴛ
You can try to find out the buggy mod using binary search, especailly when there's a large number of them.
This is actually incredibly easy to solve, it requires changing a single line of code. At line 320 in the ClientEvents.java where it says: if (FluidHelper.isWater(fluid). The fix is to add a condition for the helmet. I don't really work with Java so there may be a better way to fix the problem overall, but I personally have just added a check for the Copper Diving Helmet. This is what the fixed portion of code looks like:
ItemStack divingHelmet = DivingHelmetItem.getWornItem(entity);
if (divingHelmet != null) {
if (FluidHelper.isWater(fluid) && AllItems.COPPER_DIVING_HELMET.isIn(divingHelmet)) {
event.scaleFarPlaneDistance(6.25f);
event.setCanceled(true);
return;
} else if (FluidHelper.isLava(fluid) && AllItems.NETHERITE_DIVING_HELMET.isIn(divingHelmet)) {
event.setNearPlaneDistance(-4.0f);
event.setFarPlaneDistance(20.0f);
event.setCanceled(true);
return;
}
}
An even better fix might look something like this, but I haven't tested this personally:
ItemStack divingHelmet = DivingHelmetItem.getWornItem(entity);
if (divingHelmet != null) {
if (FluidHelper.isWater(fluid) && AllItems.COPPER_DIVING_HELMET.isIn(divingHelmet) && AllItems.NETHERITE_DIVING_HELMET.isIn(divingHelmet)) {
event.scaleFarPlaneDistance(6.25f);
event.setCanceled(true);
return;
} else if (FluidHelper.isLava(fluid) && AllItems.NETHERITE_DIVING_HELMET.isIn(divingHelmet)) {
event.setNearPlaneDistance(-4.0f);
event.setFarPlaneDistance(20.0f);
event.setCanceled(true);
return;
}
}
This can be specifically located here:
The third line off @PotionSeeker 's better fix should be
if (FluidHelper.isWater(fluid) && (AllItems.COPPER_DIVING_HELMET.isIn(divingHelmet) || AllItems.NETHERITE_DIVING_HELMET.isIn(divingHelmet)))
because that expression is true if [fluid is water and (wearing copper diving helmet or wearing netherite diving helmet)].
This was fixed yesterday in commit a947a06.