1
L()()K HERE PLZ HELP <------<<<<<<---------<<<<<<
I just started programming a few days ago I finally sat down and tried to learn, so I watched a few youtube tutorials and tried to follow what they were doing. I tried to replicate what one guy did, but I modified it and changed what happened. I wanted it so when you click a block with a stick the block flys up in the air as a fallingsand entity and comes back down. however when I click on a block it just disappears. I believe this is an error with the fallingsand failing to spawn, because the block does disapear like its supposed to. heres my code for the class with all of the important stuff, the main class just has like onEnable crap:
package me.benhallihan.blockjump;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
public class Blockjump implements Listener{
@EventHandler
public void onRightCLick(PlayerInteractEvent event){
Player player = event.getPlayer();
Action a = event.getAction();
if(a.equals(Action.RIGHT_CLICK_BLOCK)) {
Block block = event.getClickedBlock();
Material m = player.getItemInHand().getType();
if (m == Material.STICK){
block.setType(Material.AIR);
@SuppressWarnings("deprecation")
FallingBlock fall = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
Vector veloc = fall.getVelocity();
veloc.setY(veloc.getY() + 2);
fall.setVelocity(veloc);
block.setType(Material.AIR);
}
}
}
}
Im not sure what I did wrong or if the server is maybe blocking fallingsand, however i ran it on my test server which just has a few basic plugins like world edit, essentials and world guard, and I didn't even make any regions with world guard so i doubt it was that, but I just need to know what I need to do to make blocks fly up in the air when clicked with a stick
package me.benhallihan.blockjump;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
public class Blockjump implements Listener{
@EventHandler
public void onRightCLick(PlayerInteractEvent event){
Player player = event.getPlayer();
Action a = event.getAction();
if(a.equals(Action.RIGHT_CLICK_BLOCK)) {
Block block = event.getClickedBlock();
Material m = player.getItemInHand().getType();
if (m == Material.STICK){
block.setType(Material.AIR);
@SuppressWarnings("deprecation")
FallingBlock fall = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
Vector veloc = fall.getVelocity();
veloc.setY(veloc.getY() + 2);
fall.setVelocity(veloc);
block.setType(Material.AIR);
}
}
}
}
Im not sure what I did wrong or if the server is maybe blocking fallingsand, however i ran it on my test server which just has a few basic plugins like world edit, essentials and world guard, and I didn't even make any regions with world guard so i doubt it was that, but I just need to know what I need to do to make blocks fly up in the air when clicked with a stick
4
Moved to Minecraft Help.
Don't bump the post constantly, someone will reply either way.
Don't bump the post constantly, someone will reply either way.
anybody know?!
k :/
IDK. Watch his tutorial again and try to figure out what you did wrong, you may have left something out. I don't know the first thing about coding, so I can't really help you much more than that. I hope you fix your problem soon.
