Jump to content

I want to write String save in box.


zlappedx3

Recommended Posts

I want to write String save in box . Refer name player of string in server. If non owner box can't break. But if owner box can  break.

 

 

 

Minecraft mc;

 

public void onBlockAdded(World world,int par1, int par2, int par3)

    {

String var4 = mc.thePlayer.getCommandSenderName();

if(var4 == mc.thePlayer.getCommandSenderName()){

 

}else{

this.setBlockUnbreakable();

}

    }

 

 

 

how to write it ?

 

Link to comment
Share on other sites

I want to write String save in box . Refer name player in server. If non owner box can't break. But if owner box can  break.

 

 

 

Minecraft mc;

 

public void onBlockAdded(World world,int par1, int par2, int par3)

    {

String var4 = mc.thePlayer.getCommandSenderName();

if(var4 == mc.thePlayer.getCommandSenderName()){

 

}else{

this.setBlockUnbreakable();

}

    }

 

 

 

how to write it ?

 

this code is a total mess. you should better delete it and hope noone will ever find it again.

The method u are seeking is onBlockPlaced, it gives you an EntityLivingBase where u can get the players name from. If u call setBlockUnbreakable u will set ALL of your blocks unbreakable, because the Block class is for EVERY SINGE BLOCK of that block placed. if you want them to be different you need to use a TileEntity

Link to comment
Share on other sites

I want to write String save in box . Refer name player in server. If non owner box can't break. But if owner box can  break.

 

 

 

Minecraft mc;

 

public void onBlockAdded(World world,int par1, int par2, int par3)

    {

String var4 = mc.thePlayer.getCommandSenderName();

if(var4 == mc.thePlayer.getCommandSenderName()){

 

}else{

this.setBlockUnbreakable();

}

    }

 

 

 

how to write it ?

 

this code is a total mess. you should better delete it and hope noone will ever find it again.

The method u are seeking is onBlockPlaced, it gives you an EntityLivingBase where u can get the players name from. If u call setBlockUnbreakable u will set ALL of your blocks unbreakable, because the Block class is for EVERY SINGE BLOCK of that block placed. if you want them to be different you need to use a TileEntity

 

- If setBlockUnbreakable it set box all.  Should what used instead ?

 

- I use TileEntity in how to write ?

Link to comment
Share on other sites

Hook into the playerinteract event and check for player leftclick on block as the action and that the block is your block and set the result to DENY.

 

This is a good reference to keep on hand:

http://www.minecraftforge.net/wiki/Event_Reference

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Link to comment
Share on other sites

No need to use events if it's your own

Block

.

 

Override

Block#getPlayerRelativeBlockHardness

to return -1.0f to prevent a player from starting to mine the

Block

and override

Block#removedByPlayer

to return

false

to prevent a player from breaking the

Block

(probably not strictly needed for vanilla, but mods with AoE mining tools like Tinkers Construct may break a

Block

without checking its hardness).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.