Jump to content

Recommended Posts

Posted

depending on the context and location of the call, the method of obtaining it may differ significantly, but it is always Level

example: the Player parameter is passed to a certain method

public boolen anyMethod(ServerPlayer player, par1, par2) {...}

you will receive the client side as follows

player.getLevel.isClientSide

server code is written in a block if (! player.getLevel.isClientSide){///}

client code is written in a block if (player.getLevel.isClientSide){///}

 

in some cases, the world can be passed directly to the method, but I don’t remember this in my practice

in almost all cases I get the client side from LivingEntity.getLevel.isClientSide

 

example 2: the client side is taken from the event

public static void onPlayerJoin(EntityJoinLevelEvent event){
            if(!event.getLevel().isClientSide()){
                if(event.getEntity() instanceof ServerPlayer player){
                    val = event;
                    RegisterPlayer registerPlayer = new RegisterPlayer();
                    registerPlayer.start();
                    SetupQuestCoreForPlayer setupQuestCoreForPlayer = new SetupQuestCoreForPlayer();
                    setupQuestCoreForPlayer.start();
                }
            }

here you can also get the client side via event.getEntity().getLevel().isClientSide() OR event.getLevel().isClientSide()

sorry my ENGLISH is very bad

loock this

https://github.com/andreybadrey/forge/blob/master/src/main/java/com/bodryak/gmod/event/CapsEvents.java

https://github.com/andreybadrey/forge/blob/master/src/main/java/com/bodryak/gmod/event/JoinLevel.java

https://github.com/andreybadrey/forge/blob/master/src/main/java/com/bodryak/gmod/event/LivingEntityDeath.java

https://github.com/andreybadrey/forge/blob/master/src/main/java/com/bodryak/gmod/event/LivingEntityHurt.java

https://github.com/andreybadrey/forge/blob/master/src/main/java/com/bodryak/gmod/util/SyncScaner.java

its help you!

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.

Announcements



×
×
  • Create New...

Important Information

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