Inforno
Members-
Posts
10 -
Joined
-
Last visited
Everything posted by Inforno
-
Forge 1.12.2 server crashing on startup
Inforno replied to SkyPIays's topic in Support & Bug Reports
So you closed your server in the middle of it running, without properly /stop or /close or whatever you use to shut it down? That is your problem and from experience, I can tell you its a habit you should not fall into. Does not only apply to the server but your computer as well (don't use power button but properly shut it down), flash drives, and other data storing stuff. -
Finding the item of the user in onLivingHurtEvent
Inforno replied to Inforno's topic in Modder Support
Thank you! Tbh this is my first time using events, instanceof, or casting as somewhat new to java and forge Im posting my code incase anyone wants it in the future or you double check incase I did something wrong (but it works so eh): @SubscribeEvent public void onLivingHurtEvent(LivingHurtEvent event) { if (event.getSource().getImmediateSource() != null) { if (event.getSource().getImmediateSource() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource(); if (player.getHeldItemMainhand().getItem() == _Items.itemAquaDagger) { double targetYaw = event.getEntityLiving().getRotationYawHead(); double playerYaw = event.getSource().getTrueSource().getRotationYawHead(); if(Math.abs(targetYaw - playerYaw) < 80 || Math.abs(targetYaw - playerYaw) > 280) { event.setAmount(event.getAmount() * 5); event.getEntity().playSound(SoundEvents.BLOCK_ANVIL_HIT, 1.0F, 1.0F); } } } } } -
Finding the item of the user in onLivingHurtEvent
Inforno replied to Inforno's topic in Modder Support
I wished I was that blind and that worked. Unfortunately, since I am using LivingHurtEvent, EntityLivingBase, in this case, would be the victim. So basically this line: if (event.getEntityLiving().getHeldItemMainhand().getItem() == _Items.itemAquaDagger) { would mean the victim has to hold the dagger, not the player. Unless of course there is something other than LivingHurtEvent I can use.. -
Finding the item of the user in onLivingHurtEvent
Inforno replied to Inforno's topic in Modder Support
The method still exists yes, but I spent more time than needed trying to find a way to find and use it. I mean that the method was removed from .getImmediateSource to my knowledge (unless there is some obvious right in front of me way to still use it and wasted an entire hour cause I am blind) -
Finding the item of the user in onLivingHurtEvent
Inforno replied to Inforno's topic in Modder Support
Well, do you have any other ideas? I used to work on this on 1.10.2 until I had school stuff and came back to this a long while later. In 1.10.2, you could have used .getHeldItemMainhand().getItem() and work from there. However, I guess in 1.12.2 they changed it so you can't use that anymore. Btw, .getHeldEquipment() returns an Iterable<ItemStack> to my knowledge, the code I put up there was just as far as I gotten to. Edit: IceDice9, grabbing the information from the player would work since I can use .getHeldItemMainhand() from there, but I need to grab it from event to make sure I am getting the source of the damage, not just a random player (I don't even know how that would go on a multiplayer server) -
So I am creating an event where if a player is holding a certain item and is behind a player, they can perform a "backstab." I figured out everything except how to get the item from the source of damage to make sure they are holding the correct item... My Code: @SubscribeEvent public void onLivingHurtEvent(LivingHurtEvent event) { if (event.getSource().getImmediateSource() != null) { if (event.getSource().getImmediateSource().getHeldEquipment() == _Items.itemAquaDagger) { System.out.println("Player With Aqua Dagger Detected"); double targetYaw = event.getEntityLiving().getRotationYawHead(); double playerYaw = event.getSource().getTrueSource().getRotationYawHead(); if(Math.abs(targetYaw - playerYaw) < 80 || Math.abs(targetYaw - playerYaw) > 280) { event.setAmount(event.getAmount() * 5); event.getEntity().playSound(SoundEvents.BLOCK_ANVIL_HIT, 1.0F, 1F); } } } } I did find .getHeldEquipment() but I am very certain that is not what I want for this case. Btw the system.out.println was just a test to make sure it was the if statement that was the problem.
-
n00b question about Forge modded seed open to LAN
Inforno replied to YalithKBK's topic in General Discussion
If your looking to play over LAN with forge. You and your friend need the same forge version + mods. Just let him connnect like normal and you should be all good. Summary: Just do it like you normally do when hosting over LAN