Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Sokoly_

Members
  • Posts

    17
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Sokoly_'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Got it!!!!. Thank you very much for the help.
  2. So please could you give me an example of how to make it possible to hit from a distance. I have seen other mods on github and most have the same process and I can't find another
  3. So the " public static void mouseEvent(InputEvent.MouseInputEvent event)" is unnecessary?
  4. There is any error? @EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = {Dist.CLIENT}) public class AkuariumHelper { @SuppressWarnings("resource") @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public static void mouseEvent(InputEvent.MouseInputEvent event) { if (Minecraft.getInstance().level == null || Minecraft.getInstance().screen == null || Minecraft.getInstance().isPaused()) return; KeyMapping keyAttack = Minecraft.getInstance().options.keyAttack; if (event.getButton() == keyAttack.getKey().getValue() && event.getAction() == 1 && ForgeMod.REACH_DISTANCE.isPresent()) checkForReachAttack(); } @SuppressWarnings("unused") private static HitResult getEntityMouseOverExtended(float reach) { BlockHitResult blockRayTraceResult = null; HitResult result = null; Minecraft mc = Minecraft.getInstance(); Entity viewEntity = mc.crosshairPickEntity; if (viewEntity != null) { double d0 = reach; HitResult rayTrace = viewEntity.pick(d0, 0.0F, false); Vec3 eyePos = viewEntity.getEyePosition(0.0F); boolean flag = false; double d1 = d0; if (mc.gameMode.hasFarPickRange() && d1 < 6.0D) { d1 = 6.0D; d0 = d1; } else if (d0 > reach) { flag = true; } d1 *= d1; if (rayTrace != null) d1 = rayTrace.getLocation().distanceToSqr(eyePos); Vec3 lookVec = viewEntity.getEyePosition(1.0F); Vec3 attackVec = eyePos.add(lookVec.x * d0, lookVec.y * d0, lookVec.z * d0); AABB expBounds = viewEntity.getBoundingBox().expandTowards(lookVec.scale(d0)).inflate(1.0D, 1.0D, 1.0D); EntityHitResult entityRayTrace = ProjectileUtil.getEntityHitResult(viewEntity, eyePos, attackVec, expBounds, entity -> (!entity.isSpectator() && entity.canBeCollidedWith()), d1); if (entityRayTrace != null) { Vec3 hitVec = entityRayTrace.getLocation(); double d2 = eyePos.distanceToSqr(hitVec); if (flag && d2 > (reach * reach)) { blockRayTraceResult = BlockHitResult.miss(hitVec, Direction.getNearest(lookVec.x, lookVec.y, lookVec.z), new BlockPos(hitVec)); } else if (d2 < d1 || blockRayTraceResult == null) { EntityHitResult entityRayTraceResult = entityRayTrace; } } else { blockRayTraceResult = BlockHitResult.miss(attackVec, Direction.getNearest(lookVec.x, lookVec.y, lookVec.z), new BlockPos(attackVec)); } } return (HitResult)blockRayTraceResult; } private static void checkForReachAttack() { Minecraft mc = Minecraft.getInstance(); LocalPlayer clientPlayerEntity = mc.player; if (clientPlayerEntity == null || clientPlayerEntity.isSpectator()) return; double reach = (float)clientPlayerEntity.getAttributeValue(ForgeMod.REACH_DISTANCE.get()); if (reach == ForgeMod.REACH_DISTANCE.get().getDefaultValue()) return; HitResult rayTrace = getEntityMouseOverExtended((float)reach); if (!(rayTrace instanceof EntityHitResult)) return; EntityHitResult entityRayTrace = (EntityHitResult)rayTrace; Entity entityHit = entityRayTrace.getEntity(); if (entityHit != null && entityHit.invulnerableTime == 0 && entityHit != clientPlayerEntity && entityHit != clientPlayerEntity.getControllingPassenger()) { float velocity = 0.0F; if (clientPlayerEntity.getControllingPassenger() != null) { Entity riding = clientPlayerEntity.getControllingPassenger(); Vec3 vec = riding.getDeltaMovement(); velocity = (float)vec.length(); } PacketHandler.sendPacketToServer(new LongReachAttackPacket(entityHit.getId(), velocity)); } } }
  5. Good morning, I have been testing and I have managed to put the Forge REACH DISTANCE on the tool, but it still does not hit from a distance
  6. I've been testing and I already added the reach distance, but still you can't hit from a distance
  7. I've been testing it and nothing has changed
  8. Well I will try to test, if there is an error I will come back later
  9. In the old thread I saw this way of doing it, but I think there is something wrong, could you tell me the fault public final Lazy<Multimap<Attribute, AttributeModifier>> LAZY = Lazy.of(() -> { ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder(); builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", damage, AttributeModifier.Operation.ADDITION)); builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", speed, AttributeModifier.Operation.ADDITION)); if (ForgeMod.REACH_DISTANCE.isPresent()) { builder.put(ForgeMod.REACH_DISTANCE.get(), new AttributeModifier(ATTACK_REACH_MODIFIER, "Weapon modifier", reach, AttributeModifier.Operation.ADDITION)); } builder.put(Attributes.ATTACK_KNOCKBACK, new AttributeModifier(ATTACK_KNOCKBACK_MODIFIER, "Weapon modifier", kb, AttributeModifier.Operation.ADDITION)); Multimap<Attribute, AttributeModifier> attributeModifiers = ArrayListMultimap.create(); attributeModifiers = builder.build(); return attributeModifiers; });
  10. @SubscribeEvent public static void onEntityAttributeModificationEvent(final EntityAttributeModificationEvent event) { event.add(EntityType.PLAYER, ForgeMod.REACH_DISTANCE.get()); }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.