
Taji34
Forge Modder-
Posts
147 -
Joined
-
Last visited
Everything posted by Taji34
-
[Solved][1.7.2]Can someone explain adding new liquids to me?
Taji34 replied to Taji34's topic in Modder Support
Thanks! It seems to be just the naming conventions (IIcon vs Icon) that have changed, but haven't been updated in the tutorial, once I get a fluid implemented, I will mark this thread as solved! Edit: Ok, so isLiquid() is saying it is undefined for the type block on the line world.getBlock(x, y, z).isLiquid(), is it supposed to be something other than a block? Fixed it, turns out world.getBlockMaterial(x, y, z).isLiquid() changes to world.getBlock(x, y, y).getMaterial().isLiquid(). Edit 2: Ok, so I guess I must not be registering something right because it's just registering a null liquid. this is what i have for my liquidEnergy.java: And this is what i have in my Troncraft.java: What am I doing wrong? Do I need another class somewhere? -
[Solved][1.7.2]Can someone explain adding new liquids to me?
Taji34 posted a topic in Modder Support
I looked at the tutorial on how to create a fluid for 1.7.2 (http://www.minecraftforge.net/wiki/Create_a_Fluid) but it seems to not be working. Either I am doing something wrong, or it has changed in forge because its saying that some of the classes don't exist or a methods are being undefined for an object type. Could someone explain the tutorial a bit more in depth to help me figure out either what has changed or where I am going wrong? if you need more info just ask and I'll post some screen caps of my eclipse workspace to show what is happening. -
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.
-
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?
-
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.
-
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...
-
Does anyone know what could be causing the error/my problem?
-
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?
-
Anyone have an idea? The first version of my mod is so close to release...
-
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Well, either way would work I believe, but basically take your actionPerformed method, and replicate it under the execute command in you custom packet. You will need to first retrieve the tile entity from the correct block, since it's not passed in the packet. After you've done that, post your custom packet code. -
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Hmm, well I tried to look through your code but I was a bit confused, in your current code where do you change the height of how high the block lifts you? The way I would do it is have an NBT tag called height, which stored and integer. Then for the packet I'd send an integer array that help 4 numbers, the X, Y, and Z coordinates of the block, and the height I want it to change to. Under the execute I would retrieve the tile entity at the X, Y, and Z coordinates, and then set the NBT tag height to the fourth number I sent. Then I would have the block read the NBT tag to get what height it should be lifting to. -
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Okay, now it is time to make your custom packet. Make a new class named something like, BlockChangePacket, so you know what the packet is doing later without having to look at the actual class. Follow the making our first class part of the tutorial. Under the execute method is where you will want to tell it to change the block. My suggestion is after you finish that part, create a constructor for that class that takes in an integer array, which you would use to send the x, y, and z coordinates of the specific block you want to change the values of, and set three variables (name them what you would like, but x, y and z would be the least confusing) to the values accordingly. Under execute if where will out your code for changing the block's variables. This is where it gets a little involved, so do what you can, and then post here if you get stuck. -
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Next is the method that actually sends our packet. Add the following to your BasePacket class: public final int getPacketId() { if (idMap.inverse().containsKey(getClass())) { return idMap.inverse().get(getClass()).intValue(); } else { throw new RuntimeException("Packet " + getClass().getSimpleName() + " is missing a mapping!"); } } public final Packet makePacket() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeByte(getPacketId()); write(out); return PacketDispatcher.getPacket(CHANNEL, out.toByteArray()); } These methods make it so that you can actually send a packet to the server. -
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Okay, next we need a way to receive packets, this is our packet handler, create a new class call CustomPacketHandler and follow the receiving packets section of the tutorial. You will need to change some class names in the code (namely from DemoPacket to PacketBase). This class basically determines when a packet is sent, and determines what it should do with it. -
the sound is in the correct area, and when I put @ForgeSubscribe before the SoundLoadEvent, all sound goes away...
-
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; } }
-
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Okay, so first thing you want to do is get the packet framework in place before you change any of your existing code. Create a new class, this will be our base for any packets we send, call it something like PacketBase. In this class you will want to follow the Making the Base for our Packet classes part in the Advanced Packet Handling tutorial I linked to earlier. This class basically implements all the basic stuff needed to create a packet, and it will be the parent class to any custom packets we send. This is also where we will register any custom packets we made. Do this, and post a reply when you are done with this step. If you run into any problem, post here and I will help you figure them out. -
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
I'm sorry, but I have already looked through those tutorials, and I still don't know what to do, or where I should implement everything. It should be much simpler than this shouldn't it? Thank you already for the help you have given me, it is much appreciated. I will mention you in the mod's credits. No need to put me in the mod's credits! Packet handling is a bit confusing at first, but once you actually get one working it's simple. I can try to figure out what needs to be done, but it is quite late where I am, so I will take a look at your code tomorrow, sound good? -
Wow, I was lightyears away from the solution...haha.
-
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
Read through these two tutorials: http://www.minecraftforge.net/wiki/Packet_Handling http://www.minecraftforge.net/wiki/Advanced_Packet_Handling (I suggest you do not change any part of your code until after you've read through these, and understand packet handling) Once you get a grip on packet handling, it might become clearer. Basically, where ever you want to change a value in the tile entity of a block, you want to send a packet to the server that tells the server to change the value of the block. That way, you make sure the server knows you're making a change, not just the client. After you've read through both tutorials, if you still are unclear on what you should do, I can try to walk you through getting it to change. -
Umm, yeah, it may be that Minecraft doesn't know how to render your mob. I, however, have no experience with this, so you might have to do some looking for a tutorial to help you.
-
Try: par3Entityplayer.addChatMessage("Your message here");
-
Umm, I think the problem here is that the game might not know how to render your custom entity. Code you provide the code for your entity?
-
NBT's are not saving or saving too soon when the game is quit
Taji34 replied to kris91268's topic in Modder Support
I believe the problem you are having is that you aren't telling the server what is changing in the nbt data, you're doing everything client side, which, upon log out, is discarded. What you will want to do is send a packet to the server, then have it execute the changes as a result of what packet it receives. -
It's finally working the way I want it! In case anyone is interested here is the code I used. It's not commented, but if you want me to explain any of it, just send me a PM. Troncraft.java: package taji34.troncraft; import net.minecraft.block.Block; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.src.ModLoader; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; 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.Init; 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; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; 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 } } Baton.java: package taji34.troncraft; import cpw.mods.fml.common.network.PacketDispatcher; 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.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class Baton extends Item { private boolean active = false; public Baton(int par1) { super(par1); setMaxStackSize(1); setCreativeTab(CreativeTabs.tabMisc); setUnlocalizedName("Baton"); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { this.itemIcon = iconRegister.registerIcon("Troncraft:Baton"); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par2World.isRemote) { NBTTagCompound tag = par1ItemStack.getTagCompound(); if (tag == null) { tag = new NBTTagCompound(); par1ItemStack.setTagCompound(tag); } if (tag.getName().equals("tag")) { tag.setName("Normal"); } System.out.println(tag.getInteger("Damage")); if (!this.active) { this.active = true; PacketDispatcher.sendPacketToServer(new BatonModePacket("activate").makePacket()); } else { this.active = false; PacketDispatcher.sendPacketToServer(new BatonModePacket("deactivate").makePacket()); } } return par1ItemStack; } } BatonModePacket.java: package taji34.troncraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataOutput; import cpw.mods.fml.relauncher.Side; public class BatonModePacket extends TajiPacket { private String text; public BatonModePacket(String text) { this.text = text; } public BatonModePacket() { } @Override protected void write(ByteArrayDataOutput out) { out.writeUTF(text); } @Override protected void read(ByteArrayDataInput in) throws ProtocolException { text = in.readUTF(); } @Override protected void execute(EntityPlayer player, Side side) throws ProtocolException { ItemStack itemstack = player.getHeldItem(); Baton baton = (Baton) itemstack.getItem(); if (itemstack.getDisplayName().equals("Baton")) { NBTTagCompound tag = itemstack.getTagCompound(); if (text.equals("Sword")) { tag.setName("Sword"); } else if (text.equals("Staff")) { tag.setName("Staff"); } else if (text.equals("Normal")) { tag.setName("Normal"); } if (text.equals("activate")) { tag.setInteger("Damage", 1000); } if (text.equals("deactivate")) { tag.setInteger("Damage", 0); } System.out.println(tag.getInteger("Damage")); } } } 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.event.ForgeSubscribe; import net.minecraftforge.event.entity.living.LivingHurtEvent; public class TajiEvents { @ForgeSubscribe public void entityAttacked(LivingHurtEvent event) { EntityLiving attackedEnt = (EntityLiving) event.entityLiving; DamageSource attackSource = event.source; if (attackSource.getSourceOfDamage() != null) { 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; } } } } } Finished product changes it's damage output when it is held in the player's hand and right clicked.