Hi Guys, I have solved most beginning problmes, but now I can't find a metho to create a Block somewhere. I want to check the location of a right clicked block an place some blocks on top of that Block. (some sort of tower) And here is anoher Problem, now I'm looking for an event to check if a pressure plate was pressed. Would be nice if someone could help me out! Sincerely, Zero9195
All blocks that exist in the game are already present. To create a block you need to change the existing block to something new. For example, if you want to create a block directly above the players head you change the id of the 'air' block above them to whatever block type you want to be there.
Here's a little code I wrote yesterday. when you right click with a wooden hoe, it will spawn a 3 block high obsidian pole above. Code: public void onBlockRightClick(BlockRightClickEvent event){ Block block = event.getBlock(); Player player = event.getPlayer(); if (player.getItemInHand().getTypeId() == 290){ for(int q = 1;q <= 3; q++){ Block newBlock = player.getWorld().getBlockAt(block.getX(), block.getY()+q, block.getZ()); newBlock.setTypeId(49); } } }
Ohhhh yeah. Now you say it. Totally forgot air is a block *head meets wall* Thanks for your code, helped me a lot I'm still looking for an event to check a pressed pressure plate. HELP!!! Thanks Guys, Zero9195
ok thx, will try this out Problems over problems, here the next one: I want to check if the player who playced the block has 63 of it in his hand or inventory. this is what i tried so far: Code: public void Tower1( BlockRightClickEvent event) { Player player = event.getPlayer( ); Block block = event.getBlock( ); ItemStack hand = event.getItemInHand( ); if ( block.getType( ) == Material.DIRT && JMPlayerListener.plugin.enabled( player ) && HERE I WANT THE CHECK) { for (int i = 0 ; i < 63 ; i++) { Block newBlock = player.getWorld( ).getBlockAt(block.getX( ), block.getY( ) + i, block.getZ( ) ); newBlock.setTypeId(3); REMOVE 1 OF THE ITEM DIRT } } } Thanks for your help