Reputation: 77
I am just learning how to create inventory GUIs in Minecraft. I am adding one to my call of duty zombies game that I have already built just to make it a little bit better. My problem is that when people buy team upgrades I need the inventory options to change to reflect what they have bought and what they have not bought.
The way I was planning to do this was to simply check for scoreboard tags that are assigned to them when they purchase an item. However, I couldn't find a way to do this.
My next thought was to have it so that when they buy each upgrade it sets a block at specific coordinates to a certain material. for this example lets just say cords (100, 50, 200) and type Sandstone. If the block was sandstone then it will open up a whole separate UI that i would make allowing them to buy upgrade two. This process would repeat until all upgrades were bought with the block at cords 100, 50, 200 changing as upgrades were bought.
I have really a few questions.
Is there a better way to do this and if so please explain.
Even if there isn't a good way I would still like to know how in a plugin to set a block at specific coordinates not relative to the player to a certain block type.
Even if there isn't a good way I would also still like to know how to check what type of block is at a specific set of coordinates not relative to the player.
I didn't think code examples were necessary here but if you need any please let me know and I can edit them in.
Thanks in advance for any help you can provide, ~Stone
Upvotes: 2
Views: 5391
Reputation: 148
There is no good way to do this, but i can anser your questions,
In the World there is a method called getBlock(x,y,z) you can then call the setType method on that block, example:
p.getLocation().getWorld().getBlock(0,0,0).setType(Material.AIR);
As in the second anser you can also get the type, Example:
if(p.getLocation().getWorld().getBlock(0,0,0).getTyp() == Material.AIR){
//Check for air in the players world at 0,0,0
}
Upvotes: 1