My current project is a mod that adds flintlock guns. I've got the first gun working perfectly, except that the bullets aren't making sparks and a metallic impact noise when hitting blocks of a certain hardness. The problem is that they are supposed to do this, and the code that makes them do this doesn't seem to be executing correctly for some reason. have I missed something obvious?
I can't see any obvious problems, so all I can suggest is stepping through your code (specifically the onImpact method) in a debugger and seeing what goes wrong.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Sounds good. Ill try that and report back. I recently figured out how to use the debugger. Question though: does debugging minecraft work any differently than a console app?
Sounds good. Ill try that and report back. I recently figured out how to use the debugger. Question though: does debugging minecraft work any differently than a console app?
It's mostly the same, but you need to keep in mind that there are usually two main threads running (client and server) and keeping one thread paused for too long will usually disconnect it from the other.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Fair enough. I tried the debugger, and I've confirmed that the lines of code that spawn particles and make noise are being called. They just arent taking effect for some reason.
World#spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int...) does nothing on the server, it only spawns particles when called on the client. You need to use one of the spawnParticle overloads from WorldServer instead.
World#playSound(double, double, double, SoundEvent, SoundCategory, float, float, boolean) does nothing on the server, it only plays a sound when called on the client. You need to use one of the other overloads instead.
Forge's documentation explains the sound-playing methods in more detail here.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How do I use WorldServer? The methods are non static. Is there some object I should be calling this from? "this" doesn't work.
If World#isRemote is false, the World will be an instance of WorldServer. Cast the World to WorldServer and call the appropriate spawnParticle method.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You're using a different wrong overload, which happens to be client-only.
Look at the spawnParticle overloads in the WorldServer class and use one of them. Don't use the overloads from the World class.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The World#playSound overloads with an EntityPlayer argument do the following:
On the logical server, they send a packet to every player except the one passed as an argument telling their clients to play the sound
On the logical client, they play the sound only if the player passed as an argument is the client player
If you pass a player argument, you need to call the method on both sides. If you pass null as the player argument, you only need to call it on the logical server.
You can't assume that the thrower will always be a player and you're only calling the method on the logical server, so just pass null as the player argument.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Are you sure it's not working, or are you just not hearing the sounds?
SoundEvents.BLOCK_ANVIL_FALL uses the step/stone1-6 sound files, which are very quiet and short. Vanilla plays this sound event when a living entity falls on an anvil.
SoundEvents.BLOCK_ANVIL_LAND uses the random/anvil_land sound file, which is a much more distinctive "clang" sound. Vanilla plays this sound event when a falling anvil lands. Is this the sound you meant to use?
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
My current project is a mod that adds flintlock guns. I've got the first gun working perfectly, except that the bullets aren't making sparks and a metallic impact noise when hitting blocks of a certain hardness. The problem is that they are supposed to do this, and the code that makes them do this doesn't seem to be executing correctly for some reason. have I missed something obvious?
Code:
http://pastebin.com/HHY2XrYi
My first mod =D
Still no leads, some assistance would be appreciated.
My first mod =D
I can't see any obvious problems, so all I can suggest is stepping through your code (specifically the onImpact method) in a debugger and seeing what goes wrong.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Sounds good. Ill try that and report back. I recently figured out how to use the debugger. Question though: does debugging minecraft work any differently than a console app?
My first mod =D
It's mostly the same, but you need to keep in mind that there are usually two main threads running (client and server) and keeping one thread paused for too long will usually disconnect it from the other.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Fair enough. I tried the debugger, and I've confirmed that the lines of code that spawn particles and make noise are being called. They just arent taking effect for some reason.
My first mod =D
Ah, I can see the issue now.
World#spawnParticle(EnumParticleTypes, double, double, double, double, double, double, int...) does nothing on the server, it only spawns particles when called on the client. You need to use one of the spawnParticle overloads from WorldServer instead.
World#playSound(double, double, double, SoundEvent, SoundCategory, float, float, boolean) does nothing on the server, it only plays a sound when called on the client. You need to use one of the other overloads instead.
Forge's documentation explains the sound-playing methods in more detail here.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How do I use WorldServer? The methods are non static. Is there some object I should be calling this from? "this" doesn't work.
My first mod =D
If World#isRemote is false, the World will be an instance of WorldServer. Cast the World to WorldServer and call the appropriate spawnParticle method.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I made the changes, it still doesn't work.
Code as of now:
http://pastebin.com/kdUAB839
My first mod =D
You're using a different wrong overload, which happens to be client-only.
Look at the spawnParticle overloads in the WorldServer class and use one of them. Don't use the overloads from the World class.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Now the particles are working, but the sounds are not.
Code: http://pastebin.com/j4Z8gfA4
My first mod =D
The World#playSound overloads with an EntityPlayer argument do the following:
If you pass a player argument, you need to call the method on both sides. If you pass null as the player argument, you only need to call it on the logical server.
You can't assume that the thrower will always be a player and you're only calling the method on the logical server, so just pass null as the player argument.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I tried passing in null, it didnt work. Code:
http://pastebin.com/ip0bcHsE
My first mod =D
Are you sure it's not working, or are you just not hearing the sounds?
SoundEvents.BLOCK_ANVIL_FALL uses the step/stone1-6 sound files, which are very quiet and short. Vanilla plays this sound event when a living entity falls on an anvil.
SoundEvents.BLOCK_ANVIL_LAND uses the random/anvil_land sound file, which is a much more distinctive "clang" sound. Vanilla plays this sound event when a falling anvil lands. Is this the sound you meant to use?
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
oh! I get it now. anvil land is the one i want!
My first mod =D
I've got it working, thanks so much for the help.
My first mod =D