2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* This library 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 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library 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 library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2014-06-04 20:32:55 +00:00
|
|
|
package net.minecraftforge.client.event;
|
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2014-06-04 20:32:55 +00:00
|
|
|
import net.minecraft.client.renderer.EntityRenderer;
|
2018-12-21 22:45:35 +00:00
|
|
|
import net.minecraft.client.renderer.FogRenderer;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2018-12-21 22:45:35 +00:00
|
|
|
import net.minecraft.fluid.IFluidState;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Cancelable;
|
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2014-06-04 20:32:55 +00:00
|
|
|
|
2018-09-22 10:40:22 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Event.HasResult;
|
|
|
|
|
2014-06-04 20:32:55 +00:00
|
|
|
/**
|
2016-02-16 13:52:41 +00:00
|
|
|
* Event that hooks into EntityRenderer, allowing any feature to customize visual attributes
|
|
|
|
* the player sees.
|
2014-06-04 20:32:55 +00:00
|
|
|
*/
|
2018-06-11 01:12:46 +00:00
|
|
|
public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event
|
2014-06-04 20:32:55 +00:00
|
|
|
{
|
2016-03-01 17:52:19 +00:00
|
|
|
private final EntityRenderer renderer;
|
|
|
|
private final Entity entity;
|
|
|
|
private final IBlockState state;
|
2018-12-21 22:45:35 +00:00
|
|
|
private final IFluidState fluidState;
|
2016-03-01 17:52:19 +00:00
|
|
|
private final double renderPartialTicks;
|
2014-06-04 20:32:55 +00:00
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public EntityViewRenderEvent(EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
2014-06-04 20:32:55 +00:00
|
|
|
{
|
|
|
|
this.renderer = renderer;
|
|
|
|
this.entity = entity;
|
2016-03-01 17:52:19 +00:00
|
|
|
this.state = state;
|
2018-12-21 22:45:35 +00:00
|
|
|
this.fluidState = fluidState;
|
2014-06-04 20:32:55 +00:00
|
|
|
this.renderPartialTicks = renderPartialTicks;
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public EntityRenderer getRenderer()
|
|
|
|
{
|
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Entity getEntity()
|
|
|
|
{
|
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public IBlockState getBlockState()
|
2016-03-01 17:52:19 +00:00
|
|
|
{
|
|
|
|
return state;
|
|
|
|
}
|
2018-12-21 22:45:35 +00:00
|
|
|
|
|
|
|
public IFluidState getFluidState()
|
|
|
|
{
|
|
|
|
return fluidState;
|
|
|
|
}
|
2016-03-01 17:52:19 +00:00
|
|
|
|
|
|
|
public double getRenderPartialTicks()
|
|
|
|
{
|
|
|
|
return renderPartialTicks;
|
|
|
|
}
|
2018-12-21 22:45:35 +00:00
|
|
|
|
|
|
|
private static class FogEvent extends EntityViewRenderEvent
|
|
|
|
{
|
|
|
|
private final FogRenderer fogRenderer;
|
|
|
|
|
|
|
|
protected FogEvent(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks)
|
|
|
|
{
|
|
|
|
super(renderer, entity, state, fluidState, renderPartialTicks);
|
|
|
|
this.fogRenderer = fogRenderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FogRenderer getFogRenderer() { return fogRenderer; }
|
|
|
|
}
|
2016-03-01 17:52:19 +00:00
|
|
|
|
|
|
|
/**
|
2014-06-04 20:32:55 +00:00
|
|
|
* Event that allows any feature to customize the fog density the player sees.
|
|
|
|
* NOTE: In order to make this event have an effect, you must cancel the event
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2018-12-21 22:45:35 +00:00
|
|
|
public static class FogDensity extends FogEvent
|
2014-06-04 20:32:55 +00:00
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private float density;
|
2014-06-04 20:32:55 +00:00
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public FogDensity(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float density)
|
2014-06-04 20:32:55 +00:00
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
2016-03-24 08:44:52 +00:00
|
|
|
this.setDensity(density);
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getDensity()
|
|
|
|
{
|
|
|
|
return density;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDensity(float density)
|
|
|
|
{
|
2014-06-04 20:32:55 +00:00
|
|
|
this.density = density;
|
|
|
|
}
|
|
|
|
}
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
|
2014-07-27 05:20:42 +00:00
|
|
|
/**
|
|
|
|
* Event that allows any feature to customize the rendering of fog.
|
|
|
|
*/
|
|
|
|
@HasResult
|
2018-12-21 22:45:35 +00:00
|
|
|
public static class RenderFogEvent extends FogEvent
|
2014-07-27 05:20:42 +00:00
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private final int fogMode;
|
|
|
|
private final float farPlaneDistance;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public RenderFogEvent(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, int fogMode, float farPlaneDistance)
|
2014-07-27 05:20:42 +00:00
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
2014-07-27 05:20:42 +00:00
|
|
|
this.fogMode = fogMode;
|
|
|
|
this.farPlaneDistance = farPlaneDistance;
|
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
|
|
|
public int getFogMode()
|
|
|
|
{
|
|
|
|
return fogMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getFarPlaneDistance()
|
|
|
|
{
|
|
|
|
return farPlaneDistance;
|
|
|
|
}
|
2014-07-27 05:20:42 +00:00
|
|
|
}
|
2014-06-04 20:32:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event that allows any feature to customize the color of fog the player sees.
|
|
|
|
* NOTE: Any change made to one of the color variables will affect the result seen in-game.
|
|
|
|
*/
|
2018-12-21 22:45:35 +00:00
|
|
|
public static class FogColors extends FogEvent
|
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private float red;
|
|
|
|
private float green;
|
|
|
|
private float blue;
|
2014-06-04 20:32:55 +00:00
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public FogColors(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float red, float green, float blue)
|
2014-06-04 20:32:55 +00:00
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
super(fogRenderer, renderer, entity, state, fluidState, renderPartialTicks);
|
2016-03-24 08:44:52 +00:00
|
|
|
this.setRed(red);
|
|
|
|
this.setGreen(green);
|
|
|
|
this.setBlue(blue);
|
2014-06-04 20:32:55 +00:00
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
|
|
|
public float getRed() { return red; }
|
|
|
|
public void setRed(float red) { this.red = red; }
|
|
|
|
public float getGreen() { return green; }
|
|
|
|
public void setGreen(float green) { this.green = green; }
|
|
|
|
public float getBlue() { return blue; }
|
|
|
|
public void setBlue(float blue) { this.blue = blue; }
|
2014-06-04 20:32:55 +00:00
|
|
|
}
|
2015-05-08 14:31:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event that allows mods to alter the angles of the player's camera. Mainly useful for applying roll.
|
|
|
|
*/
|
|
|
|
public static class CameraSetup extends EntityViewRenderEvent
|
|
|
|
{
|
2016-03-24 08:44:52 +00:00
|
|
|
private float yaw;
|
|
|
|
private float pitch;
|
|
|
|
private float roll;
|
2015-05-08 14:31:23 +00:00
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public CameraSetup(EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, float yaw, float pitch, float roll)
|
2015-05-08 14:31:23 +00:00
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
super(renderer, entity, state, fluidState, renderPartialTicks);
|
2016-03-24 08:44:52 +00:00
|
|
|
this.setYaw(yaw);
|
|
|
|
this.setPitch(pitch);
|
|
|
|
this.setRoll(roll);
|
2015-05-08 14:31:23 +00:00
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
|
|
|
public float getYaw() { return yaw; }
|
|
|
|
public void setYaw(float yaw) { this.yaw = yaw; }
|
|
|
|
public float getPitch() { return pitch; }
|
|
|
|
public void setPitch(float pitch) { this.pitch = pitch; }
|
|
|
|
public float getRoll() { return roll; }
|
|
|
|
public void setRoll(float roll) { this.roll = roll; }
|
2015-05-08 14:31:23 +00:00
|
|
|
}
|
2016-02-16 13:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event that allows mods to alter the raw FOV itself.
|
|
|
|
* This directly affects to the FOV without being modified.
|
|
|
|
* */
|
|
|
|
public static class FOVModifier extends EntityViewRenderEvent
|
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
private double fov;
|
2016-02-16 13:52:41 +00:00
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public FOVModifier(EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, double renderPartialTicks, double fov) {
|
|
|
|
super(renderer, entity, state, fluidState, renderPartialTicks);
|
2016-02-16 13:52:41 +00:00
|
|
|
this.setFOV(fov);
|
|
|
|
}
|
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public double getFOV() {
|
2016-02-16 13:52:41 +00:00
|
|
|
return fov;
|
|
|
|
}
|
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public void setFOV(double fov) {
|
2016-02-16 13:52:41 +00:00
|
|
|
this.fov = fov;
|
|
|
|
}
|
|
|
|
}
|
2014-06-04 20:32:55 +00:00
|
|
|
}
|