Jump to content

[Request] Minor change to onPlaySound hook in ISoundHandler


Azanor
 Share

Recommended Posts

Currently the onPlaySound hook from ISoundHandler is triggered from within the playSound method in SoundManager. playSoundEffect in World first calls playSound in RenderGlobal and in that method a distance check is made to the current renderViewEntity before passing it on to SoundManager.

 

This means that the Forge hook is never called if the current render entity is out of a certain range of the block.

Would it be possible to move the call to the hook before the range check is done, either within World or within RenderGlobal ? This way you could still check if a sound was supposed to be played even if it is never actually played due to distance considerations, making it possible to create blocks that can "listen" for certain sounds.

 

NOTE: The onPlaySoundAtEntity hook in ISoundHandler works correctly as it is triggered within World

47MdL.png

Link to comment
Share on other sites

Not to be a fanboy or anything, but... I love your mod. CreeperFace.png

Sorry for the lack of useful input. I just wanted to let you know. :D

 

Well, I guess this post won't be completely useless. The link in your signature is broken. Try this instead. :)

[url=http://www.minecraftforum.net/topic/838839-100-thaumcraft/][img=http://i.imgur.com/47MdL.png][/url]

 

 

47MdL.png

 

Check out my

Texture Packs Thread here on the Forge Forum. :)

Currently in the process of adding some mod support for JohnSmith Texture Pack.

width=105 height=12https://www.sugarsync.com/piv/D8135159_67366891_21351[/img]

 

width=209 height=19https://www.sugarsync.com/piv/D8135159_67366891_772852[/img]

Link to comment
Share on other sites

not against it personally, but in order for this to work, would they not have to re-write half the vanilla sound handling code? :S

(i am not a java expert, and honestly have not spend a lot of time looking over the MC base-code)

Being noobish since 96, being dumb since birth!

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

As an example for when I ran into this issue:

 

I created a block that "listens" via the hook for specific notes being played by a vanilla noteblock. Everthing works perfectly as long as the player remains within the view distance of the noteblock. Any further and the sounds doesn't play and the hook is never triggered.

 

However the sound call is still made so in my mind the hook should still trigger, even though the actual sound doesn't play.

 

 

Anyway, there are a few other issues with this as well, since I suspect this won't work in SMP anyway.

47MdL.png

Link to comment
Share on other sites

As an example for when I ran into this issue:

 

I created a block that "listens" via the hook for specific notes being played by a vanilla noteblock. Everthing works perfectly as long as the player remains within the view distance of the noteblock. Any further and the sounds doesn't play and the hook is never triggered.

 

However the sound call is still made so in my mind the hook should still trigger, even though the actual sound doesn't play.

 

 

Anyway, there are a few other issues with this as well, since I suspect this won't work in SMP anyway.

 

If a tree falls in the wood, and no one is around, does it still make a noise?

 

Instead of hooking to the sound, can you hook to the activation of the noteblock itself, and check to make sure that it is set to the particular 'sound' you are looking for? Perhaps restrict it to check for it being within x block radius, so it would be able to legitimately 'hear' the noise itself.

 

Not very familiar with Java code yet, but in logic statements:

 

If (noteblock triggers) THEN
   IF (noteblock is within range) THEN
        IF (Noteblock is set to the particular setting you are looking for) THEN
            Trigger
        ENDIF
   ENDIF
ENDIF

 

Just throwing out an idea for you

Link to comment
Share on other sites

cant wait for new mods, since i bought the game 2 days ago :) now i can play mc without being afraid to get problems with mojang or the law :-P oh and servers are not a problem anymore, damn shitty cracked servers lol, just a waste of time

Minecraft.net Username: Sailren

Link to comment
Share on other sites

cant wait for new mods, since i bought the game 2 days ago :) now i can play mc without being afraid to get problems with mojang or the law :-P oh and servers are not a problem anymore, damn shitty cracked servers lol, just a waste of time

 

Yeah. I can honestly say that with what I've gotten out of it, and still get plenty out of, that Minecraft is probably the best $26 or so I ever spent on a videogame. :P

Check out my

