Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class ArrowHitboxes {
@SubscribeEvent
public void worldUpdate(RenderWorldLastEvent e) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
for(Object o : Minecraft.getMinecraft().theWorld.loadedEntityList) {
if(o instanceof EntityArrow) {
EntityArrow obj = (EntityArrow) o;
//reflection for access inGround of arrow
Field inGround = EntityArrow.class.
getDeclaredField("inGround");
inGround.setAccessible(true);
boolean arrow = (Boolean) inGround.get(obj);
//man all of forge insideofair, isCollided, onground, isAirborne, motion != 0 ... don't work?
//wtf?!?! why have useless fields? Honestly it's sort of dumb
if (!arrow)
{
float red = 1F;
float green = 1F;
float blue = 1F;
double xPos = obj.posX - Minecraft.getMinecraft().getRenderManager().viewerPosX;
double yPos = obj.posY - Minecraft.getMinecraft().getRenderManager().viewerPosY;
double zPos = obj.posZ - Minecraft.getMinecraft().getRenderManager().viewerPosZ;
render(red, green, blue, xPos, yPos, zPos, obj.width/20*7, obj.height/20*7);
}
}
}
}
//draw the hitbox
public void render(float red, float green, float blue, double x, double y, double z, float width, float height) {
HitboxRenderTools.drawArrowHitbox(x, y, z, width, height, red, green, blue, 0.75F);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.