Skip to content

Commit

Permalink
add black fog effect when immersed in crude oil
Browse files Browse the repository at this point in the history
  • Loading branch information
desht committed Nov 13, 2024
1 parent b0dadfc commit a3d8de7
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
import me.desht.pneumaticcraft.common.pneumatic_armor.CommonUpgradeHandlers;
import me.desht.pneumaticcraft.common.pneumatic_armor.JetBootsStateTracker;
import me.desht.pneumaticcraft.common.pneumatic_armor.JetBootsStateTracker.JetBootsState;
import me.desht.pneumaticcraft.common.registry.ModBlocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -118,9 +121,28 @@ public static void fogDensityEvent(ViewportEvent.RenderFog event) {
event.setFogShape(FogShape.SPHERE);
event.setCanceled(true);
}
} else if (isPlayerHeadInOil()) {
event.setNearPlaneDistance(0.25F);
event.setFarPlaneDistance(2.0F);
event.setFogShape(FogShape.SPHERE);
event.setCanceled(true);
}
}

@SubscribeEvent
public static void fogColorEvent(ViewportEvent.ComputeFogColor event) {
if (isPlayerHeadInOil()) {
event.setRed(0.1f);
event.setGreen(0.1f);
event.setBlue(0.1f);
}
}

private static boolean isPlayerHeadInOil() {
Player player = Minecraft.getInstance().player;
return player != null && !player.isSpectator() && player.level().getBlockState(BlockPos.containing(player.getEyePosition())).getBlock() == ModBlocks.OIL.get();
}

@SubscribeEvent
public static void guiContainerForeground(ContainerScreenEvent.Render.Foreground event) {
// general extra rendering
Expand Down

0 comments on commit a3d8de7

Please sign in to comment.