Clean up a bunch of render events (#6444)

* Delete RenderHandEvent as RenderSpecificHandEvent can do everything it does and more. Rename RenderSpecificHandEvent to RenderHandEvent as it's now the only hand rendering event.
* Pass MatrixStack and IRenderTypeBuffer into the event whenever they are available. If they're available, that means we're in a batching environment and the modder should not be using the tessellator or other buffers on their own, or they risk "Already building" crashes.
This commit is contained in:
Vincent Lee 2020-01-29 17:46:22 -06:00 committed by GitHub
parent 4839d18c73
commit 0ad574257e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 156 additions and 168 deletions

View file

@ -35,14 +35,14 @@
if (flag) {
float f5 = hand == Hand.MAIN_HAND ? f : 0.0F;
float f2 = 1.0F - MathHelper.func_219799_g(p_228396_1_, this.field_187470_g, this.field_187469_f);
+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(Hand.MAIN_HAND, p_228396_2_, p_228396_1_, f1, f3, f5, this.field_187467_d))
+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(Hand.MAIN_HAND, p_228396_2_, p_228396_3_, p_228396_5_, p_228396_1_, f1, f3, f5, this.field_187467_d))
this.func_228405_a_(p_228396_4_, p_228396_1_, f1, Hand.MAIN_HAND, f5, this.field_187467_d, f2, p_228396_2_, p_228396_3_, p_228396_5_);
}
if (flag1) {
float f6 = hand == Hand.OFF_HAND ? f : 0.0F;
float f7 = 1.0F - MathHelper.func_219799_g(p_228396_1_, this.field_187472_i, this.field_187471_h);
+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(Hand.OFF_HAND, p_228396_2_, p_228396_1_, f1, f4, f6, this.field_187468_e))
+ if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(Hand.OFF_HAND, p_228396_2_, p_228396_3_, p_228396_5_, p_228396_1_, f1, f4, f6, this.field_187468_e))
this.func_228405_a_(p_228396_4_, p_228396_1_, f1, Hand.OFF_HAND, f6, this.field_187468_e, f7, p_228396_2_, p_228396_3_, p_228396_5_);
}

View file

