ah
This commit is contained in:
parent
81154f266f
commit
b480c3640b
1 changed files with 13 additions and 28 deletions
|
|
@ -1,8 +1,8 @@
|
|||
package xyz.hynse.bbsdfia;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
|
@ -10,16 +10,10 @@ import org.bukkit.entity.FallingBlock;
|
|||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Bbsdfia extends JavaPlugin implements Listener {
|
||||
private final Map<Entity, Vector> teleportedFallingBlocks = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
|
|
@ -40,32 +34,23 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
Location loc = entity.getLocation();
|
||||
Vector vel = entity.getVelocity();
|
||||
Block movingTo = getBlockMovingTo(loc, vel);
|
||||
Location loc2 = new Location(Bukkit.getWorld("world_the_end"), 100, 50, 0);
|
||||
|
||||
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);
|
||||
/*
|
||||
World world = Bukkit.getServer().getWorld("world");
|
||||
Location spawnLoc = new Location(world, 100, 50, 0);
|
||||
*/
|
||||
|
||||
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
||||
FallingBlock dummy = loc2.getWorld().spawnFallingBlock(loc2, ((FallingBlock) entity).getBlockData());
|
||||
Vector dummyVel = vel.clone();
|
||||
dummyVel.setY(-dummyVel.getY());
|
||||
dummyVel.multiply(new Vector(2, 2, 2)); // double the velocity
|
||||
|
||||
// Store the velocity of the falling block entity
|
||||
teleportedFallingBlocks.put(dummy, vel.clone());
|
||||
// add a constant downward velocity to simulate gravity
|
||||
dummyVel.add(new Vector(0, 0.3, 0));
|
||||
|
||||
// Set the velocity of the dummy entity to 0 to prevent it from moving
|
||||
dummy.setVelocity(new Vector(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityTeleport(EntityTeleportEvent e) {
|
||||
Entity entity = e.getEntity();
|
||||
if (entity.getType() == EntityType.FALLING_BLOCK && e.getTo().getWorld().getEnvironment() == World.Environment.THE_END) {
|
||||
// Check if the falling block entity has been teleported through the end portal
|
||||
if (teleportedFallingBlocks.containsKey(entity)) {
|
||||
Vector vel = teleportedFallingBlocks.remove(entity);
|
||||
entity.setVelocity(vel);
|
||||
dummy.setVelocity(dummyVel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue