Jump to content

Filloax

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Filloax

  1. You can use this in modpacks. In fact, it was made for one, Discovery Download on curse http://mods.curse.com/mc-mods/minecraft/243929-improved-commands#t1:other-downloads This mod adds 4 new commands: /playsound2 sound <mode> <player> <x> <y> <z> <vol> <pitch> <delay> As you can see, this has 2 more arguments: mode can be normal (default), loop or stop. normal plays the sound like normal, but overrides the sound already playing from that position (played with this command, it cannot override sounds played other ways). loop is like normal, but the sound loops until it is stopped. stop stops the sound, regardless of what sound is in the sound argument. delay is the time between each loop, if mode is set to loop. /playsoundb sound <mode> <player> <vol> <pitch> <delay> This command plays background music (so, regardless of position) to the specified player, which is by default @p. The mode argument is the same as in /playsound2, except the sounds are overridden / stopped based on the sound itself (so, to stop records.cat you have to do records.cat). Again, you can only stop sounds played with this command. /summon2 This command is exactly the same as /summon, except in the JSON you can use string item IDs for items (in equipment, etc) like in 1.8+, so you won't have the items the mob is spawned with changing between each save because modded numerical IDs change with saves. /setblock2 Same thing as above, but for setblock.
  2. Solved, apparently I needed to specify wich arg wasa the username in the isUsernameIndex function. Second time I post an issue which I solve myself today, lol
  3. Hello, I'm trying to make an improved playsound command. I got the packet etc working, only problem is that @a works only when there is one player in LAn or in singleplayer (couldn't test with proper server, but I imagine it's the same). When I try to use the command with @a when tehre are 2 players in LAN, it says "That player cannot be foundr" The only thing different form /playsound with player seems that playsound uses entityplayermp.playerNetServerHandler.sendPacket while I use network.sendTo Code: In command class: public void processCommand(ICommandSender player, String[] input) { if (input.length < 1) { throw new WrongUsageException(this.getCommandUsage(player), new Object[0]); } else { String sound = input[0]; String mode = "normal"; int x = player.getPlayerCoordinates().posX; int y = player.getPlayerCoordinates().posY; int z = player.getPlayerCoordinates().posZ; float vol = 1; float pitch = 1; EntityPlayerMP playerarg = getPlayer(player, "@a"); World world = player.getEntityWorld(); if (input.length > 1) { mode = input[1]; } if (input.length > 2) { playerarg = getPlayer(player, input[2]); } if (input.length > 5) { x = MathHelper.floor_double(func_110666_a(player, (double)x, input[3])); y = MathHelper.floor_double(func_110666_a(player, (double)y, input[4])); z = MathHelper.floor_double(func_110666_a(player, (double)z, input[5])); } if (input.length > 6) { vol = Float.parseFloat(input[6]); } if (input.length > 7) { pitch = Float.parseFloat(input[7]); } Main.network.sendTo(new SoundPacket(sound, mode, x, y, z, vol, pitch), playerarg); System.out.println("Played \'"+sound+"\' to \'"+playerarg.getDisplayName()+"\' at "+x+" "+y+" "+z); } In packet handler: @Override public IMessage onMessage(SoundPacket m, MessageContext ctx) { System.out.println(m.sound+";"+m.mode+";"+m.x+";"+m.y+";"+m.z+";"+m.vol+";"+m.pitch); ChunkCoordinates chunkcoordinates = new ChunkCoordinates(m.x, m.y, m.z); ISound isound = mapSoundPositions.get(chunkcoordinates); System.out.println("isound get"); if (isound != null) { System.out.println("Sound already playing at " + m.x + "/" + m.y + "/" + m.z + "; stopping sound"); Minecraft.getMinecraft().getSoundHandler().stopSound(isound); mapSoundPositions.remove(chunkcoordinates); } if (m.mode.equals("normal")) { System.out.println("Playing sound at " + m.x + "/" + m.y + "/" + m.z + ": " + m.sound); ResourceLocation resource = new ResourceLocation(m.sound); PositionedSoundRecord psr = new PositionedSoundRecord(resource, m.vol, m.pitch, m.x, m.y, m.z); mapSoundPositions.put(chunkcoordinates, psr); Minecraft.getMinecraft().getSoundHandler().playSound(psr); } return null; }
  4. Realized how to, I have to run that code after sending a packet to the client.
  5. To be more clear, I'm trying to make a playsound alternative that is also able to stop the sound from a coordinate (if it has been started by the same command) and loop it. I managed to make the start/stop thing for now, but it only on cient side. Any help on how to make it work for other players? Code of the play sound part: In the command: Main.proxy.playSoundFromCoords(sound, x, y, z, vol, pitch); In the client proxy: private final Map<ChunkCoordinates, ISound> mapSoundPositions = new HashMap<ChunkCoordinates, ISound>(); @Override public void playSoundFromCoords(String sound, int x, int y, int z, float vol, float pitch) { ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z); ISound isound = mapSoundPositions.get(chunkcoordinates); if (isound != null) { System.out.println("Sound already playing at " + x + "/" + y + "/" + z + "; stopping sound"); Minecraft.getMinecraft().getSoundHandler().stopSound(isound); mapSoundPositions.remove(chunkcoordinates); } if (sound != null) { System.out.println("Playing sound at " + x + "/" + y + "/" + z + ": " + sound); ResourceLocation resource = new ResourceLocation(sound); PositionedSoundRecord psr = new PositionedSoundRecord(resource, vol, pitch, x, y, z); mapSoundPositions.put(chunkcoordinates, psr); Minecraft.getMinecraft().getSoundHandler().playSound(psr); } } Edit: forgot to say that the code mostly comes from this thread:http://www.minecraftforge.net/forum/index.php?topic=24230.0
  6. And if that isn't possible, is there a way (through another mod or something) to automatically copy the customnpcs folder in each new save that is created?
  7. Is there a way to make placed mob spawners become another spawner other than pig's one? Also, how do you overwrite vanilla blocks (for example like railcraft did with vanilla rails)?
×
×
  • Create New...

Important Information

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