Jump to content

Recommended Posts

Posted

So I followed a tutorial about adding sounds in forge 1.6.2 but it doesn't seem to be working for me. The sound should play while it is selected in the hotbar. I tested this with the "random.bow" sound and it worked, however, with my custom sound it doesn't. Here is the code I have:

 

Troncraft.java:

package taji34.troncraft;

import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.Item;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="Troncraft", name="Troncraft", version="0.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false, channels={"troncraft"}, packetHandler = TajiPacketHandler.class)

public class Troncraft {
        // The instance of your mod that Forge uses.
        @Instance("Troncraft")
        public static Troncraft instance;
        public final static Item identityDisk = new IdentityDisk(5001);
        int diskItemID = identityDisk.itemID;
    	private final static Item baton = new Baton(5002);
    	int batonItemID = baton.itemID;
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="taji34.troncraft.client.ClientProxy", serverSide="taji34.troncraft.CommonProxy")
        public static CommonProxy proxy;
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
        @EventHandler
        public void load(FMLInitializationEvent event) {
            LanguageRegistry.addName(identityDisk, "Identity Disk");
            LanguageRegistry.addName(baton, "Baton");
            EntityRegistry.registerModEntity(EntityIdentityDisk.class, "IdentityDisk", 5001, this, 40, 3, true);
            RenderingRegistry.registerEntityRenderingHandler(EntityIdentityDisk.class, new RenderSnowball(identityDisk));
        	KeyBindingRegistry.registerKeyBinding(new TajiKeyHandler());
        	MinecraftForge.EVENT_BUS.register(new TajiEvents());
        }
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

 

TajiEvents.java:

package taji34.troncraft;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingHurtEvent;

public class TajiEvents {
public boolean isPlayerDamage(DamageSource source)
{
	if ((source.getSourceOfDamage() != null) && !(source.isExplosion()) && !(source.isFireDamage()) && !(source.isMagicDamage()) && !(source.isProjectile()))
	{
		return true;
	}
	return false;
}
@ForgeSubscribe
public void entityAttacked(LivingHurtEvent event)
{
	EntityLiving attackedEnt = (EntityLiving) event.entityLiving;
	DamageSource attackSource = event.source;
	if (isPlayerDamage(attackSource))
	{
		EntityPlayer player = (EntityPlayer) attackSource.getSourceOfDamage();
		if(player.getHeldItem() != null)
		{
			ItemStack itemstack = player.getHeldItem();
			if (itemstack.getDisplayName().equals("Baton"))
			{
				NBTTagCompound tag = itemstack.getTagCompound();
				int damageAmmount = tag.getInteger("Damage");
				event.ammount = damageAmmount;
			}
		}
	}
}
public void onSound(SoundLoadEvent event) {
	event.manager.addSound("troncraft:freezer-hum.ogg");
}
}

 

IdentityDisk.Java:

package taji34.troncraft;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class IdentityDisk extends Item {
        public IdentityDisk(int id) {
                super(id);
                setMaxStackSize(1);
                setCreativeTab(CreativeTabs.tabMisc);
                setUnlocalizedName("identityDisk");
        }
        @Override
        @SideOnly(Side.CLIENT)
        public void registerIcons(IconRegister iconRegister) {
            this.itemIcon = iconRegister.registerIcon("troncraft:IdentityDisk");
        }
        public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
        	if (par5){
        		par2World.playSoundAtEntity(par3Entity, "troncraft:freezer-hum", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
        	}
        }
        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
        {
            if (!par3EntityPlayer.capabilities.isCreativeMode)
            {
                --par1ItemStack.stackSize;
            }

            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

            if (!par2World.isRemote)
            {
                par2World.spawnEntityInWorld(new EntityIdentityDisk(par2World, par3EntityPlayer));
            }

            return par1ItemStack;
        }
}

Posted

Make sure you put @ForgeSubscribe on your SoundLoadEvent.

And that your sound is in mcp/src/minecraft/assets/troncraft/sound/..

the sound is in the correct area, and when I put @ForgeSubscribe before the SoundLoadEvent, all sound goes away...

Posted

Well you definately need the @ForgeSubscribe annotation. It's normal to surround the addSound() method with a try-catch statement. Do this and print in the catch part something like "Problem when trying to load TronCraft sounds".

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Posted

Well you definately need the @ForgeSubscribe annotation. It's normal to surround the addSound() method with a try-catch statement. Do this and print in the catch part something like "Problem when trying to load TronCraft sounds".

 

