Jump to content

Recommended Posts

Posted

okay, so i just created a TPPI server, which runs on 1.6.4, only to learn that bukkitForge and Cauldron no longer exist. this poses a problem when it comes to protecting areas of my server that need protecting.

 

I have thought long and hard about this and i think i have worked out how to protect land in my mod. i'm just not certain this will work or how to do it. could i get your thoughts please?

 

here's what i was thinking

create a 3-d array "ProtChunk" and populate it with the protected chunks when the server starts

 

chunks would be saved in a JSON or YML format and would look like this:

 

area{

    chunk1

    chunk2

    chunk3

}

area2{

    chunk4

    chunk5

    chunk6

}

 

override, or extend (not sure) the block break event so that every time a block is broken the mod does the following check:

get the chunk the block is in, check if this chunk is in an array of protected chunks (which is set from a file when the mod loads). if it is cancel the event

 

 

when i want to protect an area i would use a command like /prot new <area name> and then

/prot claim <area name> to claim the chunk i am in.

 

when i do that 2nd command i would get the chunk i am currently in and save it to the array, which will be saved to the file.

 

 

it's a rough idea, can anyone tell me if i'm on the right track and how i would go about doing this?

Posted

Yes, I think you can override the block break event and cancel it for chunks you care to protect.

 

In terms of saving a list of chunks to protect, I think you can do it a bit more simply. You don't need 3-d, only 2-d because chunks go all the way in the Y-direction -- so if you have X and Z position you can figure out the chunk. Further, you only have to store the X and Z of one block in the chunk as there are methods to find chunk from X and Z position. I don't think you'd need a JSON, you could simply have a text file with pairs of X and Z positions.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

ok :)

 

with regards to storing and saving, i was looking for a way to define areas, so if i want to remove a protected area i just need to remove that area rather than the individual chunks... so it might still only need to be 2d, it would look like this:

 

Array protChunk{

    area1{

        "1,1",

        "1,2"

        "1,3"

    },

    area2{

        "2,1",

        "2,2"

    }

}

 

or am i still being overly complex? lol ( i have a tendency to do that)

Posted

I'm sure it could work with several different approaches. My main point is that you can identify a chunk by a single block location and you only need X and Z from that. So if all your regions are rectangular, you could just record the X, Z position of two corners and use a loop to check for any chunks in between.

 

So a text format simply like this would specify three regions:

region[0].corner[0].posX

region[0].corner[0].posZ

region[0].corner[1].posX

region[0].corner[1].posZ

region[1].corner[0].posX

region[1].corner[0].posZ

region[1].corner[1].posX

region[1].corner[1].posZ

region[2].corner[0].posX

region[2].corner[0].posZ

region[2].corner[1].posX

region[2].corner[1].posZ

 

Anyway, I think that would be the most minimal data structure that would be sufficient to figure out all protected chunks. But it seems like you're a competent coder, so feel free to use a more formal tagging scheme if you wish.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.