Server side code

Started by LueLusten on

Topic category: Help with MCreator software

Active 7 years ago
Joined Nov 2016
Points:
886

User statistics:

  • Modifications: 0
  • Forum topics: 21
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 155
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?

Active 6 years ago
Joined Aug 2014
Points:
913

User statistics:

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

I need it too D:

Active 6 years ago
Joined Aug 2017
Points:
824

User statistics:

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

@#1 Do you have discord?

Active 6 years ago
Joined Aug 2014
Points:
913

User statistics:

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

@#1.1 Yes why?

Active 6 years ago
Joined Aug 2017
Points:
824

User statistics:

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

@#1.1.1 Just wondering.

Active 7 years ago
Joined Nov 2016
Points:
886

User statistics:

  • Modifications: 0
  • Forum topics: 21
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 155
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 :)

Active 1 year ago
Joined Aug 2013
Points:
1164

User statistics:

  • Modifications: 4
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 737
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.

Active 7 years ago
Joined Feb 2017
Points:
703

User statistics:

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

How can i make a attack with a potion effect

 

Active 6 years ago
Joined Aug 2014
Points:
913

User statistics:

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

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

Active 7 years ago
Joined Feb 2017
Points:
703

User statistics:

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

@Kane yes

 

Active 6 years ago
Joined Jul 2017
Points:
732

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 51
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,

Active 6 years ago
Joined Aug 2014
Points:
913

User statistics:

  • Modifications: 1
  • Forum topics: 16
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 204
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

Active 7 years ago
Joined Feb 2017
Points:
703

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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)

Active 7 years ago
Joined Nov 2016
Points:
886

User statistics:

  • Modifications: 0
  • Forum topics: 21
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 155
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.