Jump to content

theishiopian

Members
  • Posts

    150
  • Joined

  • Last visited

Everything posted by theishiopian

  1. Im making an enchantement that reflects arrows. My code works, but its causing a rather strange bug. When an arrow is deflected, it appears to fall to the ground, then teleport to where it should have impacted. My code: private static void reflect(Entity projectile, EntityPlayer player) { Vec3d vector = new Vec3d(-projectile.motionX,-projectile.motionY,-projectile.motionZ); vector = vector.normalize(); projectile.motionX = vector.x; projectile.motionY = vector.y; projectile.motionZ = vector.z; System.out.println("checkpoint 3"); } what could be causing this rather strange effect?
  2. Oh, right, that makes sense. Only one player per client after all. Thank you!
  3. @Choonster OK, I've got most of it set up, but I have one more question: How does the server know which player sent the packet? Do I have to specify somehow, or will the server somehow be able to tell? Currently, I have an event handler listening for PlayerInteract.LeftClickEmpty, which then sends an empty packet to the server like so: Core.INSTANCE.sendToServer(new DeflectPacket()); (I defined the networkwrapper instance in the core mod class temporarily, I'll move it to somewhere else later) EDIT: I tested it, and it works! But I'd still appreciate an explanation as to WHY it works.
  4. Oh, so I can just send an empty packet from the player?
  5. @Choonster would using the entityID work for players? I need the server to know when a player is left clicking, but the left click event is clientside only, hence the need for packets.
  6. I need to trigger code on the server when a particular event fires on the client. I have two questions: are uuid's the same on both the client and server, ie can I use the uuid of an entity on the client to find that same entity on the server, and if so, whats the best way to send a uuid in a packet? I tried looking into forges built in packet system, but it doesn't have a way to send uuids, only primitives and bytes, and I'd like to avoid converting a uuid into bytes if possible.
  7. @Cadiboo I just tested and AttackEntityEvent event by firing arrows at myself from a dispenser and swinging a sword at them. It appears that arrows dont fire the event. Code: @SubscribeEvent public static void event(AttackEntityEvent event) { if(event.getEntity() instanceof IProjectile) { System.out.println("x"); } } EDIT: Holy shit I'm dumb, I forgot to register the event. EDIT2: After registering the event, it still doesn't work.
  8. Lol, this codebase scares me sometimes with how janky it is. I seem to recall arrows not responding to being hit with a sword, but I'll test again and report back.
  9. Thats... oddly specific
  10. Will attackEntityEvents work with projectiles? Also, leftclickempty only works on the client.
  11. How do I detect (on the server) if a player is swinging a sword? I want to make an enchantment that lets you deflect arrows like ghast fireballs, but I can't find an event that fires when the player left clicks. I looked into sending a packet from the client to the server when there's a left click on the client side, but I couldn't figure out how to send the server an event object for the left click event. If theres an easier way to do this, I'd love to hear it.
  12. Ok, so I found the problem. Turns out the 1.11 lowercase everything standard also applies to lang files. Thus, en_US should have been en_us. works fine now, thanks for pointing me towards the mcmeta file.
  13. I'm trying to name an item (currently known as item.pbj.name) "PBJ sandwich", but my lang file (en_US.lang, to be specific) seems to not be taking effect. I know the names match, but is there something I need to do to make the mod see the lang file?
  14. Multiple problems with this: 1. your crash log is WAYYYYYYYYYYYYY to big to just paste into a post. Use pastebin in the future please. 2. you've ignored a very important clue (in red): In this case, the mod causing the issue is immersive engineering: Please report this issue here: https://github.com/BluSunrize/ImmersiveEngineering/issues When you do, put the crash log in a pastebin link, and provide instructions on how to reproduce the issue.
  15. Click the three dots button at the top right, then click downloads, then click keep file on the entry at the top for your file.
  16. Interesting, I had a hunch that might be the case. Once Im done playing around with it, I'll try that.
  17. Ok, multiplayer testing complete, the new modified code works perfectly! Thank you so much everyone! One last question: how do i detect if the arrow was shot by a dispenser? I want mobs like the stray to still be able to deal damage, but arrows from players and dispensers to not deal any. I know how to get whether or not it was shot by a player, but not sure if dispensers are handled differently.
  18. Ok, I've managed to add my reflection code to your modified event handlers, they work perfectly in singleplayer. Now I need to test this in multiplayer.
  19. Interesting, I didn't know that. I must say, people on the forum tend to just say "figure it out yourself", but you lot have been extremely helpful. Thank you!
  20. So, after some preliminary experimentation, I've discovered a small bug in your code, namely the event handlers being static means they don't register properly. Changing them to non static methods seems to fix it.
  21. I haven't been able to do any testing due to being really sick, so this is super appreciated! It looks like your code just nullifies all projectile damage, but it should be easy enough to merge my reflection code with your code to narrow it down to just potion arrows. Thanks for the suggestion, Ill be sure to list you as a contributor in the mcinfo file if this works!
  22. ok, looks like its F8 for eclipse. Ill test this tomorrow, thank you for your help.
  23. ok, ill do that. just to refresh my memory, how to i jump to the next breakpoint?
  24. So maybe set the damage to 0.1 then?
  25. Ok, so the reflection changes don't solve the original problem. Tipped arrows from players still only hit other players 50% of the time, and tipped arrows from dispensers still cant hit players at all. Code now looks like this: public class DamageNullifier { static Field potion; static { potion = ReflectionHelper.findField(EntityTippedArrow.class, "potion", "field_184560_g"); } @SubscribeEvent public void Nullifier(ProjectileImpactEvent.Arrow event) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { EntityArrow arrow = event.getArrow(); World world = arrow.getEntityWorld(); if(!world.isRemote && arrow instanceof EntityTippedArrow) { PotionType plocal = (PotionType) potion.get(arrow); if(!(plocal.getRegistryName().toString().equals("minecraft:empty"))) { arrow.setDamage(0.0); if(event.getRayTraceResult().typeOfHit == RayTraceResult.Type.ENTITY) event.getRayTraceResult().entityHit.hurtResistantTime = 0; } } } }
×
×
  • Create New...

Important Information

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