Simple block mod can't run on a server

Started by Truemirror on Tue, 08/07/2018 - 06:52

Topic category: General discussion

Last seen on 16:48, 9. Aug 2018
Joined Apr 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Simple block mod can't run on a server
Tue, 08/07/2018 - 06:52

Yesterday I played on my server and we have ProjectE there. I setup a sugar cane farm for infinite EMC, but the energy condenser overflowed with canes, and so I thought to myself why not make a mod which allows me to craft sugar cane blocks. Problem is, mod runs fine in singleplayer, but the server crashes when I run it.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Can you post your crash log?
Tue, 08/07/2018 - 08:12

Can you post your crash log?

Last seen on 10:11, 21. Oct 2020
Joined Apr 2010
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Which version of MCreator…
Tue, 08/07/2018 - 16:21

Which version of MCreator did you use to create this mod?

Last seen on 16:48, 9. Aug 2018
Joined Apr 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Version 1.7.3 for MC 1.7.10,…
Tue, 08/07/2018 - 17:44

Version 1.7.3 for MC 1.7.10, here's the crash report:

https://pastebin.com/rRLPqWrS

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Class of your block uses…
Tue, 08/07/2018 - 19:57

Class of your block uses references to client-only classes in the common or server-side code, resulting in to crash, as the server-side cannot see these classes as they de-facto are not there.
The client-side class is EntityClientPlayerMP. You have to use some common or server-side class instead, depending on your needs. I do not have an access to your code, but I guess that using EntityPlayer should be enough, if it is possible in the method, that the EntityClientPlayerMP is referenced from. Another possible solution could be checking for server-side (using field isRemote (its value is false for a server) in World class) and/or using @SideOnly annotation.

Last seen on 16:48, 9. Aug 2018
Joined Apr 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Well, first, it only adds a…
Wed, 08/08/2018 - 08:09

Well, first, it only adds a recipe for the sugar cane block, which is 4 sugar canes in a square pattern.

Second, I have absolutely no clue as to how these classes work, how can I change them etc. I'm guessing when I select the mod I go to "Edit code of selected element", but everything to me there is just a bunch of text. Any suggestions how to do this?

Last seen on 16:48, 9. Aug 2018
Joined Apr 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Ohhh by "only new recipes"…
Wed, 08/08/2018 - 08:11

Ohhh by "only new recipes" you meant if there's already a sugar cane block... No, the block is also from the MCreator mod.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I can not offer any more…
Wed, 08/08/2018 - 09:11

I can not offer any more help as long as you don't provide any of your code, as it is nearly impossible to do anything without it.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Replace  public void…
Wed, 08/08/2018 - 10:34

Replace 

public void onBlockAdded(World world, int i, int j, int k) {
            EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
            if (entity != null && world != null) {
                int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
                world.setBlockMetadataWithNotify(i, j, k, le, 2);
            }
 
            world.scheduleBlockUpdate(i, j, k, this, this.tickRate(world));
 
        }

 

by this

public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entity, ItemStack stack) {
            if (entity != null && world != null) {
                int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
                world.setBlockMetadataWithNotify(i, j, k, le, 2);
            }
 
            world.scheduleBlockUpdate(i, j, k, this, this.tickRate(world));
 
        }

And you should be fine.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You have to import…
Wed, 08/08/2018 - 13:33

You have to import EntityLivingBase class, you can do it manually (import net.minecraft.entity.EntityLivingBase;), or you can use the fix imports button. (Actually that is not its name, but it is close enough. Most likely something like "fix imports & format code".)

Last seen on 16:48, 9. Aug 2018
Joined Apr 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thank you so much, it worked…
Wed, 08/08/2018 - 13:56

Thank you so much, it worked! 

One question, do I have to do this everytime I want to add a mod to a server?

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I have not modded for 1.7.10…
Wed, 08/08/2018 - 14:05

I have not modded for 1.7.10 for quite a while, but it seems that MCreator for this version most likely generates this part of the code for every new block. So you have to do this change for every new block, I guess. Alternatively, you could also just remove the part of the code. What the code actually does is that it sets the metadata f the block based on placer facing on its placement, so if you do not want to have the block this functionality, you should be fine without it.