Texture Packs Thread here on the Forge Forum. :)

Currently in the process of adding some mod support for JohnSmith Texture Pack.

width=105 height=12https://www.sugarsync.com/piv/D8135159_67366891_21351[/img]

 

width=209 height=19https://www.sugarsync.com/piv/D8135159_67366891_772852[/img]

Link to comment
Share on other sites

and we can show our creativity in this game, just look after the enterprise in youtube :D one of them, others build the red dragon in zelda wind waker :) at the moment im trying to play direwolfs season 4 lets play on my own, i will update to 1.3.1, when he starts his season 5 and i have finished my season 4 :D

Minecraft.net Username: Sailren

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The version you are using is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Currently supported versions are 1.19.3 (Latest), 1.19.2, and 1.18.2 (LTS).
    • Technically, you can reuse the crafting recipe classes as long as you change the RecipeType since that's what determines whether the recipes can be used by a given system or not.
    • I mean...it's neither. You are trying to play a 1.19.2 mod on 1.19.3. It won't work. 1.19.2 does not equal 1.19.3.
    • Hi all, lately I've started developing mods that are server-side only, so I've already started working with packets, I thought it was a pretty simple thing (having already worked on it when developing plugins) (I know it's completely different at code level, but logical I think it's the same) but I ran into multiple problems, I'm developing a mod in 1.19.2 server side which for now has to send a simple message to individual clients by executing a command, like a sort of "hello world" debugging. I developed the command part and it works, but I really have no idea how to send a chatmessagepacket to the client, could someone help me? Test.java -- Command Class (Working) public class Test { public Test (CommandDispatcher<CommandSourceStack> dispatcher){ dispatcher.register(Commands.literal("test").executes((command) -> { return 0; })); } private int prova(CommandSourceStack source) throws CommandSyntaxException{ ServerPlayer player = source.getPlayer(); BlockPos pos = player.blockPosition(); //here must send a packet to the client return 1; } } PacketHandler.java public class PacketHandler { private static SimpleChannel INSTANCE; private static int packetId = 0; public static void register(){ SimpleChannel net = NetworkRegistry.ChannelBuilder .named(new ResourceLocation(Mceconomy.MODID, "main")) .networkProtocolVersion(() -> "1.0") .clientAcceptedVersions(s -> true) .serverAcceptedVersions(s -> true) .simpleChannel(); INSTANCE = net; net.messageBuilder(MessagePacket.class, id(), NetworkDirection.PLAY_TO_SERVER) .encoder(MessagePacket::toBytes) .decoder(MessagePacket::new) .consumerMainThread(MessagePacket::handle) .add(); } private static int id() { return packetId++; } public static <MSG> void sendToServer(MSG message) { INSTANCE.sendToServer(message); } public static <MSG> void sendToClient(MSG message, ServerPlayer player) { INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), message); } } MessagePacket.java -- (StringTextComponent can't find it and I don't know why) public class MessagePacket { public MessagePacket() { } public MessagePacket(FriendlyByteBuf buf) { } public void toBytes(FriendlyByteBuf buf) { } public boolean handle(Supplier<NetworkEvent.Context> supplier) { NetworkEvent.Context context = supplier.get(); context.enqueueWork(() -> { //On the server ServerPlayer player = context.getSender(); ServerLevel world = player.getLevel(); player.sendSystemMessage(new StringTextComponent("Hello World!")); }); return true; } } Any ideas?
    • Alright, so for a second I thought I had a solution when I remembered the old position Entities use for lerping is public public final Vec3 getPosition(float p_20319_) { double d0 = Mth.lerp((double)p_20319_, this.xo, this.getX()); double d1 = Mth.lerp((double)p_20319_, this.yo, this.getY()); double d2 = Mth.lerp((double)p_20319_, this.zo, this.getZ()); return new Vec3(d0, d1, d2); } and while I was able to get the position on server, I found out the old position is identical to the current position (both on client and server), which means if I subtract it from the current position, I still get 0.0, what's up with that? I how can the game lerp motion if the two positions are the same?
  • Topics

×
×
  • Create New...

Important Information

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