Sorry for the delay, was a bit busy the past couple of days. So now my onSound block reads:

public void onSound(SoundLoadEvent event) {
	try {
		event.manager.addSound("troncraft:freezer-hum.ogg");
	}
	catch(Exception e){ 
		System.out.println("Something went wrong loading Troncraft Sounds!");
	}
}

 

However, the same error is occurring without the catch printing anything to the console. I noticed something though, sound works fine up until I load a world, in which case this Exception prints to the console:

2013-08-01 15:35:20 [iNFO] [sTDERR] Exception in thread "Thread-13" java.lang.NullPointerException
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.codecs.CodecJOrbis.readHeader(CodecJOrbis.java:448)
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.codecs.CodecJOrbis.initialize(CodecJOrbis.java:301)
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.libraries.LibraryLWJGLOpenAL.loadSound(LibraryLWJGLOpenAL.java:392)
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.libraries.LibraryLWJGLOpenAL.newSource(LibraryLWJGLOpenAL.java:640)
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.SoundSystem.CommandNewSource(SoundSystem.java:1800)
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2415)
2013-08-01 15:35:20 [iNFO] [sTDERR] 	at paulscode.sound.CommandThread.run(CommandThread.java:121)

 

Then sound stops working everywhere, even after exiting the world. Upon exiting the game this prints to the console:

2013-08-01 15:38:04 [iNFO] [sTDOUT] SoundSystem shutting down...
2013-08-01 15:38:09 [iNFO] [sTDOUT] Error in class 'SoundSystem'
2013-08-01 15:38:09 [iNFO] [sTDOUT]     Command thread did not die!
2013-08-01 15:38:09 [iNFO] [sTDOUT] Ignoring errors... continuing clean-up.
2013-08-01 15:38:09 [iNFO] [sTDOUT]     Author: Paul Lamb, www.paulscode.com

 

Any ideas?

Posted

The sound may be too long.

 

 

And also, if the Item is in your hotbar, and it is supposed to PLAY the sound when it is in your hotbar, does it not make sense that the thread may have trouble "dying"?

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted

The sound may be too long.

 

 

And also, if the Item is in your hotbar, and it is supposed to PLAY the sound when it is in your hotbar, does it not make sense that the thread may have trouble "dying"?

OK, do you know how long is too long? I want to create something like the industrialcraft machines the have a recurring sound. And It's only plays while it's in your hand, not just the hotbar, but yes that does make sense. Let me see what happens when I close the game with it not in my hand.

 

Edit: Alright, so the Sound error is only thrown when my custom sound tries to play. If I log on with the item not selected and log off without selecting it, sound plays fine with no errors or trouble closing the thread. However, if at any point I select the item, the error gets thrown and sound completely cuts out. The error seems to be what is causing the thread to have trouble closing. I am going to see if shortening the sound helps...

Posted

I'm very interested in the solution to this problem, I havent encountered it myself but sounds code fascinates me.

I hope you can report back when you find out something :)

 

How long is the sound file? I did manage to play rather large files without a problem although I didn't thread it :)

 

If you guys dont get it.. then well ya.. try harder...

Posted

I'm very interested in the solution to this problem, I havent encountered it myself but sounds code fascinates me.

I hope you can report back when you find out something :)

 

How long is the sound file? I did manage to play rather large files without a problem although I didn't thread it :)

 

It is currently 1:00 which is way longer than I need it to be now that i think about it. I'm going to shorten it to 0:10 to see if that works. If not, then I am going to shorten it to one second as a last resort to see if length is causing the problem.

Posted

That lenght is not the problem, you can confirm this easly by creating a custom block which plays the sound on activation/r-click!

 

I do have several sounds longer than 2 minutes and they work! :)

If you guys dont get it.. then well ya.. try harder...

Posted

That lenght is not the problem, you can confirm this easly by creating a custom block which plays the sound on activation/r-click!

 

I do have several sounds longer than 2 minutes and they work! :)

Ok, So If length isn't the problem, it has to be something with my code right? Could you please make sure I have everything and have it in the right place?

Posted

Doesn't seem to be the code. Could be something in your file codec. How did you make it ?

I downloaded the original file of off the internet as a mp3. I manipulated it in Adobe Soundbooth CS4 saving it as an mp3 again (as soundbooth doesn't natively save to ogg) and then used an online converter to convert it to ogg.

Posted

I also have this issue and I'm curious on what fixes it. Any luck yet? I personally converted my sound using Audacity which, to my knowledge, is quite universal. Also, I used stone.ogg by Mojang as a replacement for my sound and it still doesn't work (it's in assets/modID/sound). So I can hardly imagine that the codec of the sound file is the issue.

 

Does it perhaps have anything to do with the fact that it asks for a pack.mcmeta for my mod?

 

I'm really stuck on this so I hope this gets solved.

 

Here is my code btw, just so you guys can check.

 

 

My mod file

package mods.atmosmobs;

import java.util.logging.Logger;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid = "atmosmobs", name = "atmosmobs", version = "0.1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class AtmosMobs {

@PreInit
public void preInit(FMLPreInitializationEvent event) {

	MinecraftForge.EVENT_BUS.register(new AtmosMobs());
	MinecraftForge.EVENT_BUS.register(new AtmosMobsSounds());

	AMlogger = Logger.getLogger("atmosmobs");
	AMlogger.setParent(FMLLog.getLogger());

	tabAtmosMobs = new TabAtmosMobs(CreativeTabs.getNextID(), "AtmosMobs");
	AddItems();
	AtmosMobsConfiguration.init(event.getSuggestedConfigurationFile());
	AchievementPage.registerAchievementPage(new AtmosMobsAchievementPage());
	new EntitySpawning();

	AtmosMobs.AMlogger
			.info("Atmosmobs: preInit complete: sounds loaded and config loaded");
	AtmosMobs.AMlogger.info(" ");
}

public AtmosMobs() {

}

public String getVersion() {
	return "v0.1 (MC 1.6.2)";
}

@Mod.Init
public void load(FMLInitializationEvent event) {
	AddNames();
	AddRecipes();
	AddEggs();
	proxy.registerRenderInformation();
	AtmosMobs.AMlogger.info(" ");
	AtmosMobs.AMlogger.info("Atmosmobs: init complete");
	AtmosMobs.AMlogger.info(" ");
}

@PostInit
public void loadAPIs(FMLPostInitializationEvent event) {
	AtmosMobs.AMlogger.info(" ");
	AtmosMobs.AMlogger.info("Atmosmobs: Starting API load");
	AtmosMobs.AMlogger.info(" ");
	new ImplementAPIs();
	AtmosMobs.AMlogger.info(" ");
	AtmosMobs.AMlogger.info("Atmosmobs: postInit and API load complete");
	AtmosMobs.AMlogger.info(" ");
}

private void AddEggs() {
	EntityList.IDtoClassMapping.put(800,
			mods.atmosmobs.EntityButterfly.class);
	EntityList.entityEggs.put(Integer.valueOf(800), new EntityEggInfo(800,
			0x606051, 0xBD8B72));
	EntityList.IDtoClassMapping.put(801, mods.atmosmobs.EntityFox.class);
	EntityList.entityEggs.put(Integer.valueOf(801), new EntityEggInfo(801,
			0x606051, 0xBD8B72));
	AtmosMobs.AMlogger.info(" ");
	AtmosMobs.AMlogger.info("Atmosmobs: spawn Eggs registered");
	AtmosMobs.AMlogger.info(" ");
}

private void AddItems() {
	// SpiderEgg = new ItemSpiderEgg(SpiderEggID)
	// .setUnlocalizedName("Spider Egg");
	AtmosMobs.AMlogger.info(" ");
	AtmosMobs.AMlogger.info("Atmosmobs: items registered");
	AtmosMobs.AMlogger.info(" ");
}

private void AddNames() {
	// LanguageRegistry.addName(SpiderEgg, "Spider Egg");
	AtmosMobs.AMlogger.info(" ");
	AtmosMobs.AMlogger.info("Atmosmobs: language registry completed");
	AtmosMobs.AMlogger.info(" ");
}

private void AddRecipes() {
	// GameRegistry.addRecipe(new ItemStack(Item.dyePowder, 1, 14),
	// new Object[] { "#", '#', ButterflyMod.SpiderEggShell });
	// GameRegistry.addSmelting(AtmosMobs.CrabMeatRaw.itemID, new
	// ItemStack(AtmosMobs.CrabMeatCooked, 1), 1F);
}

public static void sendNameInfo(int i, String s) {
}

@SidedProxy(clientSide = "mods.atmosmobs.ClientProxy", serverSide = "mods.atmosmobs.CommonProxy")
public static mods.atmosmobs.CommonProxy proxy;
@Instance("atmosmobs")
public static AtmosMobs instance;
public static long lastTickRun = 0L;
public static Logger AMlogger;
public static CreativeTabs tabAtmosMobs;
}

My Sound Event file

package mods.atmosmobs;

import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class AtmosMobsSounds {
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
	try {
		event.manager.addSound("atmosmobs:foxidle.ogg");
		// event.manager.addSound("atmosmobs:foxidle2.ogg");
		// event.manager.addSound("atmosmobs:foxhurt.ogg");
	} catch (Exception e) {
		System.err.println("Sounds not loaded");
	}
}
}

Entity that plays the sound

package mods.atmosmobs;

import net.minecraft.block.Block;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityFox extends EntityMammel {

public EntityFox(World par1World) {
	super(par1World);
}

public void determineSpecies(World worldObj) {
	byte byte0 = 0;

	if (getOnSpawn()) {
		AxisAlignedBB axisalignedbb = boundingBox.expand(8D, 8D / 2D, 8D);
		int n = MathHelper.floor_double(axisalignedbb.minX);
		int o = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
		int p = MathHelper.floor_double(axisalignedbb.minY);
		int q = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
		int n1 = MathHelper.floor_double(axisalignedbb.minZ);
		int o1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);

		for (int p1 = n; p1 < o; p1++) {
			for (int q1 = p; q1 < q; q1++) {
				for (int n2 = n1; n2 < o1; n2++) {
					int o2 = worldObj.getBlockId(p1, q1, n2);

					if (o2 == 0) {
						continue;
					}

					if (o2 == Block.snow.blockID) {

						byte0 = 1;
					}
				}
			}
		}
	}

	setOnSpawn(false);
	setSpecies(byte0);
}

@Override
public void onUpdate() {
	determineSpecies(worldObj);
	super.onUpdate();
}

@Override
protected String getLivingSound() {
	return "atmosmobs:foxidle";
}

@Override
protected String getHurtSound() {
	return null;
}

@Override
protected String getDeathSound() {
	return null;
}

@Override
protected void playStepSound(int par1, int par2, int par3, int par4) {
	this.playSound("mob.pig.step", 0.15F, 1.0F);
}
}

My console before it stops the sound

