Problem Entity burns at night (resolved)

Started by sprits2000 on

Topic category: Help with modding (Java Edition)

Last seen on 17:57, 23. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Problem Entity burns at night (resolved)
Sat, 03/23/2024 - 14:08 (edited)

Okey I have a problem. I would like my entity to burn during the day and not burn at night. The code works halfway, my entity burns and takes flame damage during the day but at night it also burns but takes no damage (it's just the texture of the flames).

Edited by sprits2000 on Sat, 03/23/2024 - 14:08
Last seen on 17:32, 23. Apr 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have run into this myself…
Sat, 03/23/2024 - 00:38

I have run into this myself in the past, and I found a solution.

You need to put the entire procedure in an "if" block, then attach a "not" block, then "is provided world client-side" That fixes a lot of visual glitches, including 'ghost' fire, 'ghost' blocks, and 'ghost' potion effects, so you can use this same method if you run into any of those other problems.

Last seen on 17:57, 23. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you very much for your…
Sat, 03/23/2024 - 12:18

Thank you very much for your reply.

The problem persists, could you tell me if the changes made to my code follow your advice? 
Is there anything left to modify?

Code image 2 : https://1drv.ms/i/s!Aq6mSRcVQGujgYZck6a8HEUMIt0VsA?e=u4CvFH

Last seen on 17:57, 23. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've got the solution  …
Sat, 03/23/2024 - 14:07

I've got the solution

 

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;

public class DailyFireProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		if (world.canSeeSkyFromBelowWater(BlockPos.containing(x, y + 1, z))) {
			if (world instanceof Level _lvl1 && _lvl1.isDay() && !(world.getLevelData().isRaining() || world.getLevelData().isThundering())) {
				if (!entity.isOnFire()) {
					if (!world.isClientSide()) {
						entity.setSecondsOnFire(5);
					}
				}
			}
		}
	}
}