13
0

Half arrow implementation

Dieser Commit ist enthalten in:
Lixfel 2020-09-03 20:34:37 +02:00
Ursprung 28903eebe3
Commit 854dd81e65
4 geänderte Dateien mit 26 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.spectatesystem.elements;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -10,6 +11,8 @@ import java.util.Map;
public abstract class REntity {
protected static final WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
private static Map<Integer, REntity> entities = new HashMap<>();
private final int internalId;

Datei anzeigen

@ -5,7 +5,6 @@ import com.mojang.authlib.properties.Property;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
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.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -41,7 +40,6 @@ public class RPlayer extends REntity {
private static EntityPlayer createPlayer(UUID uuid, String name){
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.
try {
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");
}
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);
return npc;
}

Datei anzeigen

@ -1,14 +1,11 @@
package de.steamwar.spectatesystem.elements;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import net.minecraft.server.v1_15_R1.EntityTNTPrimed;
import net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_15_R1.PlayerConnection;
public class RTnT extends REntity {
private static World world = null;
public RTnT(int internalId) {
super(internalId, createTnT());
}
@ -19,10 +16,6 @@ public class RTnT extends REntity {
}
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);
}