Half arrow implementation
Dieser Commit ist enthalten in:
Ursprung
28903eebe3
Commit
854dd81e65
19
src/de/steamwar/spectatesystem/elements/RArrow.java
Normale Datei
19
src/de/steamwar/spectatesystem/elements/RArrow.java
Normale Datei
@ -0,0 +1,19 @@
|
|||||||
|
package de.steamwar.spectatesystem.elements;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
|
|
||||||
|
public class RArrow extends REntity {
|
||||||
|
|
||||||
|
public RArrow(int internalId) {
|
||||||
|
super(internalId, createArrow());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void spawnEntity(PlayerConnection connection) {
|
||||||
|
connection.sendPacket(new PacketPlayOutSpawnEntity(entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static EntityTippedArrow createArrow() {
|
||||||
|
return new EntityTippedArrow(world, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package de.steamwar.spectatesystem.elements;
|
|||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public abstract class REntity {
|
public abstract class REntity {
|
||||||
|
|
||||||
|
protected static final WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||||
|
|
||||||
private static Map<Integer, REntity> entities = new HashMap<>();
|
private static Map<Integer, REntity> entities = new HashMap<>();
|
||||||
|
|
||||||
private final int internalId;
|
private final int internalId;
|
||||||
|
@ -5,7 +5,6 @@ import com.mojang.authlib.properties.Property;
|
|||||||
import net.minecraft.server.v1_15_R1.*;
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.enchantments.CraftEnchantment;
|
import org.bukkit.craftbukkit.v1_15_R1.enchantments.CraftEnchantment;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -41,7 +40,6 @@ public class RPlayer extends REntity {
|
|||||||
|
|
||||||
private static EntityPlayer createPlayer(UUID uuid, String name){
|
private static EntityPlayer createPlayer(UUID uuid, String name){
|
||||||
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
|
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
WorldServer nmsWorld = ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle(); // Change "world" to the world the NPC should be spawned in.
|
|
||||||
GameProfile gameProfile = new GameProfile(uuid, name); // Change "playername" to the name the NPC should have, max 16 characters.
|
GameProfile gameProfile = new GameProfile(uuid, name); // Change "playername" to the name the NPC should have, max 16 characters.
|
||||||
try {
|
try {
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(String.format("https://api.ashcon.app/mojang/v2/user/%s", name)).openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) new URL(String.format("https://api.ashcon.app/mojang/v2/user/%s", name)).openConnection();
|
||||||
@ -64,7 +62,7 @@ public class RPlayer extends REntity {
|
|||||||
Bukkit.getLogger().log(Level.SEVERE, "Player skin could not be fetched");
|
Bukkit.getLogger().log(Level.SEVERE, "Player skin could not be fetched");
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile, new PlayerInteractManager(nmsWorld)); // This will be the EntityPlayer (NPC) we send with the sendNPCPacket method.
|
EntityPlayer npc = new EntityPlayer(nmsServer, world, gameProfile, new PlayerInteractManager(world)); // This will be the EntityPlayer (NPC) we send with the sendNPCPacket method.
|
||||||
npc.getDataWatcher().set(new DataWatcherObject<>(15, DataWatcherRegistry.a), (byte)127);
|
npc.getDataWatcher().set(new DataWatcherObject<>(15, DataWatcherRegistry.a), (byte)127);
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package de.steamwar.spectatesystem.elements;
|
package de.steamwar.spectatesystem.elements;
|
||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
import net.minecraft.server.v1_15_R1.EntityTNTPrimed;
|
||||||
import org.bukkit.Bukkit;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
import net.minecraft.server.v1_15_R1.PlayerConnection;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|
||||||
|
|
||||||
public class RTnT extends REntity {
|
public class RTnT extends REntity {
|
||||||
|
|
||||||
private static World world = null;
|
|
||||||
|
|
||||||
public RTnT(int internalId) {
|
public RTnT(int internalId) {
|
||||||
super(internalId, createTnT());
|
super(internalId, createTnT());
|
||||||
}
|
}
|
||||||
@ -19,10 +16,6 @@ public class RTnT extends REntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static EntityTNTPrimed createTnT() {
|
private static EntityTNTPrimed createTnT() {
|
||||||
if (world == null) {
|
|
||||||
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
|
|
||||||
world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
|
||||||
}
|
|
||||||
return new EntityTNTPrimed(world, 0, 0, 0, null);
|
return new EntityTNTPrimed(world, 0, 0, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren