Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underwater visibility is increased even if the player is not wearing a Diving Helmet #4826

Closed
LaGz4643 opened this issue May 25, 2023 · 9 comments
Labels
status: fixed in next release Issue will be fixed in the next release type: bug Issue where something isn't working

Comments

@LaGz4643
Copy link

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

  1. Swim underwater. A larger body of water like an ocean or river makes it easier to notice this issue.
  2. Notice the distance of the underwater fog.
  3. Equip a Diving Helmet.
  4. 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:
2023-05-25_12 10 51

Water fog with Create installed:
2023-05-25_12 06 51

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.

@LaGz4643 LaGz4643 added the type: bug Issue where something isn't working label May 25, 2023
@VOLKOUL
Copy link

VOLKOUL commented May 26, 2023

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ᴛ

@Bomb787
Copy link

Bomb787 commented Jun 9, 2023

Also getting this with 0.5.1b.

@electricsteve
Copy link

electricsteve commented Jun 24, 2023

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

@PRO-2684
Copy link

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.

@PotionSeeker
Copy link

PotionSeeker commented Jun 24, 2023

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:

@VOLKOUL
Copy link

VOLKOUL commented Jun 30, 2023

Damn you're the goat!
The devs gotta see this!

@Aceplante
Copy link

please fix :(

@Jakobuo
Copy link

Jakobuo commented Jul 1, 2023

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)].

@PepperCode1
Copy link
Member

This was fixed yesterday in commit a947a06.

@PepperCode1 PepperCode1 added the status: fixed in next release Issue will be fixed in the next release label Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: fixed in next release Issue will be fixed in the next release type: bug Issue where something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants