Jump to content

Item Recipes not working in multiplayer?


Athire

Recommended Posts

Hello all! I'm a bit new to Minecraft modding so please bare with me, as this is probably an easy fix. I'm working on a basic spells mod, and I've run into an issue.In single player I made a spell book that would shoot a fireball when right clicked, but when I try to get it working in multiplayer the crafting recipe for it does not work! The book appears in the crafting output, but when I click it it does not go into my inventory. To verify that the issue isn't just my book, I added another recipe that would turn a few blocks of dirt into diamond, and I got the same result. What do I have to do differently to get custom recipes working in multiplayer? I believe the issue has to do with the client server system in minecraft. I have both a clientProxy and commonProxy class, but they don't currently do anything because I don't quite know what to do with them :P I'll add my code in the attachments section, I used kennethbgoodin's Youtube tutorial to get my base class, client proxy and common proxy classes set up, so creadit for the structure of it goes to him! Also, I'm trying to add a mana system, so I created a player class inherited from the EntityPlayerMP class in minecraft and added a variable to store the amount of player mana, so that's why I have an "EntityMagicPlayerMP" class.  Thank you so much for any help you guys can give! I'm still in the learning phases of this so anything you guys can teach me will be greatly appreciated!

 

P.S. ok I'm having an issue uploading the attachment, I'll try attaching it in another comment (Sorry, I'm new here if you couldn't tell :P)

P.S.S Also it gave me an error that I uploaded this already, but my profile says I havn't posted anything yet. So if this is  a re-post I'm very sorry!

Link to comment
Share on other sites

So for the life of me I can't get attachments to work, I'm gonna have to just copy/paste my code. Sorry if this isn't the correct thing to do on this site, again I'm new :(

 

 

 

//************************ Base Class *****************************

package InnerPower;

//---------------------------------

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.*;

import net.minecraftforge.common.MinecraftForge;

//-----------------------------------

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.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

 

@Mod(modid= "AthInrPwr", name= "Inner Power", version= "Alpha 1.0")

@NetworkMod(clientSideRequired= true, serverSideRequired= false)

public class BaseClass

{

//*********** Defining blocks/items

public static final Block InrPwrCrystal = new crystalBlock(550, Material.ground).setHardness(45.0f).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("crystalBlock").setCreativeTab(CreativeTabs.tabBlock).setTextureName("InnerPower_Block_Crystal");

public static final Item InrPwrWispEssence = new Item(5001).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("essenceWisp").setTextureName("InnerPower_Essence_WispyEssence");

public static final Item STFireball= new SpellTomeFireball(5000).setTextureName("InnerPower_SpellTome_Fireball");

//From new tutorial

 

//instance of mod forge uses

@Instance("AthInrPwr")

public static BaseClass instance;

 

//says where the client and server proxy code is loaded

@SidedProxy(clientSide= "InnerPower.client.ClientProxy",serverSide="InnerPower.CommonProxy")

public static CommonProxy proxy;

 

  @EventHandler

      public void preInit(FMLPreInitializationEvent event)

  {

              // Stub Method

      }

 

  @EventHandler

      public void postInit(FMLPostInitializationEvent event)

  {

              // Stub Method

  }

 

 

  @EventHandler

public void load(FMLInitializationEvent event)

{

  GameRegistry.registerBlock(InrPwrCrystal, "crystal" );

  LanguageRegistry.addName(InrPwrCrystal, "crystal");

  MinecraftForge.setBlockHarvestLevel(InrPwrCrystal, "pickaxe", 3);

 

  LanguageRegistry.addName(InrPwrWispEssence, "Wispy Essence");

 

 

LanguageRegistry.addName(STFireball, "Spell Tome: Fireball");

  GameRegistry.addRecipe(new ItemStack(STFireball, 1), new Object[]{

  "xx","xx", 'x', Block.dirt

  });

 

  //test recipie

  GameRegistry.addRecipe(new ItemStack(Item.diamond, 1), new Object[]{

  "x x", " x ", "x x", 'x', Block.dirt

  });

 

}

 

 

 

 

}

 

//******************************** Spell Tome Class ***********************************************

 

package InnerPower;

 

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Vec3;

import net.minecraft.world.World;

import net.minecraft.block.Block;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.projectile.EntitySmallFireball;

 

import java.util.Random;

 

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

 

public class SpellTomeFireball extends Item

{

 

//Default Constructor

 

public SpellTomeFireball(int id)

{

super(id);

setMaxStackSize(1);

setCreativeTab(CreativeTabs.tabCombat);

setUnlocalizedName("STfireball");

 

}

 

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityMagicPlayerMP par3EntityPlayer)

    {

if (!par2World.isRemote)

        {

if(par3EntityPlayer.getMana() >= 1)

{

 

 

                                        Vec3 look = par3EntityPlayer.getLookVec();

                                        EntitySmallFireball fireball2 = new EntitySmallFireball(par2World, par3EntityPlayer, 500, 500, 500);

                                        fireball2.setPosition(par3EntityPlayer.posX + look.xCoord * par3EntityPlayer.getEyeHeight(), par3EntityPlayer.posY + look.yCoord * par3EntityPlayer.getEyeHeight()+1, par3EntityPlayer.posZ + look.zCoord * par3EntityPlayer.getEyeHeight());

                                        fireball2.accelerationX = look.xCoord * 0.5;

                                        fireball2.accelerationY = look.yCoord * 0.5;

                                        fireball2.accelerationZ = look.zCoord * 0.5;

                                        par2World.spawnEntityInWorld(fireball2);

                                       

                                        par3EntityPlayer.setMana(par3EntityPlayer.getMana()-1);

}

else

par3EntityPlayer.addChatMessage("I don't have enough mana to do that!");

        }

 

    return par1ItemStack;

 

 

    }

 

public String getVersion()

{

return "1.0";

}

 

 

}

 

//******************************************* Common Proxy Class **********************************************

package InnerPower;

 

public class CommonProxy

{

// Client stuff

    public void registerRenderers() {

            // Nothing here as the server doesn't render graphics or entities!

    }

}

 

 

// ********************************************** Client Proxy Class *****************************************************

 

package InnerPower.client;

 

import net.minecraftforge.client.MinecraftForgeClient;

import InnerPower.CommonProxy;

 

public class ClientProxy extends CommonProxy {

     

        @Override

        public void registerRenderers() {

                // This is for rendering entities and so forth later on

        }

     

}

 

//************************************** EntityMagicPlayerMP class, which is inherited from EntityPlayerMP ************************

 

Link to comment
Share on other sites

Hi

 

Looks to me like your mod is running on the client not the server.

 

Try changing this line

@NetworkMod(clientSideRequired= true, serverSideRequired= false)

to be true on both sides.  Not sure if that's the problem but it's worth a try.

 

BTW a link on Proxy stuff you might find interesting

http://greyminecraftcoder.blogspot.com/2013/11/how-forge-starts-up-your-code.html

 

-TGG

Link to comment
Share on other sites

Ok so i tried switching serverSideRequired to true, which made no change unfortunately. Then I moved all of my blocks and items to the preInit function, which also made no change. I checked the server console and found that it said "3 mods loaded" which it lists as MCP, Forge, and ForgeModLoader. So I guess the server isn't registering my mod? Any ideas on how to fix this? That's weird though because my custom recipes are recognized to a degree, my spell book thing appears in the crafting output, if I hover over it it reads the name "Spell Tome: Fireball". When I click it it fidgets like it's going into my inventory but then doesn't, the same with my dirt to diamond test recipe. Is that because the recipes are registered client side, so they appear, but the server doesn't recognize them, so nothing happens when it is clicked? Thank you all for your help so far, even if the prior suggestions didn't pan out I'm super grateful for your input!

Link to comment
Share on other sites

The behavior you describe is exactly equivalent to the server not having your mod installed.

 

In fact, you confirmed it when the server said that it loaded three mods: MCP, Forge, and FML.

 

How do you fix it?  Well, by putting your mod in the server's mod folder.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ok, so I found where to put my mod, but my issue is now that I've been just using the run button on eclipse to test my mod builds on the MCP test server (in the MCP file in forge), I haven't been recompiling and reobfuscating it because I've only added like 1 recipe so far. So I don't really have a mod folder. I did find the folder containing my .class files under MCP>>src>>minecraft, but when I copy/pasted it there it didn't work. I figured it wouldn't but I gave it a try anyway. So will I have to recompile and reobfuscate every time I want to test to see if something works? Will that give me the finished mod folder I need to run it on the MCP test server? Or am I just missing something (which I very well could be)? Again thanks for everything guys, you've been very helpful! Thanks for having patience with me :)

Link to comment
Share on other sites

The run button has a dropdown.  In it are two options:

 

Client

Server

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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
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.



×
×
  • Create New...

Important Information

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