Jump to content

Differentiation

Members
  • Posts

    606
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Differentiation

  1. I don't understand what you are trying to say
  2. Do you mean you want your mod only to run on Singleplayer and not on Multiplayer Servers?
  3. Please clarify.
  4. Steps for checking if an event is being fired: 1. Place this line of code in your event method: Log.info("check"); 2. Meet all the requirements in-game for the event to fire (i.e. be attacked by any other entity). 3. If [INFO] check doesn't show up on the console, you did NOT register your event. Or just simply use the debugger
  5. It's firing perfectly for me, whenever the player is attacked by another entity.
  6. Well then, you never called EventHandler::registerEvents(); in your Main class like I told you. Do any of your events even work? Try different ones and see if they work.
  7. The solution is simply not to extend ParticleCloud and remove the overrided method.
  8. But I do hope you're aware that LivingAttackEvent is fired whenever the EntityLivingBase is attacked by another EntityLivingBase. If you are trying to test this event out by taking fall damage, don't expect anything to work.
  9. My only conclusion is that LivingAttackEvent might not work on 1.9.4. Please update to 1.10.2 and above, since I use 1.10.2 and it works mighty fine for me.
  10. Well then explain why it doesn't work.
  11. Let me guide you. 1. Create a new class called EventHandler. 2. Create a method called registerEvents() in the class and register your event inside. Like so: public class EventHandler { public void registerEvents() { /* All your events will be registered here */ ... MinecraftForge.EVENT_BUS.register(new YourClassNameWhereTheEventIsFound()); ... } } 3. Call this method in your mod's initialization phase. MAIN CLASS: ...... EventHandler eventHandler = new EventHandler(); @EventHandler public void registerEvents(FMLInitializationEvent event) { ... eventHandler.init(); ... } ...... You may use these steps to guide you. I hope I helped.
  12. Well, did you actually register the constructor where you register the event?
  13. Below, I provided a direct example of how to get the attacker, target, etc. and how to use LivingAttackEvent. @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 */ targetIn.worldObj.playSound((EntityPlayer) null, targetIn.getPosition(), SoundEvents.BLOCK_METAL_BREAK, SoundCategory.BLOCKS, 2.0F, 1.25F); // I play a sound in my attack event Random rand = worldIn.rand; // random instance for (int i = 0; i < 75; ++i) { /* my helper stuff, don't worry about it */ DinocraftServer.spawnParticle(EnumParticleTypes.BLOCK_CRACK, worldIn, targetIn.posX + (rand.nextDouble() - 0.5D) * (double)targetIn.width, targetIn.posY + rand.nextDouble() - (double)targetIn.getYOffset() + 0.25D, targetIn.posZ + (rand.nextDouble() - 0.5D) * (double)targetIn.width, Math.random() * 0.2D - 0.1D, Math.random() * 0.25D, Math.random() * 0.2D - 0.1D, Block.getIdFromBlock(Blocks.REDSTONE_BLOCK) ); // I spawn blood particles in my attack event } } } I don't even think LivingAttackEvent works on 1.9, last I heard, correct me if I'm wrong. I would recommend updating to at least 1.10.2, which is the version I used above.
  14. As a summary, you are reaching across logical sides Packets, like aforementioned, will do the work. You must send a packet to tell the client that it needs to play a sound (using EntityPlayerMP). For more information about packets, click HERE. However, there is a server-side friendly method to play a sound (which I use all the time instead of sending a packet), which I have put for you below for your convenience. World worldIn = playerIn.world; worldIn.playSound(null, playerIn.getPosition(), /* your sound name */, /* your sound category */, 5.0F, 1.0F); I hope I helped. Happy modding!
  15. Comments for feedback: 1. Since you are handling block replacements, you need to use ServerChatEvent instead of ClientChatEvent. 2. You can just make a new command and register it. execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException method is executed in server-side. 3. Don't use Minecraft.getMinecraft() in server-side once you get the server to run the code, this might crash you or cause errors if on a server. 4. Don't use WorldClient, simply use playerIn.world once you have EntityPlayerMP through CommandBase in execute(...) method. Follow these tips and you'll be set! ... @Override public String getCommandName() { return "evanesco"; } @Override public void execute(MinecraftServer serverIn, ICommandSender senderIn, String[] args) throws CommandException { EntityPlayer playerIn = CommandBase.getCommandSenderAsPlayer(senderIn); RayTraceResult trace = PointingAt(); if (trace == null || trace.typeOfHit == RayTraceResult.Type.MISS) { SendStatus("§6Whiff!§r"); } else { BlockPos pos = trace.getBlockPos(); World worldIn = playerIn.world; worldIn.setBlockToAir(pos); worldIn.playSound(/* if you want sound to play for all players */ null /* else if only for this player, playerIn */, pos, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F); SendStatus("§5Shoop!§r"); CommandBase.notifyCommandListener("commands.evanesco.success", new Object[0]); } } ... I stripped the code for you, if you wish to use it, you may. I hope I helped. Happy modding!
  16. Ambiguous.
  17. Can I have some of those flowers too?
  18. Please post your code.
  19. Yes, Entity entity = ray.entityHit; is the starting line that is wrong in his code that would lead to further errors. You're correct, that's the cause of the exception.
  20. This will throw a NullPointerException since there is (most of the time) no hit entity! You are running the item right click method...
  21. Minecraft Version 1.7.10 is no longer supported on this Forum.
  22. You mean this? Minecraft mc = Minecraft.getMinecraft(); EntityPlayer playerIn = mc.thePlayer; World worldIn = playerIn.world;
  23. I used that long ago when I just started modding. But I recall it did give some crashes. I omitted the code loooong ago
×
×
  • Create New...

Important Information

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