2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2020-07-02 17:49:11 +00:00
|
|
|
* Copyright (c) 2016-2020.
|
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
|
|
|
|
*/
|
|
|
|
|
2012-08-07 08:24:06 +00:00
|
|
|
package net.minecraftforge.client.event;
|
|
|
|
|
2020-01-29 23:46:22 +00:00
|
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
|
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
2019-12-10 19:46:01 +00:00
|
|
|
import net.minecraft.util.math.BlockRayTraceResult;
|
|
|
|
import net.minecraft.util.math.EntityRayTraceResult;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Cancelable;
|
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
2019-02-14 23:08:53 +00:00
|
|
|
import net.minecraft.client.renderer.WorldRenderer;
|
2012-08-07 08:24:06 +00:00
|
|
|
|
2019-12-10 19:46:01 +00:00
|
|
|
/**
|
|
|
|
* An event called whenever the selection highlight around blocks is about to be rendered.
|
|
|
|
* Canceling this event stops the selection highlight from being rendered.
|
|
|
|
*/
|
2012-08-07 08:24:06 +00:00
|
|
|
@Cancelable
|
2019-12-19 04:39:41 +00:00
|
|
|
public class DrawHighlightEvent extends Event
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
2019-02-14 23:08:53 +00:00
|
|
|
private final WorldRenderer context;
|
2019-05-23 23:02:15 +00:00
|
|
|
private final ActiveRenderInfo info;
|
2016-03-24 08:44:52 +00:00
|
|
|
private final RayTraceResult target;
|
|
|
|
private final float partialTicks;
|
2020-01-29 23:46:22 +00:00
|
|
|
private final MatrixStack matrix;
|
|
|
|
private final IRenderTypeBuffer buffers;
|
2016-03-01 12:58:03 +00:00
|
|
|
|
2020-01-29 23:46:22 +00:00
|
|
|
public DrawHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
|
|
|
this.context = context;
|
2019-05-23 23:02:15 +00:00
|
|
|
this.info = info;
|
2012-08-07 08:24:06 +00:00
|
|
|
this.target = target;
|
|
|
|
this.partialTicks= partialTicks;
|
2020-01-29 23:46:22 +00:00
|
|
|
this.matrix = matrix;
|
|
|
|
this.buffers = buffers;
|
2012-08-07 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
2019-02-14 23:08:53 +00:00
|
|
|
public WorldRenderer getContext() { return context; }
|
2019-05-23 23:02:15 +00:00
|
|
|
public ActiveRenderInfo getInfo() { return info; }
|
2016-03-24 08:44:52 +00:00
|
|
|
public RayTraceResult getTarget() { return target; }
|
|
|
|
public float getPartialTicks() { return partialTicks; }
|
2020-01-29 23:46:22 +00:00
|
|
|
public MatrixStack getMatrix() { return matrix; }
|
|
|
|
public IRenderTypeBuffer getBuffers() { return buffers; }
|
2019-12-10 19:46:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A variant of the DrawBlockHighlightEvent only called when a block is highlighted.
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2019-12-19 04:39:41 +00:00
|
|
|
public static class HighlightBlock extends DrawHighlightEvent
|
2019-12-10 19:46:01 +00:00
|
|
|
{
|
2020-01-29 23:46:22 +00:00
|
|
|
public HighlightBlock(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
2019-12-10 19:46:01 +00:00
|
|
|
{
|
2020-01-29 23:46:22 +00:00
|
|
|
super(context, info, target, partialTicks, matrix, buffers);
|
2019-12-10 19:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockRayTraceResult getTarget()
|
|
|
|
{
|
|
|
|
return (BlockRayTraceResult) super.target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A variant of the DrawBlockHighlightEvent only called when an entity is highlighted.
|
|
|
|
* Canceling this event has no effect.
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2019-12-19 04:39:41 +00:00
|
|
|
public static class HighlightEntity extends DrawHighlightEvent
|
2019-12-10 19:46:01 +00:00
|
|
|
{
|
2020-01-29 23:46:22 +00:00
|
|
|
public HighlightEntity(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
2019-12-10 19:46:01 +00:00
|
|
|
{
|
2020-01-29 23:46:22 +00:00
|
|
|
super(context, info, target, partialTicks, matrix, buffers);
|
2019-12-10 19:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EntityRayTraceResult getTarget()
|
|
|
|
{
|
|
|
|
return (EntityRayTraceResult) super.target;
|
|
|
|
}
|
|
|
|
}
|
2012-08-07 08:24:06 +00:00
|
|
|
}
|