Jump to content

[Solved] Custom BlockFenceGate won't make open/close sounds


Recommended Posts

Posted

If the gate is closed and the player is holding a valid key, the gate opens.

If the gate is open and the player is not holding a valid key, the gate closes.

 

I use the playAuxSFXAtEntity method to play the appropriate sound on gate open and close.

But, I'm not getting any sound from the gate.

Other gates sound okay.

 

Here is the relevant code. Have I missed something?

 

public class MyGate extends BlockFenceGate {
...
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
	if(!par1World.isRemote) {
		if (par5Entity instanceof EntityLivingBase) {
        	EntityLivingBase entityLiving = (EntityLivingBase) par5Entity;
        	if (entityLiving instanceof EntityPlayer) {
        		EntityPlayer entityPlayer = (EntityPlayer) entityLiving;        		
...
        		int i1 = par1World.getBlockMetadata(par2, par3, par4);
        		boolean MyGateOpen = isFenceGateOpen(i1);
        		
			if (!MyGateOpen && holdingValidKey) {
				MyGateOpen = true;
				par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 | 4, 2); // open the gate
				par1World.playAuxSFXAtEntity(entityPlayer, 1003, par2, par3, par4, 0);
			} 
			else if (MyGateOpen && !holdingValidKey) {
				MyGateOpen = false;
				par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 & -5, 2); // close the gate
				par1World.playAuxSFXAtEntity(entityPlayer, 1003, par2, par3, par4, 0);
			}

Posted

Try with (EntityPlayer)null instead of the entity instance. It seems the given entity don't receive the packet.

 

That did the trick! Thank you, GotoLink.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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