Jump to content

Differentiation

Members
  • Posts

    606
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Differentiation

  1. Ahh, I see. I never knew that there could be a client mod and a server mod and common (both) mod. Now I know the differences. Thanks! And I have another question: What is client thread's role in LivingAttackEvent. Shouldn't it be a server event only?
  2. The first paragraph sounds like something no-one will like to do. Instead, I think it is best for OP to allow a server-side mod. Server-side is useful for SO many things, I don't understand why you would not like to have it, ESPECIALLY when you use LivingAttackEvent... one should 100% know that that has to have server-side running >.> This is just my opinion. And I have another question: What is client thread's role in LivingAttackEvent. Shouldn't it be a server event only?
  3. Hello! I was wondering, if I call a method in a server-side method where only the server thread runs, will the contents in the method be run by the server and not the client? For example: public void onCommand(EntityPlayer playerIn) { World worldIn = playerIn.worldObj; worldIn.playSound(null, playerIn.getPosition(), SoundEvents.BLOCK_CLOTH_BREAK, SoundCategory.PLAYERS, 1.0F, 1.0F); Random rand = worldIn.rand; worldIn.spawnParticle(EnumParticleTypes.CLOUD, playerIn.posX + (double)(rand.nextFloat() * playerIn.width * 2.5F) - (double)playerIn.width, playerIn.posY + 0.5D + (double)(rand.nextFloat() * playerIn.height) - 1.25D, playerIn.posZ + (double)(rand.nextFloat() * playerIn.width * 2.5F) - (double)playerIn.width, rand.nextGaussian() * 0.025D, rand.nextGaussian() * 0.025D, rand.nextGaussian() * 0.025D, 1 ); DinocraftPlayer player = DinocraftPlayer.getEntityPlayer(playerIn); if (player != null) { player.setMaxHealth(playerIn.getMaxHealth() + 1.0F); } } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { EntityPlayer playerIn = getCommandSenderAsPlayer(sender); this.onCommand(playerIn); // when I call this method, will the contents inside the method run on the server-thread, client-thread, or common (client and server-side)? } This is just a quick example. Any help will be welcome. Thanks!
  4. You need to make a custom player capability, and then set it to false onItemRightClick(); to check for the very first time a player right clicks with this weapon. I have a custom player capability class and this is how I would do it: @Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) { DinocraftPlayer player = DinocraftPlayer.getEntityPlayer(playerIn); DinocraftPlayerActions actions = player.getActions(); if (actions.isFirstTimeWeapon2 /* or whatever name */) { actions.setIsFirstTimeWeapon2(false); /* do things */ // will never fire again until player respawns } }
  5. That's not how you get the item being used. The event provides it for you if you are using a proper Minecraft version (aka 1.9 +) ItemStack stack = event.item; or something along these lines.
  6. It's not supposed to, just don't use static in this case...
  7. Don't use static, you don't have to have that modifier.
  8. Please PROPERLY set up the mod and proxies, etc. before doing anything else...
  9. ******* @SubscribeEvent public void onPlayerUseItem(PlayerUseItemEvent event) { ... } Properly SUBSCRIBE to the event, THEN do things when it is fired.
  10. My mod is client-side only??? Minecraft provides you with both sides. I don't understand what is the problem...
  11. What is in this method? Please show the contents. Thanks!
  12. I can't help, the only suggestion I will give is to update to a newer version such as 1.10.2.
  13. I don't mod on 1.12, so I can't help you any further. This should be pretty simple to figure out...
  14. EntityPlayer playerIn = (EntityPlayer) event.entity; World worldIn = playerIn.world; worldIn.playSound(playerIn, playerIn.getPosition(), /* here you have to put a SoundEvent instance, NOT a String */, SoundCategory.PLAYERS, 5.0F, 1.0F);
  15. Hi, no problem. EntityPlayer is the simplest to get, silly Answer: EntityPlayer playerIn = (EntityPlayer) event.entity;
  16. You're confused between sides. Please read about sides and then try to understand what each thread is responsible for. You don't need to have anything with the client-side in LivingAttackEvent...
  17. @SubscribeEvent public void onAttack(LivingAttackEvent event) { if (event.getEntity() instanceof EntityPlayer) { Entity attackerIn = event.getSource().getSourceOfDamage(); // this is your attacker instance, the entity attacking the target EntityPlayer targetIn = (EntityPlayer) event.getEntity(); // this is your target instance, the entity being attacked by the attacker /* * Here, you do whatever you want with your attacker and target. * You can make the target set on flame, add potion effects, etc. * Make sure you properly handle sides */ } } It's as simple as that, can't get any simpler, my friend, if you want lines to fire on the client, then send packets.
  18. I'm not quite understanding what you're trying to ask. LivingAttackEvent will fire when you're in a Singleplayer world by yourself and Multiplayer server.
  19. What do you mean? You would have to send packets to the EntityPlayerMP's client. Simple
  20. If you do: @Override public void onAttack(LivingAttackEvent event) { if (event.getEntity().worldObj.isRemote) { ... } } nothing will happen...
  21. It won't fire. This event is fired by the server-side.
  22. The LivingAttackEvent is fired by the server. If the mod is not present in the server, this event will not fire.
  23. OH! I see. If the server does not have the mod installed, nothing will work on the clients. The event in this case will NOT be fired.
  24. Well what do you mean "server - no mod?"
  25. "The LivingAttackEvent is a Forge event that fires whenever an EntityLivingBase attacks another EntityLivingBase"
×
×
  • Create New...

Important Information

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