From c572b48bbedfd016e1909044121340a9ed7c424f Mon Sep 17 00:00:00 2001 From: grimmauld Date: Fri, 11 Sep 2020 10:58:17 +0200 Subject: [PATCH] MovedProjectileDispenserBehaviour#of now takes vanilla inaccuracy and velocity into account --- .../MovedProjectileDispenserBehaviour.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java index 3496e3036..4a33392d5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/MovedProjectileDispenserBehaviour.java @@ -53,17 +53,47 @@ public abstract class MovedProjectileDispenserBehaviour extends MovedDefaultDisp @Override protected IProjectile getProjectileEntity(World world, double x, double y, double z, ItemStack itemStack) { try { - return (IProjectile) MovedProjectileDispenserBehaviour.getGetProjectileEntityLookup().invoke(vanillaBehaviour, world, new SimplePos(x, y, z) , itemStack); + return (IProjectile) MovedProjectileDispenserBehaviour.getProjectileEntityLookup().invoke(vanillaBehaviour, world, new SimplePos(x, y, z) , itemStack); } catch (Throwable ignored) { } return null; } + + @Override + protected float getProjectileInaccuracy() { + try { + return (float) MovedProjectileDispenserBehaviour.getProjectileInaccuracyLookup().invoke(vanillaBehaviour); + } catch (Throwable ignored) { + } + return super.getProjectileInaccuracy(); + } + + @Override + protected float getProjectileVelocity() { + try { + return (float) MovedProjectileDispenserBehaviour.getProjectileVelocityLookup().invoke(vanillaBehaviour); + } catch (Throwable ignored) { + } + return super.getProjectileVelocity(); + } }; } - private static Method getGetProjectileEntityLookup() { + private static Method getProjectileEntityLookup() { Method getProjectileEntity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82499_a", World.class, IPosition.class, ItemStack.class); getProjectileEntity.setAccessible(true); return getProjectileEntity; } + + private static Method getProjectileInaccuracyLookup() { + Method getProjectileInaccuracy = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82498_a"); + getProjectileInaccuracy.setAccessible(true); + return getProjectileInaccuracy; + } + + private static Method getProjectileVelocityLookup() { + Method getProjectileVelocity = ObfuscationReflectionHelper.findMethod(ProjectileDispenseBehavior.class, "func_82500_b"); + getProjectileVelocity.setAccessible(true); + return getProjectileVelocity; + } }