aug 10, 2013 10:40:23 PM net.minecraft.launchwrapper.LogWrapper log
INFO: Using tweak class name cpw.mods.fml.common.launcher.FMLTweaker
2013-08-10 22:40:23 [iNFO] [ForgeModLoader] Forge Mod Loader version 6.2.35.804 for Minecraft 1.6.2 loading
2013-08-10 22:40:23 [iNFO] [ForgeModLoader] Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_25, running on Windows 8:amd64:6.2, installed at C:\Program Files\Java\jre7
2013-08-10 22:40:23 [iNFO] [ForgeModLoader] Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
2013-08-10 22:40:24 [iNFO] [sTDOUT] Loaded 39 rules from AccessTransformer config file fml_at.cfg
2013-08-10 22:40:24 [iNFO] [sTDOUT] Loaded 107 rules from AccessTransformer config file forge_at.cfg
2013-08-10 22:40:24 [sEVERE] [ForgeModLoader] The binary patch set is missing. Either you are in a development environment, or things are not going to work!
2013-08-10 22:40:24 [iNFO] [ForgeModLoader] Launching wrapped minecraft
2013-08-10 22:40:25 [iNFO] [Minecraft-Client] Setting user: Player796
2013-08-10 22:40:25 [iNFO] [Minecraft-Client] (Session ID is null)
2013-08-10 22:40:25 [iNFO] [Minecraft-Client] LWJGL Version: 2.9.0
2013-08-10 22:40:26 [iNFO] [Minecraft-Client] Reloading ResourceManager: Default
2013-08-10 22:40:26 [iNFO] [sTDOUT] 
2013-08-10 22:40:26 [iNFO] [sTDOUT] Starting up SoundSystem...
2013-08-10 22:40:26 [iNFO] [MinecraftForge] Attempting early MinecraftForge initialization
2013-08-10 22:40:26 [iNFO] [sTDOUT] MinecraftForge v9.10.0.804 Initialized
2013-08-10 22:40:26 [iNFO] [ForgeModLoader] MinecraftForge v9.10.0.804 Initialized
2013-08-10 22:40:26 [iNFO] [sTDOUT] Replaced 101 ore recipies
2013-08-10 22:40:26 [iNFO] [MinecraftForge] Completed early MinecraftForge initialization
2013-08-10 22:40:26 [iNFO] [ForgeModLoader] Reading custom logging properties from F:\My Files\minecraft_modding\Modding\minecraftforge-src-1.6.2-9.10.0.804\forge\mcp\jars\config\logging.properties
2013-08-10 22:40:26 [OFF] [ForgeModLoader] Logging level for ForgeModLoader logging is set to ALL
2013-08-10 22:40:26 [iNFO] [sTDOUT] Initializing LWJGL OpenAL
2013-08-10 22:40:26 [iNFO] [sTDOUT]     (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
2013-08-10 22:40:26 [iNFO] [ForgeModLoader] Searching F:\My Files\minecraft_modding\Modding\minecraftforge-src-1.6.2-9.10.0.804\forge\mcp\jars\mods for mods
2013-08-10 22:40:26 [iNFO] [sTDOUT] OpenAL initialized.
2013-08-10 22:40:27 [iNFO] [sTDOUT] 
2013-08-10 22:40:28 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 4 mods to load
2013-08-10 22:40:28 [iNFO] [mcp] Activating mod mcp
2013-08-10 22:40:28 [iNFO] [FML] Activating mod FML
2013-08-10 22:40:28 [iNFO] [Forge] Activating mod Forge
2013-08-10 22:40:28 [iNFO] [atmosmobs] Activating mod atmosmobs
2013-08-10 22:40:28 [WARNING] [atmosmobs] Mod atmosmobs is missing a pack.mcmeta file, things may not work well
2013-08-10 22:40:28 [iNFO] [Minecraft-Client] Reloading ResourceManager: Default, FMLFileResourcePack:atmosmobs
2013-08-10 22:40:28 [iNFO] [sTDOUT] 
2013-08-10 22:40:28 [iNFO] [sTDOUT] SoundSystem shutting down...
2013-08-10 22:40:28 [iNFO] [sTDOUT]     Author: Paul Lamb, www.paulscode.com
2013-08-10 22:40:28 [iNFO] [sTDOUT] 
2013-08-10 22:40:28 [iNFO] [sTDOUT] 
2013-08-10 22:40:28 [iNFO] [sTDOUT] Starting up SoundSystem...
2013-08-10 22:40:28 [iNFO] [ForgeModLoader] Registering Forge Packet Handler
2013-08-10 22:40:28 [iNFO] [ForgeModLoader] Succeeded registering Forge Packet Handler
2013-08-10 22:40:28 [iNFO] [ForgeModLoader] Configured a dormant chunk cache size of 0
2013-08-10 22:40:28 [iNFO] [atmosmobs]  
2013-08-10 22:40:28 [iNFO] [atmosmobs] Atmosmobs: items registered
2013-08-10 22:40:28 [iNFO] [atmosmobs]  
2013-08-10 22:40:28 [iNFO] [atmosmobs]  
2013-08-10 22:40:28 [iNFO] [atmosmobs] Atmosmobs: achievement registry completed
2013-08-10 22:40:28 [iNFO] [atmosmobs]  
2013-08-10 22:40:28 [iNFO] [atmosmobs] atmosmobs: entity Butterfly registered
2013-08-10 22:40:28 [iNFO] [atmosmobs] atmosmobs: entity Fox registered
2013-08-10 22:40:28 [iNFO] [atmosmobs] Atmosmobs: preInit complete: sounds loaded and config loaded
2013-08-10 22:40:28 [iNFO] [atmosmobs]  
2013-08-10 22:40:28 [iNFO] [sTDOUT] Initializing LWJGL OpenAL
2013-08-10 22:40:28 [iNFO] [sTDOUT]     (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
2013-08-10 22:40:28 [iNFO] [sTDOUT] OpenAL initialized.
2013-08-10 22:40:28 [iNFO] [sTDOUT] 
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: language registry completed
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: spawn Eggs registered
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: init complete
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: Starting API load
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: ExtraBiomesXL not found: continue
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: BiomesOPlenty not found: continue
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: Highlands not found: continue
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [atmosmobs] Atmosmobs: postInit and API load complete
2013-08-10 22:40:29 [iNFO] [atmosmobs]  
2013-08-10 22:40:29 [iNFO] [ForgeModLoader] Forge Mod Loader has successfully loaded 4 mods
2013-08-10 22:40:29 [WARNING] [atmosmobs] Mod atmosmobs is missing a pack.mcmeta file, things may not work well
2013-08-10 22:40:29 [iNFO] [Minecraft-Client] Reloading ResourceManager: Default, FMLFileResourcePack:atmosmobs
2013-08-10 22:40:29 [iNFO] [sTDOUT] 
2013-08-10 22:40:29 [iNFO] [sTDOUT] SoundSystem shutting down...
2013-08-10 22:40:29 [iNFO] [sTDOUT]     Author: Paul Lamb, www.paulscode.com
2013-08-10 22:40:29 [iNFO] [sTDOUT] 
2013-08-10 22:40:29 [iNFO] [sTDOUT] 
2013-08-10 22:40:29 [iNFO] [sTDOUT] Starting up SoundSystem...
2013-08-10 22:40:29 [iNFO] [sTDOUT] Initializing LWJGL OpenAL
2013-08-10 22:40:29 [iNFO] [sTDOUT]     (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
2013-08-10 22:40:29 [iNFO] [sTDOUT] OpenAL initialized.
2013-08-10 22:40:30 [iNFO] [sTDOUT] 
2013-08-10 22:40:30 [sEVERE] [Minecraft-Client] Realms: Invalid session id
2013-08-10 22:40:36 [iNFO] [Minecraft-Server] Starting integrated minecraft server version 1.6.2
2013-08-10 22:40:36 [iNFO] [Minecraft-Server] Generating keypair
2013-08-10 22:40:36 [iNFO] [ForgeModLoader] Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@34d24c94)
2013-08-10 22:40:36 [iNFO] [ForgeModLoader] Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@34d24c94)
2013-08-10 22:40:36 [iNFO] [ForgeModLoader] Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@34d24c94)
2013-08-10 22:40:36 [iNFO] [Minecraft-Server] Preparing start region for level 0
2013-08-10 22:40:37 [iNFO] [sTDOUT] loading single player
2013-08-10 22:40:37 [iNFO] [Minecraft-Server] Player796[/127.0.0.1:0] logged in with entity id 53 at (1669.5907000626871, 3.0, 573.7725058052233)
2013-08-10 22:40:37 [iNFO] [Minecraft-Server] Player796 joined the game
2013-08-10 22:40:37 [iNFO] [sTDOUT] Setting up custom skins
2013-08-10 22:40:38 [iNFO] [sTDERR] Exception in thread "Thread-13" java.lang.NullPointerException
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.codecs.CodecJOrbis.readHeader(CodecJOrbis.java:448)
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.codecs.CodecJOrbis.initialize(CodecJOrbis.java:301)
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.libraries.LibraryLWJGLOpenAL.loadSound(LibraryLWJGLOpenAL.java:392)
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.libraries.LibraryLWJGLOpenAL.newSource(LibraryLWJGLOpenAL.java:640)
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.SoundSystem.CommandNewSource(SoundSystem.java:1800)
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2415)
2013-08-10 22:40:38 [iNFO] [sTDERR] 	at paulscode.sound.CommandThread.run(CommandThread.java:121)
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving and pausing game...
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving chunks for level 'New World'/Overworld
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving chunks for level 'New World'/Nether
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving chunks for level 'New World'/The End
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Stopping server
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving players
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Player796 left the game
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving worlds
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving chunks for level 'New World'/Overworld
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving chunks for level 'New World'/Nether
2013-08-10 22:40:40 [iNFO] [Minecraft-Server] Saving chunks for level 'New World'/The End
2013-08-10 22:40:40 [iNFO] [ForgeModLoader] Unloading dimension 0
2013-08-10 22:40:40 [iNFO] [ForgeModLoader] Unloading dimension -1
2013-08-10 22:40:40 [iNFO] [ForgeModLoader] Unloading dimension 1
2013-08-10 22:40:41 [iNFO] [Minecraft-Client] Stopping!
2013-08-10 22:40:41 [iNFO] [sTDOUT] 
2013-08-10 22:40:41 [iNFO] [sTDOUT] SoundSystem shutting down...
2013-08-10 22:40:46 [iNFO] [sTDOUT] Error in class 'SoundSystem'
2013-08-10 22:40:46 [iNFO] [sTDOUT]     Command thread did not die!
2013-08-10 22:40:46 [iNFO] [sTDOUT] Ignoring errors... continuing clean-up.
2013-08-10 22:40:46 [iNFO] [sTDOUT]     Author: Paul Lamb, www.paulscode.com
2013-08-10 22:40:46 [iNFO] [sTDOUT] 

 

 

 

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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