@ -18,15 +18,7 @@
}
}
@@ -358,6 +360,7 @@
}
boolean flag = this.field_78531_r.func_175606_aa() instanceof LivingEntity && ((LivingEntity)this.field_78531_r.func_175606_aa()).func_70608_bn();
+ if (!net.minecraftforge.client.ForgeHooksClient.renderFirstPersonHand(field_78531_r.field_71438_f, p_228381_1_, p_228381_3_))
if (this.field_78531_r.field_71474_y.field_74320_O == 0 && !flag && !this.field_78531_r.field_71474_y.field_74319_N && this.field_78531_r.field_71442_b.func_178889_l() != GameType.SPECTATOR) {
this.field_78513_d.func_205109_c();
this.field_78516_c.func_228396_a_(p_228381_3_, p_228381_1_, this.field_228374_i_.func_228487_b_(), this.field_78531_r.field_71439_g, this.field_78531_r.func_175598_ae().func_229085_a_(this.field_78531_r.field_71439_g, p_228381_3_));
@@ -475,7 +478,7 @@
@@ -475,7 +477,7 @@
}
} else if (this.field_78531_r.field_71462_r != null) {
try {
@ -35,7 +27,7 @@
} catch (Throwable throwable) {
CrashReport crashreport1 = CrashReport.func_85055_a(throwable, "Rendering screen");
CrashReportCategory crashreportcategory1 = crashreport1.func_85058_a("Screen render details");
@@ -588,9 +591,16 @@
@@ -588,9 +590,16 @@
Matrix4f matrix4f = matrixstack.func_227866_c_().func_227870_a_();
this.func_228379_a_(matrix4f);
activerenderinfo.func_216772_a(this.field_78531_r.field_71441_e, (Entity)(this.field_78531_r.func_175606_aa() == null ? this.field_78531_r.field_71439_g : this.field_78531_r.func_175606_aa()), this.field_78531_r.field_71474_y.field_74320_O > 0, this.field_78531_r.field_71474_y.field_74320_O == 2, p_228378_1_);
@ -52,7 +44,7 @@
this.field_78531_r.func_213239_aq().func_219895_b("hand");
if (this.field_175074_C) {
RenderSystem.clear(256, Minecraft.field_142025_a);
@@ -670,4 +680,9 @@
@@ -670,4 +679,9 @@
public OverlayTexture func_228385_m_() {
return this.field_228375_t_;
}

View file

@ -68,7 +68,7 @@
BlockPos blockpos = ((BlockRayTraceResult)raytraceresult).func_216350_a();
BlockState blockstate = this.field_72769_h.func_180495_p(blockpos);
- if (!blockstate.func_196958_f() && this.field_72769_h.func_175723_af().func_177746_a(blockpos)) {
+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_228426_6_, field_72777_q.field_71476_x, 0, p_228426_2_))
+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_228426_6_, field_72777_q.field_71476_x, p_228426_2_, p_228426_1_, irendertypebuffer$impl))
+ if (!blockstate.isAir(this.field_72769_h, blockpos) && this.field_72769_h.func_175723_af().func_177746_a(blockpos)) {
IVertexBuilder ivertexbuilder2 = irendertypebuffer$impl.getBuffer(RenderType.func_228659_m_());
this.func_228429_a_(p_228426_1_, ivertexbuilder2, p_228426_6_.func_216773_g(), d0, d1, d2, blockpos, blockstate);

View file

@ -19,7 +19,7 @@
+ int i = mapdata != null ? p_225623_1_.func_82333_j() % 4 * 2 : p_225623_1_.func_82333_j();
p_225623_4_.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_((float)i * 360.0F / 8.0F));
- if (flag) {
+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderItemInFrameEvent(p_225623_1_, this))) {
+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderItemInFrameEvent(p_225623_1_, this, p_225623_4_, p_225623_5_, p_225623_6_))) {
+ if (mapdata != null) {
p_225623_4_.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_(180.0F));
float f = 0.0078125F;

View file

@ -4,7 +4,7 @@
}
public void func_225623_a_(T p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) {
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre<T, M>(p_225623_1_, this, p_225623_3_, p_225623_4_))) return;
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre<T, M>(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_))) return;
p_225623_4_.func_227860_a_();
this.field_77045_g.field_217112_c = this.func_77040_d(p_225623_1_, p_225623_3_);
- this.field_77045_g.field_217113_d = p_225623_1_.func_184218_aH();
@ -33,7 +33,7 @@
p_225623_4_.func_227865_b_();
super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post<T, M>(p_225623_1_, this, p_225623_3_, p_225623_4_));
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post<T, M>(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_));
}
@Nullable

View file

