hell setblock
This commit is contained in:
parent
c44b286d87
commit
c4e4db9677
1 changed files with 10 additions and 21 deletions
|
|
@ -14,8 +14,6 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import static org.bukkit.Bukkit.getWorld;
|
|
||||||
|
|
||||||
public class Bbsdfia extends JavaPlugin implements Listener {
|
public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
private final Vector velocity1 = new Vector(0, 0.5, -1);
|
private final Vector velocity1 = new Vector(0, 0.5, -1);
|
||||||
private final Vector velocity2 = new Vector(-1, 0.5, 0);
|
private final Vector velocity2 = new Vector(-1, 0.5, 0);
|
||||||
|
|
@ -24,42 +22,37 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
private final Vector[] velocities = { velocity1, velocity2, velocity3, velocity4 };
|
private final Vector[] velocities = { velocity1, velocity2, velocity3, velocity4 };
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
|
|
||||||
|
private final Location locationplus = new Location(Bukkit.getWorld("world_the_end"), 100, 49, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
getServer().getLogger().info("Bbsdfia plugin started");
|
getServer().getLogger().info("Bbsdfia plugin started");
|
||||||
|
locationplus.getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
getServer().getLogger().info("Bbsdfia plugin stopped");
|
getServer().getLogger().info("Bbsdfia plugin stopped");
|
||||||
}
|
locationplus.getBlock().setType(Material.AIR);
|
||||||
public void setBlockInEndDimension(Location location) {
|
|
||||||
if (!location.getWorld().getEnvironment().equals(World.Environment.THE_END)) {
|
|
||||||
// The location is not in the End dimension
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Block block = location.getBlock();
|
|
||||||
if (block.getType() != Material.AIR) {
|
|
||||||
// The block is not already air
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||||
if(e.getEntityType() == EntityType.FALLING_BLOCK){
|
if(e.getEntityType() == EntityType.FALLING_BLOCK){
|
||||||
|
|
||||||
Entity entity = e.getEntity();
|
Entity entity = e.getEntity();
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
Vector vel = entity.getVelocity();
|
Vector vel = entity.getVelocity();
|
||||||
Block movingTo = getBlockMovingTo(loc, vel);
|
Block movingTo = getBlockMovingTo(loc, vel);
|
||||||
|
|
||||||
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
||||||
|
locationplus.getBlock().setType(Material.AIR);
|
||||||
Location spawnLoc = movingTo.getLocation();
|
Location spawnLoc = movingTo.getLocation();
|
||||||
spawnLoc.setX(spawnLoc.getX()+0.5);
|
spawnLoc.setX(spawnLoc.getX()+0.5);
|
||||||
spawnLoc.setY(spawnLoc.getY()+0.5);
|
spawnLoc.setY(spawnLoc.getY()+0.5);
|
||||||
|
|
@ -73,11 +66,6 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
dummyVel.add(new Vector(0, -0.2, 0));
|
dummyVel.add(new Vector(0, -0.2, 0));
|
||||||
|
|
||||||
dummy.setVelocity(dummyVel);
|
dummy.setVelocity(dummyVel);
|
||||||
Location location = new Location(getWorld("world_the_end"), 100, 49, 0);
|
|
||||||
|
|
||||||
String commandString = String.format("/execute in minecraft:the_end run setblock %d %d %d air", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), commandString));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,9 +74,11 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (!(entity instanceof FallingBlock)) {
|
if (!(entity instanceof FallingBlock)) {
|
||||||
|
locationplus.getBlock().setType(Material.AIR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
|
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
|
||||||
|
locationplus.getBlock().setType(Material.AIR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,8 +88,7 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
||||||
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
||||||
Location locationblock = new Location(world, 100,49 ,0);
|
locationplus.getBlock().setType(Material.AIR);
|
||||||
setBlockInEndDimension(locationblock);
|
|
||||||
|
|
||||||
int index = counter % 4;
|
int index = counter % 4;
|
||||||
Vector velocity = velocities[index];
|
Vector velocity = velocities[index];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue