add DhApiBeforeFogRenderEvent
This commit is contained in:
+126
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Distant Horizons mod
|
||||||
|
* licensed under the GNU LGPL v3 License.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 James Seibel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.api.methods.events.abstractEvents;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiCancelableEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiCancelableEventParam;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiMutableFogRenderParam;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
|
import com.seibel.distanthorizons.api.objects.data.IDhApiFullDataSource;
|
||||||
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired before DH renders its fog.
|
||||||
|
* Canceling this event disables fog for that frame.
|
||||||
|
*
|
||||||
|
* @author James Seibel
|
||||||
|
* @version 2026-05-20
|
||||||
|
* @since API 7.0.0
|
||||||
|
*/
|
||||||
|
public abstract class DhApiBeforeFogRenderEvent implements IDhApiCancelableEvent<DhApiBeforeFogRenderEvent.EventParam>
|
||||||
|
{
|
||||||
|
/** Fired before fog is generated. */
|
||||||
|
public abstract void beforeRender(DhApiCancelableEventParam<DhApiBeforeFogRenderEvent.EventParam> event);
|
||||||
|
|
||||||
|
|
||||||
|
//=========================//
|
||||||
|
// internal DH API methods //
|
||||||
|
//=========================//
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void fireEvent(DhApiCancelableEventParam<DhApiBeforeFogRenderEvent.EventParam> event) { this.beforeRender(event); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==================//
|
||||||
|
// parameter object //
|
||||||
|
//==================//
|
||||||
|
|
||||||
|
public static class EventParam implements IDhApiEventParam
|
||||||
|
{
|
||||||
|
private final DhApiRenderParam renderParam;
|
||||||
|
private final DhApiFogRenderParam originalFogRenderParam;
|
||||||
|
private final DhApiMutableFogRenderParam fogRenderParam;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public EventParam(DhApiRenderParam renderParam, DhApiFogRenderParam fogRenderParam)
|
||||||
|
{
|
||||||
|
this.renderParam = renderParam;
|
||||||
|
this.originalFogRenderParam = fogRenderParam;
|
||||||
|
this.fogRenderParam = new DhApiMutableFogRenderParam(fogRenderParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================//
|
||||||
|
// getters/setters //
|
||||||
|
//=================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public DhApiRenderParam getRenderParam() { return this.renderParam; }
|
||||||
|
|
||||||
|
/** immutable, stores what DH would do without API intervention so API users have a reference point */
|
||||||
|
public DhApiFogRenderParam getOriginalFogRenderParam() { return this.originalFogRenderParam; }
|
||||||
|
/** mutable, can be modified by API users */
|
||||||
|
public DhApiMutableFogRenderParam getFogRenderParam() { return this.fogRenderParam; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==========================//
|
||||||
|
// base api event overrides //
|
||||||
|
//==========================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the same instance of this event.
|
||||||
|
* Copying this event isn't supported
|
||||||
|
* since the internal parameters must be mutated
|
||||||
|
* by API users in order to be tracked by DH's internal
|
||||||
|
* logic.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DhApiBeforeFogRenderEvent.EventParam copy() { return this; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getCopyBeforeFire() { return false; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+202
@@ -0,0 +1,202 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Distant Horizons mod
|
||||||
|
* licensed under the GNU LGPL v3 License.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 James Seibel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.api.methods.events.sharedParameterObjects;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiFarFogConfig;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiFogConfig;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiHeightFogConfig;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains all the information needed to render Distant Horizons' fog.
|
||||||
|
*
|
||||||
|
* @see IDhApiFogConfig
|
||||||
|
* @see IDhApiFarFogConfig
|
||||||
|
* @see IDhApiHeightFogConfig
|
||||||
|
*
|
||||||
|
* @author James Seibel
|
||||||
|
* @version 2026-05-20
|
||||||
|
* @since API 7.0.0
|
||||||
|
*/
|
||||||
|
public class DhApiFogRenderParam implements IDhApiEventParam
|
||||||
|
{
|
||||||
|
protected Color fogColor;
|
||||||
|
public Color getFogColor() { return this.fogColor; }
|
||||||
|
|
||||||
|
// far fog //
|
||||||
|
//region
|
||||||
|
|
||||||
|
protected EDhApiFogFalloff farFogFalloff;
|
||||||
|
/** @see IDhApiFarFogConfig#farFogFalloff() */
|
||||||
|
public EDhApiFogFalloff getFarFogFalloff() { return this.farFogFalloff; }
|
||||||
|
|
||||||
|
protected float farFogStartPercent;
|
||||||
|
/** @see IDhApiFarFogConfig#farFogStartDistance() */
|
||||||
|
public float getFarFogStartPercent() { return this.farFogStartPercent; }
|
||||||
|
|
||||||
|
protected float farFogEndPercent;
|
||||||
|
/** @see IDhApiFarFogConfig#farFogEndDistance() */
|
||||||
|
public float getFarFogEndPercent() { return this.farFogEndPercent; }
|
||||||
|
|
||||||
|
protected float farFogMinThickness;
|
||||||
|
/** @see IDhApiFarFogConfig#farFogMinThickness() */
|
||||||
|
public float getFarFogMinThickness() { return this.farFogMinThickness; }
|
||||||
|
|
||||||
|
protected float farFogMaxThickness;
|
||||||
|
/** @see IDhApiFarFogConfig#farFogMaxThickness() */
|
||||||
|
public float getFarFogMaxThickness() { return this.farFogMaxThickness; }
|
||||||
|
|
||||||
|
protected float farFogDensity;
|
||||||
|
/** @see IDhApiFarFogConfig#farFogDensity() */
|
||||||
|
public float getFarFogDensity() { return this.farFogDensity; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
// height fog //
|
||||||
|
//region
|
||||||
|
|
||||||
|
protected EDhApiFogFalloff heightFogFalloff;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogFalloff() */
|
||||||
|
public EDhApiFogFalloff getHeightFogFalloff() { return this.heightFogFalloff; }
|
||||||
|
|
||||||
|
protected EDhApiHeightFogMixMode heightFogMixingMode;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogMixMode() */
|
||||||
|
public EDhApiHeightFogMixMode getHeightFogMixingMode() { return this.heightFogMixingMode; }
|
||||||
|
|
||||||
|
protected EDhApiHeightFogDirection heightFogDirection;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogDirection() */
|
||||||
|
public EDhApiHeightFogDirection getHeightFogDirection() { return this.heightFogDirection; }
|
||||||
|
|
||||||
|
protected float heightFogBaseHeight;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogBaseHeight() */
|
||||||
|
public float getHeightFogBaseHeight() { return this.heightFogBaseHeight; }
|
||||||
|
|
||||||
|
protected float heightFogStartPercent;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogStartingHeightPercent() */
|
||||||
|
public float getHeightFogStartPercent() { return this.heightFogStartPercent; }
|
||||||
|
|
||||||
|
protected float heightFogEndPercent;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogEndingHeightPercent() */
|
||||||
|
public float getHeightFogEndPercent() { return this.heightFogEndPercent; }
|
||||||
|
|
||||||
|
protected float heightFogMinThickness;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogMinThickness() */
|
||||||
|
public float getHeightFogMinThickness() { return this.heightFogMinThickness; }
|
||||||
|
|
||||||
|
protected float heightFogMaxThickness;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogMaxThickness() */
|
||||||
|
public float getHeightFogMaxThickness() { return this.heightFogMaxThickness; }
|
||||||
|
|
||||||
|
protected float heightFogDensity;
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogDensity() */
|
||||||
|
public float getHeightFogDensity() { return this.heightFogDensity; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==============//
|
||||||
|
// constructors //
|
||||||
|
//==============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public DhApiFogRenderParam(DhApiFogRenderParam parent)
|
||||||
|
{
|
||||||
|
this(
|
||||||
|
parent.fogColor,
|
||||||
|
|
||||||
|
// far fog
|
||||||
|
parent.farFogFalloff,
|
||||||
|
parent.farFogStartPercent, parent.farFogEndPercent,
|
||||||
|
parent.farFogMinThickness, parent.farFogEndPercent,
|
||||||
|
parent.farFogDensity,
|
||||||
|
|
||||||
|
// height fog
|
||||||
|
parent.heightFogFalloff,
|
||||||
|
parent.heightFogMixingMode, parent.heightFogDirection,
|
||||||
|
parent.heightFogBaseHeight,
|
||||||
|
parent.heightFogStartPercent, parent.heightFogEndPercent,
|
||||||
|
parent.heightFogMinThickness, parent.heightFogMaxThickness,
|
||||||
|
parent.heightFogDensity
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public DhApiFogRenderParam(
|
||||||
|
Color fogColor,
|
||||||
|
|
||||||
|
// far fog
|
||||||
|
EDhApiFogFalloff farFogFalloff,
|
||||||
|
float farFogStartPercent, float farFogEndPercent,
|
||||||
|
float farFogMinThickness, float farFogMaxThickness,
|
||||||
|
float farFogDensity,
|
||||||
|
|
||||||
|
// height fog
|
||||||
|
EDhApiFogFalloff heightFogFalloff,
|
||||||
|
EDhApiHeightFogMixMode heightFogMixingMode, EDhApiHeightFogDirection heightFogDirection,
|
||||||
|
float heightFogBaseHeight,
|
||||||
|
float heightFogStartPercent, float heightFogEndPercent,
|
||||||
|
float heightFogMinThickness, float heightFogMaxThickness,
|
||||||
|
float heightFogDensity
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.fogColor = fogColor;
|
||||||
|
|
||||||
|
// far fog
|
||||||
|
this.farFogFalloff = farFogFalloff;
|
||||||
|
this.farFogStartPercent = farFogStartPercent;
|
||||||
|
this.farFogEndPercent = farFogEndPercent;
|
||||||
|
this.farFogMinThickness = farFogMinThickness;
|
||||||
|
this.farFogMaxThickness = farFogMaxThickness;
|
||||||
|
this.farFogDensity = farFogDensity;
|
||||||
|
|
||||||
|
// height fog
|
||||||
|
this.heightFogFalloff = heightFogFalloff;
|
||||||
|
this.heightFogMixingMode = heightFogMixingMode;
|
||||||
|
this.heightFogDirection = heightFogDirection;
|
||||||
|
this.heightFogBaseHeight = heightFogBaseHeight;
|
||||||
|
this.heightFogStartPercent = heightFogStartPercent;
|
||||||
|
this.heightFogEndPercent = heightFogEndPercent;
|
||||||
|
this.heightFogMinThickness = heightFogMinThickness;
|
||||||
|
this.heightFogMaxThickness = heightFogMaxThickness;
|
||||||
|
this.heightFogDensity = heightFogDensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// base overrides //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DhApiFogRenderParam copy() { return new DhApiFogRenderParam(this); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+117
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Distant Horizons mod
|
||||||
|
* licensed under the GNU LGPL v3 License.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 James Seibel
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.seibel.distanthorizons.api.methods.events.sharedParameterObjects;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiFarFogConfig;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiFogConfig;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiHeightFogConfig;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mutable version of {@link DhApiFogRenderParam} to allow
|
||||||
|
* API modification of DH's fog rendering.
|
||||||
|
*
|
||||||
|
* @see IDhApiFogConfig
|
||||||
|
* @see IDhApiFarFogConfig
|
||||||
|
* @see IDhApiHeightFogConfig
|
||||||
|
* @see DhApiFogRenderParam
|
||||||
|
*
|
||||||
|
* @author James Seibel
|
||||||
|
* @version 2026-05-20
|
||||||
|
* @since API 7.0.0
|
||||||
|
*/
|
||||||
|
public class DhApiMutableFogRenderParam extends DhApiFogRenderParam
|
||||||
|
{
|
||||||
|
public void setFogColor(Color fogColor) { this.fogColor = fogColor; }
|
||||||
|
|
||||||
|
// far fog //
|
||||||
|
//region
|
||||||
|
|
||||||
|
/** @see IDhApiFarFogConfig#farFogFalloff() */
|
||||||
|
public void setFarFogFalloff(EDhApiFogFalloff farFogFalloff) { this.farFogFalloff = farFogFalloff; }
|
||||||
|
/** @see IDhApiFarFogConfig#farFogStartDistance() */
|
||||||
|
public void setFarFogStartPercent(float farFogStartPercent) { this.farFogStartPercent = farFogStartPercent; }
|
||||||
|
/** @see IDhApiFarFogConfig#farFogEndDistance() */
|
||||||
|
public void setFarFogEndPercent(float farFogEndPercent) { this.farFogEndPercent = farFogEndPercent; }
|
||||||
|
/** @see IDhApiFarFogConfig#farFogMinThickness() */
|
||||||
|
public void setFarFogMinThickness(float farFogMinThickness) { this.farFogMinThickness = farFogMinThickness; }
|
||||||
|
/** @see IDhApiFarFogConfig#farFogMaxThickness() */
|
||||||
|
public void setFarFogMaxThickness(float farFogMaxThickness) { this.farFogMaxThickness = farFogMaxThickness; }
|
||||||
|
/** @see IDhApiFarFogConfig#farFogDensity() */
|
||||||
|
public void setFarFogDensity(float farFogDensity) { this.farFogDensity = farFogDensity; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
// height fog //
|
||||||
|
//region
|
||||||
|
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogFalloff() */
|
||||||
|
public void setHeightFogFalloff(EDhApiFogFalloff heightFogFalloff) { this.heightFogFalloff = heightFogFalloff; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogMixMode() */
|
||||||
|
public void setHeightFogMixingMode(EDhApiHeightFogMixMode heightFogMixingMode) { this.heightFogMixingMode = heightFogMixingMode; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogDirection() */
|
||||||
|
public void setHeightFogDirection(EDhApiHeightFogDirection heightFogDirection) { this.heightFogDirection = heightFogDirection; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogBaseHeight() */
|
||||||
|
public void setHeightFogBaseHeight(float heightFogBaseHeight) { this.heightFogBaseHeight = heightFogBaseHeight; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogStartingHeightPercent() */
|
||||||
|
public void setHeightFogStartPercent(float heightFogStartPercent) { this.heightFogStartPercent = heightFogStartPercent; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogEndingHeightPercent() */
|
||||||
|
public void setHeightFogEndPercent(float heightFogEnd) { this.heightFogEndPercent = heightFogEnd; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogMinThickness() */
|
||||||
|
public void setHeightFogMinThickness(float heightFogMinThickness) { this.heightFogMinThickness = heightFogMinThickness; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogMaxThickness() */
|
||||||
|
public void setHeightFogMaxThickness(float heightFogMaxThickness) { this.heightFogMaxThickness = heightFogMaxThickness; }
|
||||||
|
/** @see IDhApiHeightFogConfig#heightFogDensity() */
|
||||||
|
public void setHeightFogDensity(float heightFogDensity) { this.heightFogDensity = heightFogDensity; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==============//
|
||||||
|
// constructors //
|
||||||
|
//==============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public DhApiMutableFogRenderParam(DhApiFogRenderParam parent)
|
||||||
|
{ super(parent); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// base overrides //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DhApiMutableFogRenderParam copy() { return new DhApiMutableFogRenderParam(this); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
package com.seibel.distanthorizons.core.render.renderer;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||||
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeFogRenderEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DhApiFogRenderParam
|
||||||
|
* @see DhApiBeforeFogRenderEvent.EventParam
|
||||||
|
*/
|
||||||
|
public class FogRenderParamFactory
|
||||||
|
{
|
||||||
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static DhApiBeforeFogRenderEvent.EventParam createRenderParam(RenderParams renderParams)
|
||||||
|
{
|
||||||
|
Color fogColor = getFogColor(renderParams.partialTicks);
|
||||||
|
|
||||||
|
// far fog
|
||||||
|
EDhApiFogFalloff farFogFalloff = Config.Client.Advanced.Graphics.Fog.farFogFalloff.get();
|
||||||
|
float farFogStart = Config.Client.Advanced.Graphics.Fog.farFogStart.get();
|
||||||
|
float farFogEnd = Config.Client.Advanced.Graphics.Fog.farFogEnd.get();
|
||||||
|
float farFogMin = Config.Client.Advanced.Graphics.Fog.farFogMin.get();
|
||||||
|
float farFogMax = Config.Client.Advanced.Graphics.Fog.farFogMax.get();
|
||||||
|
float farFogDensity = Config.Client.Advanced.Graphics.Fog.farFogDensity.get();
|
||||||
|
|
||||||
|
|
||||||
|
// height fog
|
||||||
|
EDhApiFogFalloff heightFogFalloff = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogFalloff.get();
|
||||||
|
EDhApiHeightFogMixMode heightFogMixingMode = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMixMode.get();
|
||||||
|
EDhApiHeightFogDirection heightFogCameraDirection = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDirection.get();
|
||||||
|
|
||||||
|
float heightFogBaseHeight = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogBaseHeight.get();
|
||||||
|
float heightFogStart = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogStart.get();
|
||||||
|
float heightFogEnd = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogEnd.get();
|
||||||
|
float heightFogMin = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMin.get();
|
||||||
|
float heightFogMax = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMax.get();
|
||||||
|
float heightFogDensity = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDensity.get();
|
||||||
|
|
||||||
|
// override fog if underwater
|
||||||
|
if (MC_RENDER.isFogStateSpecial())
|
||||||
|
{
|
||||||
|
// hide everything behind fog
|
||||||
|
farFogStart = 0.0f;
|
||||||
|
farFogEnd = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
DhApiFogRenderParam fogRenderParam = new DhApiFogRenderParam(
|
||||||
|
fogColor,
|
||||||
|
|
||||||
|
// far fog
|
||||||
|
farFogFalloff,
|
||||||
|
farFogStart, farFogEnd,
|
||||||
|
farFogMin, farFogMax,
|
||||||
|
farFogDensity,
|
||||||
|
|
||||||
|
// height fog
|
||||||
|
heightFogFalloff,
|
||||||
|
heightFogMixingMode, heightFogCameraDirection,
|
||||||
|
heightFogBaseHeight,
|
||||||
|
heightFogStart, heightFogEnd,
|
||||||
|
heightFogMin, heightFogMax,
|
||||||
|
heightFogDensity
|
||||||
|
);
|
||||||
|
|
||||||
|
DhApiBeforeFogRenderEvent.EventParam fogRenderEventParam = new DhApiBeforeFogRenderEvent.EventParam(renderParams, fogRenderParam);
|
||||||
|
return fogRenderEventParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Color getFogColor(float partialTicks)
|
||||||
|
{
|
||||||
|
Color fogColor;
|
||||||
|
|
||||||
|
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
|
||||||
|
{
|
||||||
|
fogColor = MC_RENDER.getSkyColor();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fogColor = MC_RENDER.getFogColor(partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fogColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+12
-5
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.render.renderer;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiTransparency;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiTransparency;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
@@ -118,9 +119,9 @@ public class LodRenderer
|
|||||||
|
|
||||||
private void renderTerrain(RenderParams renderParams, IProfilerWrapper profiler, boolean runningDeferredPass)
|
private void renderTerrain(RenderParams renderParams, IProfilerWrapper profiler, boolean runningDeferredPass)
|
||||||
{
|
{
|
||||||
//====================//
|
|
||||||
// validate rendering //
|
// validate rendering //
|
||||||
//====================//
|
//====================//
|
||||||
|
//====================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
boolean deferTransparentRendering = DhApiRenderProxy.INSTANCE.getDeferTransparentRendering();
|
boolean deferTransparentRendering = DhApiRenderProxy.INSTANCE.getDeferTransparentRendering();
|
||||||
@@ -202,6 +203,8 @@ public class LodRenderer
|
|||||||
renderFog |= renderParams.vanillaFogEnabled;
|
renderFog |= renderParams.vanillaFogEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DhApiBeforeFogRenderEvent.EventParam fogRenderEventParam = FogRenderParamFactory.createRenderParam(renderParams);
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -270,11 +273,13 @@ public class LodRenderer
|
|||||||
|
|
||||||
// fog
|
// fog
|
||||||
|
|
||||||
if (renderFog)
|
boolean cancelFogEvent = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeFogRenderEvent.class, fogRenderEventParam);
|
||||||
|
if (renderFog
|
||||||
|
&& !cancelFogEvent)
|
||||||
{
|
{
|
||||||
profiler.popPush("LOD Fog");
|
profiler.popPush("LOD Fog");
|
||||||
|
|
||||||
this.fogRenderer.render(renderParams);
|
this.fogRenderer.render(renderParams, fogRenderEventParam.getFogRenderParam());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -333,11 +338,13 @@ public class LodRenderer
|
|||||||
this.renderTerrain(this.terrainRenderer, renderBufferHandler, renderParams, /*opaquePass*/ false, profiler);
|
this.renderTerrain(this.terrainRenderer, renderBufferHandler, renderParams, /*opaquePass*/ false, profiler);
|
||||||
|
|
||||||
|
|
||||||
if (renderFog)
|
boolean cancelFogEvent = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeFogRenderEvent.class, fogRenderEventParam);
|
||||||
|
if (renderFog
|
||||||
|
&& !cancelFogEvent)
|
||||||
{
|
{
|
||||||
profiler.popPush("LOD Fog");
|
profiler.popPush("LOD Fog");
|
||||||
|
|
||||||
this.fogRenderer.render(renderParams);
|
this.fogRenderer.render(renderParams, fogRenderEventParam.getFogRenderParam());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -19,12 +19,13 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass;
|
package com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
||||||
|
|
||||||
public interface IDhFogRenderer extends IBindable
|
public interface IDhFogRenderer extends IBindable
|
||||||
{
|
{
|
||||||
|
|
||||||
void render(RenderParams renderParams);
|
void render(RenderParams renderParams, DhApiFogRenderParam fogRenderParams);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user