@ -4,9 +4,9 @@
public void func_225623_a_(AbstractClientPlayerEntity p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) {
this.func_177137_d(p_225623_1_);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(p_225623_1_, this, p_225623_3_, p_225623_4_))) return;
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_))) return;
super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_225623_1_, this, p_225623_3_, p_225623_4_));
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_225623_1_, this, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_));
}
public Vec3d func_225627_b_(AbstractClientPlayerEntity p_225627_1_, float p_225627_2_) {

View file

@ -52,6 +52,7 @@ import javax.annotation.Nonnull;
import net.minecraft.client.renderer.*;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.model.pipeline.LightUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -126,8 +127,6 @@ import net.minecraftforge.client.event.InputUpdateEvent;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.RecipesUpdatedEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderSpecificHandEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.ScreenshotEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
@ -160,17 +159,17 @@ public class ForgeHooksClient
return result != null ? result : _default;
}
public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
{
switch (target.getType()) {
case BLOCK:
if (!(target instanceof BlockRayTraceResult)) return false;
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightBlock(context, info, target, subID, partialTicks));
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightBlock(context, info, target, partialTicks, matrix, buffers));
case ENTITY:
if (!(target instanceof EntityRayTraceResult)) return false;
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightEntity(context, info, target, subID, partialTicks));
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightEntity(context, info, target, partialTicks, matrix, buffers));
}
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent(context, info, target, subID, partialTicks));
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent(context, info, target, partialTicks, matrix, buffers));
}
public static void dispatchRenderLast(WorldRenderer context, MatrixStack mat, float partialTicks)
@ -178,14 +177,9 @@ public class ForgeHooksClient
MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, mat, partialTicks));
}
public static boolean renderFirstPersonHand(WorldRenderer context, MatrixStack mat, float partialTicks)
public static boolean renderSpecificFirstPersonHand(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
{
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, mat, partialTicks));
}
public static boolean renderSpecificFirstPersonHand(Hand hand, MatrixStack mat, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
{
return MinecraftForge.EVENT_BUS.post(new RenderSpecificHandEvent(hand, mat, partialTicks, interpPitch, swingProgress, equipProgress, stack));
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(hand, mat, buffers, light, partialTicks, interpPitch, swingProgress, equipProgress, stack));
}
public static void onTextureStitchedPre(AtlasTexture map, Set<ResourceLocation> resourceLocations)

View file

@ -19,6 +19,8 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraftforge.eventbus.api.Cancelable;
@ -37,23 +39,26 @@ public class DrawHighlightEvent extends Event
private final WorldRenderer context;
private final ActiveRenderInfo info;
private final RayTraceResult target;
private final int subID;
private final float partialTicks;
private final MatrixStack matrix;
private final IRenderTypeBuffer buffers;
public DrawHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
public DrawHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
{
this.context = context;
this.info = info;
this.target = target;
this.subID = subID;
this.partialTicks= partialTicks;
this.matrix = matrix;
this.buffers = buffers;
}
public WorldRenderer getContext() { return context; }
public ActiveRenderInfo getInfo() { return info; }
public RayTraceResult getTarget() { return target; }
public int getSubID() { return subID; }
public float getPartialTicks() { return partialTicks; }
public MatrixStack getMatrix() { return matrix; }
public IRenderTypeBuffer getBuffers() { return buffers; }
/**
* A variant of the DrawBlockHighlightEvent only called when a block is highlighted.
@ -61,9 +66,9 @@ public class DrawHighlightEvent extends Event
@Cancelable
public static class HighlightBlock extends DrawHighlightEvent
{
public HighlightBlock(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
public HighlightBlock(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
{
super(context, info, target, subID, partialTicks);
super(context, info, target, partialTicks, matrix, buffers);
}
@Override
@ -80,9 +85,9 @@ public class DrawHighlightEvent extends Event
@Cancelable
public static class HighlightEntity extends DrawHighlightEvent
{
public HighlightEntity(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
public HighlightEntity(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
{
super(context, info, target, subID, partialTicks);
super(context, info, target, partialTicks, matrix, buffers);
}
@Override

View file

@ -19,33 +19,53 @@
package net.minecraftforge.client.event;
import javax.annotation.Nonnull;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
/**
* This event is fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
* before both hands are rendered.
* Canceling this event prevents either hand from being rendered,
* and prevents {@link RenderSpecificHandEvent} from firing.
* TODO This may get merged in 11 with RenderSpecificHandEvent to make a generic hand rendering
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
* whenever a hand is rendered in first person.
* Canceling the event causes the hand to not render.
*/
@net.minecraftforge.eventbus.api.Cancelable
public class RenderHandEvent extends net.minecraftforge.eventbus.api.Event
@Cancelable
public class RenderHandEvent extends Event
{
private final WorldRenderer context;
private final Hand hand;
private final MatrixStack mat;
private final IRenderTypeBuffer buffers;
private final int light;
private final float partialTicks;
public RenderHandEvent(WorldRenderer context, MatrixStack mat, float partialTicks)
private final float interpolatedPitch;
private final float swingProgress;
private final float equipProgress;
@Nonnull
private final ItemStack stack;
public RenderHandEvent(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light,
float partialTicks, float interpolatedPitch,
float swingProgress, float equipProgress, @Nonnull ItemStack stack)
{
this.context = context;
this.hand = hand;
this.mat = mat;
this.buffers = buffers;
this.light = light;
this.partialTicks = partialTicks;
this.interpolatedPitch = interpolatedPitch;
this.swingProgress = swingProgress;
this.equipProgress = equipProgress;
this.stack = stack;
}
public WorldRenderer getContext()
public Hand getHand()
{
return context;
return hand;
}
public MatrixStack getMatrixStack()
@ -53,8 +73,49 @@ public class RenderHandEvent extends net.minecraftforge.eventbus.api.Event
return mat;
}
public IRenderTypeBuffer getBuffers() {
return buffers;
}
public int getLight() {
return light;
}
public float getPartialTicks()
{
return partialTicks;
}
/**
* @return The interpolated pitch of the player entity
*/
public float getInterpolatedPitch()
{
return interpolatedPitch;
}
/**
* @return The swing progress of the hand being rendered
*/
public float getSwingProgress()
{
return swingProgress;
}
/**
* @return The progress of the equip animation. 1.0 is fully equipped.
*/
public float getEquipProgress()
{
return equipProgress;
}
/**
* @return The ItemStack to be rendered
*/
@Nonnull
public ItemStack getItemStack()
{
return stack;
}
}

