Problem Entity burns at night (resolved)

Started by sprits2000 on

Topic category: Help with Minecraft modding (Java Edition)

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

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);
					}
				}
			}
		}
	}
}