fix mismatch
This commit is contained in:
parent
c0df25a8fd
commit
01fd6c0159
1 changed files with 9 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
|
@ -19,6 +20,8 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
// Get a reference to the world_the_end world
|
||||
|
||||
// Register the plugin to listen to events
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
// Log that the plugin has started
|
||||
|
|
@ -42,28 +45,26 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
// Get the entity and its location and velocity
|
||||
Entity entity = e.getEntity();
|
||||
Location loc = entity.getLocation();
|
||||
Location spawnlocation = new Location(Bukkit.getWorld("world_the_end"), 100, 50, 0);
|
||||
Vector vel = entity.getVelocity();
|
||||
|
||||
// Spawn loocation for new falling block
|
||||
Location spawnlocation = new Location(Bukkit.getWorld("world_the_end"), 100, 50, 0);
|
||||
// Get a reference to the world_the_end world
|
||||
World endWorld = Bukkit.getWorld("world_the_end");
|
||||
// Get the block that the entity is moving towards
|
||||
Block movingTo = getBlockMovingTo(loc, vel);
|
||||
|
||||
// If the block it's moving towards is an end portal block
|
||||
if (movingTo != null && movingTo.getType() == Material.END_PORTAL) {
|
||||
|
||||
// Spawn a new falling block entity at the center of the end portal block
|
||||
FallingBlock dummy = Bukkit.getServer().getWorld("world_the_end").spawnFallingBlock(spawnlocation, ((FallingBlock) entity).getBlockData());
|
||||
// Spawn a new falling block entity in the end with the same material and block type as the old one
|
||||
FallingBlock dummy = endWorld.spawnFallingBlock(spawnlocation, movingTo.getBlockData());
|
||||
|
||||
// Copy the velocity of the original entity and invert the y component
|
||||
Vector dummyVel = vel.clone();
|
||||
dummyVel.setY(-dummyVel.getY());
|
||||
|
||||
// Double the velocity of the new entity
|
||||
dummyVel.multiply(new Vector(2, 2, 2));
|
||||
|
||||
// Add a constant upward velocity to simulate gravity
|
||||
dummyVel.add(new Vector(0, 0.3, 0));
|
||||
|
||||
// Set the velocity of the new entity to the modified velocity
|
||||
dummy.setVelocity(dummyVel);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue