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
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user