delay
This commit is contained in:
parent
45b9568dd0
commit
5f1597d5d1
1 changed files with 97 additions and 3 deletions
|
|
@ -38,7 +38,7 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
/*@EventHandler
|
||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||
if(e.getEntityType() == EntityType.FALLING_BLOCK){
|
||||
Entity entity = e.getEntity();
|
||||
|
|
@ -62,22 +62,65 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
dummy.setVelocity(dummyVel);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||
if(e.getEntityType() == EntityType.FALLING_BLOCK){
|
||||
Entity entity = e.getEntity();
|
||||
Location loc = entity.getLocation();
|
||||
Vector vel = entity.getVelocity();
|
||||
Block movingTo = getBlockMovingTo(loc, vel);
|
||||
|
||||
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
|
||||
Location spawnLoc = movingTo.getLocation();
|
||||
spawnLoc.setX(spawnLoc.getX()+0.5);
|
||||
spawnLoc.setY(spawnLoc.getY()+0.5);
|
||||
spawnLoc.setZ(spawnLoc.getZ()+0.5);
|
||||
|
||||
// Spawn the first falling block immediately
|
||||
FallingBlock firstBlock = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
||||
Vector dummyVel = vel.clone();
|
||||
dummyVel.setY(-dummyVel.getY());
|
||||
dummyVel.multiply(new Vector(2, 2, 2));
|
||||
dummyVel.add(new Vector(0, -0.2, 0));
|
||||
firstBlock.setVelocity(dummyVel);
|
||||
|
||||
// Schedule the spawning of the other two falling blocks with a delay
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
for(int i = 0; i < 2; i++){
|
||||
Location spawnLoc1 = movingTo.getLocation();
|
||||
spawnLoc1.setX(spawnLoc1.getX()+0.5);
|
||||
spawnLoc1.setY(spawnLoc1.getY()+0.5);
|
||||
spawnLoc1.setZ(spawnLoc1.getZ()+0.5);
|
||||
|
||||
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc1, ((FallingBlock) entity).getBlockData());
|
||||
Vector dummyVel1 = vel.clone();
|
||||
dummyVel1.setY(-dummyVel1.getY());
|
||||
dummyVel1.multiply(new Vector(2, 2, 2));
|
||||
dummyVel1.add(new Vector(0, -0.2, 0));
|
||||
dummy.setVelocity(dummyVel1);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof FallingBlock)) {
|
||||
entity.remove();
|
||||
return;
|
||||
}
|
||||
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
|
||||
entity.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn a new falling block entity with velocity
|
||||
|
||||
entity.remove();
|
||||
Location fuck = new Location(Bukkit.getWorld("world_the_end"), 100, 49 ,0);
|
||||
fuck.getBlock().setType(Material.AIR);
|
||||
World world = entity.getWorld();
|
||||
Location location = entity.getLocation();
|
||||
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
||||
|
|
@ -89,7 +132,58 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
|
||||
FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data);
|
||||
newFallingBlock.setVelocity(velocity);
|
||||
}
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock2(EntityChangeBlockEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof FallingBlock)) {
|
||||
return;
|
||||
}
|
||||
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn a new falling block entity with velocity
|
||||
entity.remove();
|
||||
Location fuck = new Location(Bukkit.getWorld("world_the_end"), 100, 49 ,0);
|
||||
fuck.getBlock().setType(Material.AIR);
|
||||
World world = entity.getWorld();
|
||||
Location location = entity.getLocation();
|
||||
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
||||
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
||||
|
||||
int index = counter % 4;
|
||||
Vector velocity = velocities[index];
|
||||
counter++;
|
||||
|
||||
FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data);
|
||||
newFallingBlock.setVelocity(velocity);
|
||||
}
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock1(EntityChangeBlockEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (!(entity instanceof FallingBlock)) {
|
||||
return;
|
||||
}
|
||||
if (entity.getWorld().getEnvironment() != World.Environment.THE_END) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn a new falling block entity with velocity
|
||||
entity.remove();
|
||||
Location fuck = new Location(Bukkit.getWorld("world_the_end"), 100, 49 ,0);
|
||||
fuck.getBlock().setType(Material.AIR);
|
||||
World world = entity.getWorld();
|
||||
Location location = entity.getLocation();
|
||||
byte data = ((FallingBlock) entity).getBlockData().getAsString().getBytes()[0];
|
||||
Material material = ((FallingBlock) entity).getBlockData().getMaterial();
|
||||
|
||||
int index = counter % 4;
|
||||
Vector velocity = velocities[index];
|
||||
counter++;
|
||||
|
||||
FallingBlock newFallingBlock = world.spawnFallingBlock(location, material, data);
|
||||
newFallingBlock.setVelocity(velocity);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue