Server side code

Started by LueLusten on

Topic category: Help with MCreator software

Last seen on 22:52, 27. Oct 2017
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Server side code

Hey everyone I know this was fixed by someone but I don't remeber who
I have ore what is not server friendly because of 

EntityPlayer entity = Minecraft.getMinecraft().thePlayer;

This is a client side command and brakes servers, I know a few have fixed this, so how do we call the payer entity for
the ore to work

@Override public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) { EntityPlayer entity = Minecraft.getMinecraft().thePlayer; int i = pos.getX(); int j = pos.getY(); int k = pos.getZ();                if(!world.isRemote){       if ((Math.random() * 100) <= 15) {       world.createExplosion((Entity) null, i, j, k, 4F, true);       }                }   }

it was also included in onBlockAdd but then not used so I removed it there, so there a nother code I can wrap this in to fix it for servers or away to change entity call?

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I need it too D:
Thu, 08/31/2017 - 15:43

I need it too D:

Last seen on 19:56, 11. Aug 2019
Joined Aug 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:I need it too D:
Thu, 08/31/2017 - 16:19

@#1 Do you have discord?

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:I need it too D:
Thu, 08/31/2017 - 16:50

@#1.1 Yes why?

Last seen on 19:56, 11. Aug 2019
Joined Aug 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:I need it too D:
Thu, 08/31/2017 - 17:24

@#1.1.1 Just wondering.

Last seen on 22:52, 27. Oct 2017
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Who does not have discord
Thu, 08/31/2017 - 19:52

Who does not have discord this day and age lol but we have not fix yet unless you do :)

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Quite simply , using this
Thu, 08/31/2017 - 21:36

Quite simply , using this method you can not get reference to the actual player that has broken the block , I mean you can make a guess who could if you would iterate through player list and then check which one is the closest one to the block , but it would not be accurate in situation when for example more players would be near the same block.
So as you can see Block#onBlockDestroyedByPlayer() is called generally when the block is destroyed by a player , nothing less, nothing more.
If you want for some reason (like determining the action on player's inventory or apply some NBT depending on the player to the drop), there are many places where could you do this. You can use events or some alternatives even in the block itself.
However, I have to ask one thing, why on the Earth you need so much a reference to the player that has mined the block?
You are just creating a randomly sized explosion whenever it is mined. You do not apparently need the player here. And unless you don't plan need it for something, just get rid of the EntityPlayerSP reference.

Last seen on 23:25, 5. Apr 2018
Joined Feb 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can i make a attack with
Thu, 08/31/2017 - 23:16

How can i make a attack with a potion effect

 

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:How can i make a attack with
Fri, 09/01/2017 - 05:58

@#4 ... are you new to a forum?

Last seen on 23:25, 5. Apr 2018
Joined Feb 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:How can i make a attack with
Fri, 09/01/2017 - 16:09

@Kane yes

 

Last seen on 14:48, 10. Nov 2018
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:How can i make a attack with
Fri, 09/01/2017 - 18:44

@#5 welcome to the fourms then! :D

anyways, what do you mean by attack with a potion effect? if you mean in minecraft,

get a potion, drink it and attack,

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:How can i make a attack with
Fri, 09/01/2017 - 19:07

@#5 Welcome but create a new topic, don't ask something new in here D: and I will answer

Last seen on 23:25, 5. Apr 2018
Joined Feb 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:RE:RE:How can i make a attack with
Fri, 09/01/2017 - 20:25

@OlieGamerTV thanks

and i was thinking about mcreactor (how to give my mob a attack with a potion effect)

Last seen on 22:52, 27. Oct 2017
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I 100% didn't see this post
Tue, 09/19/2017 - 11:54

I 100% didn't see this post get updated Woops, I never added all the player called it added them all on its bill, MCreator loves to add local/SP only code and put everything out of wack, I trying to learn how to mix match forge code and fix MCreators code but the tool goes out of it's way to edit things back alot.

I think I fixed the ore at one point but since custom blocks and mobs are not server friendly from MCreator I ditched the need for the ore we changed it to a more server friendly plant.