mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Add hand-specific render event
This commit is contained in:
4 files changed
+109
-5
No files matched your search
@@ -79,6 +79,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
@@ -97,6 +98,7 @@ import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEventSpecific;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.ScreenshotEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
@@ -168,6 +170,11 @@ public class ForgeHooksClient
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, partialTicks, renderPass));
|
||||
}
|
||||
|
||||
public static boolean renderFirstPersonHandSpecific(EnumHand hand, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHandEventSpecific(hand, partialTicks, interpPitch, swingProgress, equipProgress, stack));
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPre(TextureMap map)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map));
|
||||
|
||||
@@ -23,6 +23,12 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
|
||||
/**
|
||||
* 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 RenderHandEventSpecific} from firing.
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderHandEvent extends Event
|
||||
{
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public class RenderHandEventSpecific extends Event
|
||||
{
|
||||
private final EnumHand hand;
|
||||
private final float partialTicks;
|
||||
private final float interpolatedPitch;
|
||||
private final float swingProgress;
|
||||
private final float equipProgress;
|
||||
private final ItemStack stack;
|
||||
|
||||
public RenderHandEventSpecific(EnumHand hand, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
{
|
||||
this.hand = hand;
|
||||
this.partialTicks = partialTicks;
|
||||
this.interpolatedPitch = interpolatedPitch;
|
||||
this.swingProgress = swingProgress;
|
||||
this.equipProgress = equipProgress;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public EnumHand getHand()
|
||||
{
|
||||
return hand;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
@Nullable
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user