Fix Extendo Grip knockback
This commit is contained in:
parent
85b3ab2025
commit
466739bcf5
3 changed files with 5 additions and 21 deletions
|
@ -47,8 +47,6 @@ public class SuperGlueHandler {
|
|||
|
||||
if (entity == null || world == null || pos == null)
|
||||
return;
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
if (world.isRemote())
|
||||
return;
|
||||
|
||||
|
@ -79,7 +77,7 @@ public class SuperGlueHandler {
|
|||
new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, placer));
|
||||
|
||||
Direction face = ray.getFace();
|
||||
if (ray == null || face == null || ray.getType() == Type.MISS)
|
||||
if (face == null || ray.getType() == Type.MISS)
|
||||
return;
|
||||
|
||||
if (!ray.getPos()
|
||||
|
|
|
@ -20,16 +20,15 @@ import net.minecraft.entity.projectile.ProjectileHelper;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.EntityRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult.Type;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.InputEvent.ClickInputEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingKnockBackEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -64,8 +63,6 @@ public class ExtendoGripItem extends Item {
|
|||
public static void holdingExtendoGripIncreasesRange(LivingUpdateEvent event) {
|
||||
if (!(event.getEntity() instanceof PlayerEntity))
|
||||
return;
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
|
||||
String marker = "createExtendo";
|
||||
|
@ -149,23 +146,14 @@ public class ExtendoGripItem extends Item {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void attacksByExtendoGripHaveMoreKnockback(AttackEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
public static void attacksByExtendoGripHaveMoreKnockback(LivingKnockBackEvent event) {
|
||||
Entity entity = event.getAttacker();
|
||||
if (!(entity instanceof PlayerEntity))
|
||||
return;
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
if (!isHoldingExtendoGrip(player))
|
||||
return;
|
||||
Entity target = event.getTarget();
|
||||
if (target instanceof ItemFrameEntity || !target.attackEntityFrom(DamageSource.causePlayerDamage(player), 0))
|
||||
return;
|
||||
int strength = 2;
|
||||
float yaw = entity.rotationYaw * ((float) Math.PI / 180F);
|
||||
if (target instanceof LivingEntity) {
|
||||
((LivingEntity) target).knockBack(entity, strength, MathHelper.sin(yaw), -MathHelper.cos(yaw));
|
||||
return;
|
||||
}
|
||||
target.addVelocity(-MathHelper.sin(yaw) * strength, 0.1D, MathHelper.cos(yaw) * strength);
|
||||
event.setStrength(event.getStrength() + 2);
|
||||
}
|
||||
|
||||
private static boolean isUncaughtClientInteraction(Entity entity, Entity target) {
|
||||
|
|
|
@ -141,8 +141,6 @@ public class ZapperRenderHandler {
|
|||
ItemStack heldItem = event.getItemStack();
|
||||
if (!(heldItem.getItem() instanceof ZapperItem))
|
||||
return;
|
||||
if (event.isCanceled())
|
||||
return;
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT;
|
||||
|
|
Loading…
Reference in a new issue