Update NMS & Effects
This commit is contained in:
parent
e1cf108ab2
commit
03c8755067
@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'me.skymc'
|
||||
version = '5.16'
|
||||
version = '5.17'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
@ -10,7 +10,7 @@ import java.util.Arrays;
|
||||
*/
|
||||
public enum Version {
|
||||
|
||||
v1_7(10700), v1_8(10800), v1_9(10900), v1_10(11000), v1_11(11100), v1_12(11200), v1_13(11300), v1_14(11400), v1_15(11500), vNull(0);
|
||||
v1_7(10700), v1_8(10800), v1_9(10900), v1_10(11000), v1_11(11100), v1_12(11200), v1_13(11300), v1_14(11400), v1_15(11500), v1_16(11600), vNull(0);
|
||||
|
||||
private int versionInt;
|
||||
|
||||
|
@ -7,11 +7,14 @@ import io.izzel.taboolib.module.nms.nbt.Attribute;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTAttribute;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTCompound;
|
||||
import io.izzel.taboolib.module.nms.nbt.NBTList;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@ -78,4 +81,8 @@ public abstract class NMS {
|
||||
abstract public Position fromBlockPosition(Object blockPosition);
|
||||
|
||||
abstract public void openSignEditor(Player player, Block block);
|
||||
|
||||
abstract public boolean inBoundingBox(Entity entity, Vector vector);
|
||||
|
||||
abstract public Location getLastLocation(ProjectileHitEvent event);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.server.v1_13_R2.IRegistry;
|
||||
import net.minecraft.server.v1_8_R3.NBTBase;
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -28,8 +29,10 @@ import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
@ -404,4 +407,43 @@ public class NMSImpl extends NMS {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBoundingBox(Entity entity, Vector vector) {
|
||||
if (Version.isAfter(Version.v1_14)) {
|
||||
return ((org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity) entity).getHandle().getBoundingBox().c(new net.minecraft.server.v1_14_R1.Vec3D(vector.getX(), vector.getY(), vector.getZ()));
|
||||
} else {
|
||||
return ((org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) entity).getHandle().getBoundingBox().b(new net.minecraft.server.v1_12_R1.Vec3D(vector.getX(), vector.getY(), vector.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastLocation(ProjectileHitEvent event) {
|
||||
Vector vector = event.getEntity().getVelocity().normalize().multiply(0.1);
|
||||
Vector vectorEntity = event.getEntity().getLocation().toVector();
|
||||
if (event.getHitBlock() != null) {
|
||||
double i = 0;
|
||||
double length = event.getHitBlock().getLocation().add(0.5, 0.5, 0.5).distance(event.getEntity().getLocation()) * 2;
|
||||
while (i < length) {
|
||||
Location location = vectorEntity.toLocation(event.getHitBlock().getWorld());
|
||||
if (location.getBlock().getLocation().equals(event.getHitBlock().getLocation())) {
|
||||
return location;
|
||||
}
|
||||
vectorEntity.add(vector);
|
||||
i += 0.1;
|
||||
}
|
||||
}
|
||||
if (event.getHitEntity() != null) {
|
||||
double i = 0;
|
||||
double length = event.getHitEntity().getLocation().distance(event.getEntity().getLocation()) * 2;
|
||||
while (i < length) {
|
||||
if (inBoundingBox(event.getHitEntity(), vectorEntity)) {
|
||||
return vectorEntity.toLocation(event.getHitEntity().getWorld());
|
||||
}
|
||||
vectorEntity.add(vector);
|
||||
i += 0.1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @Author sky
|
||||
@ -81,6 +83,28 @@ public class Effects {
|
||||
return Particle.FLAME;
|
||||
}
|
||||
|
||||
public static void buildLine(Location locA, Location locB, Consumer<Location> action) {
|
||||
buildLine(locA, locB, action, 0.25);
|
||||
}
|
||||
|
||||
public static void buildLine(Location locA, Location locB, Consumer<Location> action, double interval) {
|
||||
Vector vectorAB = locB.clone().subtract(locA).toVector();
|
||||
double vectorLength = vectorAB.length();
|
||||
vectorAB.normalize();
|
||||
for (double i = 0; i < vectorLength; i += interval) {
|
||||
action.accept(locA.clone().add(vectorAB.clone().multiply(i)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void buildPolygon(Location center, double range, double interval, Consumer<Location> action) {
|
||||
for (double i = 0; i < 360; i += (360 / interval)) {
|
||||
double radians = Math.toRadians(i);
|
||||
double cos = Math.cos(radians) * range;
|
||||
double sin = Math.sin(radians) * range;
|
||||
action.accept(center.clone().add(cos, 0, sin));
|
||||
}
|
||||
}
|
||||
|
||||
Effects() {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user