View file

@ -19,6 +19,8 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.item.ItemStack;
@ -38,12 +40,19 @@ public class RenderItemInFrameEvent extends net.minecraftforge.eventbus.api.Even
private final ItemStack item;
private final ItemFrameEntity entityItemFrame;
private final ItemFrameRenderer renderer;
private final MatrixStack matrix;
private final IRenderTypeBuffer buffers;
private final int light;
public RenderItemInFrameEvent(ItemFrameEntity itemFrame, ItemFrameRenderer renderItemFrame)
public RenderItemInFrameEvent(ItemFrameEntity itemFrame, ItemFrameRenderer renderItemFrame, MatrixStack matrix,
IRenderTypeBuffer buffers, int light)
{
item = itemFrame.getDisplayedItem();
entityItemFrame = itemFrame;
renderer = renderItemFrame;
this.matrix = matrix;
this.buffers = buffers;
this.light = light;
}
@Nonnull
@ -61,4 +70,16 @@ public class RenderItemInFrameEvent extends net.minecraftforge.eventbus.api.Even
{
return renderer;
}
public MatrixStack getMatrix() {
return matrix;
}
public IRenderTypeBuffer getBuffers() {
return buffers;
}
public int getLight() {
return light;
}
}

View file

@ -20,6 +20,7 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.client.renderer.entity.LivingRenderer;
@ -33,29 +34,39 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
private final LivingRenderer<T, M> renderer;
private final float partialRenderTick;
private final MatrixStack matrixStack;
private final IRenderTypeBuffer buffers;
private final int light;
public RenderLivingEvent(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack)
public RenderLivingEvent(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack,
IRenderTypeBuffer buffers, int light)
{
this.entity = entity;
this.renderer = renderer;
this.partialRenderTick = partialRenderTick;
this.matrixStack = matrixStack;
this.buffers = buffers;
this.light = light;
}
public LivingEntity getEntity() { return entity; }
public LivingRenderer<T, M> getRenderer() { return renderer; }
public float getPartialRenderTick() { return partialRenderTick; }
public MatrixStack getMatrixStack() { return matrixStack; }
public IRenderTypeBuffer getBuffers() { return buffers; }
public int getLight() { return light; }
@Cancelable
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
{
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack){ super(entity, renderer, partialRenderTick, matrixStack); }
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack, IRenderTypeBuffer buffers, int light) {
super(entity, renderer, partialRenderTick, matrixStack, buffers, light);
}
}
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
{
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack){ super(entity, renderer, partialRenderTick, matrixStack); }
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack, IRenderTypeBuffer buffers, int light) {
super(entity, renderer, partialRenderTick, matrixStack, buffers, light);
}
}
}

