Jump to content

Block Damaging, About to throw computer.


snocavotia

Recommended Posts

I have been fiddling with code all day and have not found a single peice of code that works.. But lets say this.

 

I press my LeftMouseButton. that button initiates a method and that method slowly damages the block based on my pickaxe and the BlockID. I no longer need to mine at a specific x,y,z but what is this damn method?! I've searched for two days now. I've tried PlayerControllerMP.clickBlock() World.destroyBlock(), World.partiallyDestroyBlock(), etc..

 

Basically what i am saying is this. What method tells the game (Client AND Server). that i am mining/breaking/have broken the block im looking at?

Link to comment
Share on other sites

Why are you going to hurt the computer? It's a tool. It's like punching a hammer because you can't figure out how to make it pound a nail into a board.

Jokes aside, you're looking at the wrong side of things. This is done with packets.... specifically the Packet14DigBlock.class packet which is then handled by the netserverhandler regardless of which side you are on. So it is always dealt with on the server side, be it dedicated or integrated, applied to the server world, and then sent as a packet for the actual update (block removal generally). If you want more deatil look into the NetServerHandler.class

I think its my java of the variables.

Link to comment
Share on other sites

Hi

 

The client tells the server to dig the block, the server handles the digging and destroys the block (and sends the results back to the client).

 

The client uses packet14

http://greyminecraftcoder.blogspot.com.au/2013/10/packets-from-client-to-server.html

 

This is handled by NetServerHandler.handleBlockDig

 

The methods in ItemInWorldManager are used to do the block harvesting and item damage

In particular

ItemInWorldManager.tryHarvestBlock

 

This sets a flag in WorldServer.setBlock which causes the server to (a bit later) send the new block information to the client (markBlockFOrUpdate)

 

-TGG

 

 

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.