Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi, I was wondering how would one make it so entities that are players would play no sound when walking and sprinting and sneaking perhaps, whenever player footsteps would be played normally. Basically I want to make it so when I am on a server, all other players' footsteps generate no sound, and if it means I have to include my own I don't mind in fact I'd prefer that. I also would like this mod to be client side only since I am not the owner of the servers I go on. The reason why I am making this mod is because whenever I am on a popular server with thousands of people, it gets noisy in the lobbies when everyone is moving around. However, I don't want to just turn off player sounds since there are other sounds that I do want to keep. Also I play using 1.15.2 version of Minecraft with forge. So how would I go about doing this? For the following code below that I have tried, assume pig noises instead of silence. If I am being totally honest here, I'd rather you just write the code that does what I am asking instead of trying to fix the code below / using it as a starting point.

 

import net.minecraftforge.registries.ForgeRegistries;

import net.minecraft.world.IWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.Entity;

import java.util.Map;

@SliencerModElements.ModElement.Tag
public class SilenceProcedure extends SilencerModElements.ModElement {
	public SilenceProcedure(SilencerModElements instance) {
		super(instance, 1);
	}

	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			System.err.println("Failed to load dependency entity for procedure Silence!");
			return;
		}
		if (dependencies.get("world") == null) {
			System.err.println("Failed to load dependency world for procedure Silence!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		IWorld world = (IWorld) dependencies.get("world");
		if (((entity instanceof ServerPlayerEntity) && (entity.isSprinting()))) {
			if (!world.getWorld().isRemote) {
				world.playSound(null, new BlockPos((int) (entity.getPosX()), (int) (entity.getPosY()), (int) (entity.getPosZ())),
						(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.pig.hurt")),
						SoundCategory.NEUTRAL, (float) 1, (float) 1, true);
			} else {
				world.getWorld().playSound((entity.getPosX()), (entity.getPosY()), (entity.getPosZ()),
						(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.pig.hurt")),
						SoundCategory.NEUTRAL, (float) 1, (float) 1, false, true);
			}
		}
	}
}

 

Edited by PythonHunter

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.