View file

@ -20,6 +20,7 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraft.client.renderer.entity.PlayerRenderer;
import net.minecraft.entity.player.PlayerEntity;
@ -33,28 +34,38 @@ public abstract class RenderPlayerEvent extends PlayerEvent
private final PlayerRenderer renderer;
private final float partialRenderTick;
private final MatrixStack stack;
private final IRenderTypeBuffer buffers;
private final int light;
public RenderPlayerEvent(PlayerEntity player, PlayerRenderer renderer, float partialRenderTick, MatrixStack stack)
public RenderPlayerEvent(PlayerEntity player, PlayerRenderer renderer, float partialRenderTick, MatrixStack stack, IRenderTypeBuffer buffers, int light)
{
super(player);
this.renderer = renderer;
this.partialRenderTick = partialRenderTick;
this.stack = stack;
this.buffers = buffers;
this.light = light;
}
public PlayerRenderer getRenderer() { return renderer; }
public float getPartialRenderTick() { return partialRenderTick; }
public MatrixStack getMatrixStack() { return stack; }
public IRenderTypeBuffer getBuffers() { return buffers; }
public int getLight() { return light; }
@net.minecraftforge.eventbus.api.Cancelable
public static class Pre extends RenderPlayerEvent
{
public Pre(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack){ super(player, renderer, tick, stack); }
public Pre(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack, IRenderTypeBuffer buffers, int light) {
super(player, renderer, tick, stack, buffers, light);
}
}
public static class Post extends RenderPlayerEvent
{
public Post(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack){ super(player, renderer, tick, stack); }
public Post(PlayerEntity player, PlayerRenderer renderer, float tick, MatrixStack stack, IRenderTypeBuffer buffers, int light) {
super(player, renderer, tick, stack, buffers, light);
}
}
}

View file

@ -1,107 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* 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
*/
package net.minecraftforge.client.event;
import javax.annotation.Nonnull;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
/**
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
* whenever a hand is rendered in first person.
* Canceling the event causes the hand to not render.
* TODO This may get merged in 11 with RenderHandEvent to make a generic hand rendering
*/
@Cancelable
public class RenderSpecificHandEvent extends Event
{
private final Hand hand;
private final MatrixStack mat;
private final float partialTicks;
private final float interpolatedPitch;
private final float swingProgress;
private final float equipProgress;
@Nonnull
private final ItemStack stack;
public RenderSpecificHandEvent(Hand hand, MatrixStack mat, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, @Nonnull ItemStack stack)
{
this.hand = hand;
this.mat = mat;
this.partialTicks = partialTicks;
this.interpolatedPitch = interpolatedPitch;
this.swingProgress = swingProgress;
this.equipProgress = equipProgress;
this.stack = stack;
}
public Hand getHand()
{
return hand;
}
public MatrixStack getMatrixStack()
{
return mat;
}
public float getPartialTicks()
{
return partialTicks;
}
/**
* @return The interpolated pitch of the player entity
*/
public float getInterpolatedPitch()
{
return interpolatedPitch;
}
/**
* @return The swing progress of the hand being rendered
*/
public float getSwingProgress()
{
return swingProgress;
}
/**
* @return The progress of the equip animation. 1.0 is fully equipped.
*/
public float getEquipProgress()
{
return equipProgress;
}
/**
* @return The ItemStack to be rendered, or null.
*/
@Nonnull
public ItemStack getItemStack()
{
return stack;
}
}