Java programming minecraft block condition?

Ha
7

I already programmed that you can't add a banner anywhere.

But how do I add an exception in the event?

@EventHandler (priority = EventPriority.HIGHEST)

public void onBanner (BlockPlaceEvent event3) {

Player p2 = event3.getPlayer ();

(! P2.hasPermission ( "nostanding_banner.bypass")) if;

Block block = event3.getBlockPlaced ();

if (block.getType () == material.STANDING_BANNER) {

event3.setCancelled (true);

p2.sendMessage (ChatColor.RED + "lalalalal!");

Ro

An exception in which case?

Ha

Well, the exception is that the banner can be placed on bedrock. But not elsewhere

Ro

I can't give it a try, but check the position of the banner and set the Y position -1 to the position of the banner. If this position consists of bedrock, allow the event if not cancel it.

Ha

Thanks for the answer! I'm still relatively new to Java but I will try my best, but thank you!

Ro

No problem, I hope it was understandable and works.

St

First of all, this line does not matter at all:

(! P2.hasPermission ( "nostanding_banner.bypass")) if;

For the condition you should do this:

if (block.getType () == material.STANDING_BANNER) {
event3.setCancelled (true);
p2.sendMessage (ChatColor.RED + "lalalalal!");
}

replace with:

if (block.getType () == material.STANDING_BANNER) {
Block blockBelow = block.getWorld (). GetBlockAt (block.getX (), block.getY () - 1, block.getZ ());

if (blockBelow.getType () == Material.BEDROCK) {
event3.setCancelled (true);
p2.sendMessage (ChatColor.RED + "lalalalal!");
}
}

I did not test that, so there might be a small bug left inside. The nesting is not necessary in principle, but is a bit faster than without.

You should, however, deal more intensively with Java before you start with Spigot. Spigot is not for beginners.

Ha

Thanks a lot, yes, I'm aware of that, but it is better than wasting your time playing games like league of legends