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