How do i make it if a player places a certain block next to a certain block it wont allow it i dont know how to start any help
So would it be a if situation? Im doing a plugin for a modded server and im making it so you cant put a tesseract by an alluminum wire vise versa
would this work so far? @EventHandler public void onBlockPlaceEvent(BlockPlaceEvent event){ Player player = (Player) event.getPlayer(); ItemMeta blockMeta = player.getItemInHand().getItemMeta();
You shouldn't have to cast Player. Code (Text): Player player = event.getPlayer(); HINT: you need to get the block that was placed. Not ItemMeta
No, since you are trying to find the block placed on the BlockPlaceEvent make sure to do event. not player. EDIT: Perhaps it is event.getBlock();
Try player.getInventory().getIteminMainHand() EDIT: Just realized what you are trying to do, you will need to do even.getBlock() then get the meta from there
@EventHandler public void onBlockPlaceEvent(BlockPlaceEvent event){ Player player = event.getPlayer(); TileTesseract blockMeta = (TileTesseract) player.getItemInHand().getItemMeta(); if(event.getBlockPlaced() != null) { }
@EventHandler public void onBlockPlaceEvent(BlockPlaceEvent event){ Player player = event.getPlayer(); TileTesseract blockMeta = (TileTesseract) player.getItemInHand().getItemMeta(); if(event.getBlockPlaced() != null) { } Is this good? so far
I know i should be studying the basics which i will after but i need to get this done thank you guys for putting up with me
I actually would just get the block, I don't think you need to get the player's hand, do a check if it is a tesseract or aluminum wire, then get the blocks around it and check if it's the opposit placed block, if it is, cancel the event.
If you can't figure out what he said just google it. There is no more help we can give you besides coding it for you.