Jump to content

[Unsolved] Server hurt Player


Ghoul159

Recommended Posts

Is there a easy way to tell the server to hurt the player?

player.attackEntityFrom()

i need to call the hurt method in a client tick...

is it possible to tell the server (out of a client side class) to perform one server mehod to hurt the player?

No, it is not possible and should never be done. The client is dumb and only tells lies*. Never ever trust the client. Always do everything on the server. Period.

 

*Of course this is not true, but it is the way you should think while developing. Clients can be evil and do stuff you don't expect in your wildest dreams :D

 

yea i noticed some strange behaviours of the client nevertheless i set some things up there and i have to tell the server to hurt the player...

 

so i thought about someting like this:

 

1. i'll write a little method "server-side" to hurt the player and call it from "client-side"

2. my PROBLEM: how do i get the player instance on the server without using the evil modloader stuff... :)

 

maybe i should have been more specific^^

Link to comment
Share on other sites

ok then i'll have to rewrite some stuff^^

 

i have to hurt him in an ingame tick...

sort of he is alive and is in that biome hurt him (for example)

 

and have an additional question:

 

how do i get the specific player from the server if i would want to get the player in an biome or under the sun or in water? :)

Link to comment
Share on other sites

ok i think i got something like that already :

 

public class ServerTickHandler implements ITickHandler {

    @Override
    public void tickStart(EnumSet<TickType> type, Object... tickData) {}

    @Override
    public void tickEnd(EnumSet<TickType> type, Object... tickData)
    {
            if(type.equals(EnumSet.of(TickType.PLAYER)))
            {
                    onTickInGame();
            }
    }


            public EnumSet ticks()
        {
            return EnumSet.of(TickType.PLAYER);
        }

        public String getLabel()
        {
            return null;
        }
       

        private void onTickInGame()
        {
            //put here any code that needs to be done server side, like set WorldGeneration, and let entities spawn on the first server tick.
            //also put all the code in a if(world != null && !world.isRemote) statement, makes it so that you don't get NPEs from that.
        		
        }

}

Link to comment
Share on other sites

ah i see

sry about so many questins i read a lot about mc modding but wasn't 100% shure about this whole client - server thing :)

 

i 've already a sided proxy :)

 

 

but i just tried a simple write chat massage code in my server tick from above and it worked as server but not in singleplayer, oehm do you know why?

and how can i get a server World tick too? :)

i think if i know that i am able to rewrite my code in a few minutes :)

Link to comment
Share on other sites

currently i'm doin it just with a server-sided proxy:

 

package TempCraft.common;

import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.block.Block;

public class CommonProxyTempCraft 
{
public void registerRenderThings()
{
	TickRegistry.registerTickHandler(new ServerTickHandler(), Side.SERVER);
	TickRegistry.registerTickHandler(new ServerTickWorldHandler(), Side.SERVER);
}

}

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.

Announcements



×
×
  • Create New...

Important Information

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