Search in sources :

Example 6 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project BedWars1058 by andrei1058.

the class v1_15_R1 method registerTntWhitelist.

@Override
public void registerTntWhitelist() {
    try {
        Field field = net.minecraft.server.v1_15_R1.Block.class.getDeclaredField("durability");
        field.setAccessible(true);
        field.set(Blocks.END_STONE, 12f);
        field.set(Blocks.GLASS, 300f);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1)

Example 7 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method reloadLocation.

@Override
public void reloadLocation() {
    if (displayEntity.getPassenger() != null) {
        net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
        Location loc;
        if (this.displayRider != null) {
            if (this.displayRider.getType().equals(EntityType.SHULKER)) {
                loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
            } else {
                loc = getBukkitEntity().getLocation().clone();
            }
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
        displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
        loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
            if (entity instanceof Player) {
                Player player = (Player) entity;
                PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
                ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
            }
        });
        return;
    }
    net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
    Location loc;
    if (this.displayRider != null) {
        if (this.displayRider.getType().equals(EntityType.SHULKER)) {
            loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
    } else {
        loc = getBukkitEntity().getLocation().clone();
    }
    displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
        if (entity instanceof Player) {
            Player player = (Player) entity;
            PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
        }
    });
}
Also used : net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) Location(org.bukkit.Location)

Example 8 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project SilkSpawners by timbru31.

the class NMSHandler method setNBTEntityID.

@Override
public ItemStack setNBTEntityID(final ItemStack item, final String entity) {
    if (item == null || StringUtils.isBlank(entity)) {
        Bukkit.getLogger().warning("[SilkSpawners] Skipping invalid spawner to set NBT data on.");
        return null;
    }
    String prefixedEntity;
    if (!entity.startsWith("minecraft:")) {
        prefixedEntity = "minecraft:" + entity;
    } else {
        prefixedEntity = entity;
    }
    net.minecraft.server.v1_15_R1.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getOrCreateTag();
    // Check for SilkSpawners key
    if (!tag.hasKey("SilkSpawners")) {
        tag.set("SilkSpawners", new NBTTagCompound());
    }
    tag.getCompound("SilkSpawners").setString("entity", entity);
    // Check for Vanilla keys
    if (!tag.hasKey("BlockEntityTag")) {
        tag.set("BlockEntityTag", new NBTTagCompound());
    }
    tag = tag.getCompound("BlockEntityTag");
    // EntityId - Deprecated in 1.9
    tag.setString("EntityId", entity);
    tag.setString("id", TileEntityTypes.a(TileEntityTypes.MOB_SPAWNER).getKey());
    // SpawnData
    if (!tag.hasKey("SpawnData")) {
        tag.set("SpawnData", new NBTTagCompound());
    }
    tag.getCompound("SpawnData").setString("id", prefixedEntity);
    if (!tag.hasKey("SpawnPotentials")) {
        tag.set("SpawnPotentials", new NBTTagCompound());
    }
    // SpawnEgg data
    if (!tag.hasKey("EntityTag")) {
        tag.set("EntityTag", new NBTTagCompound());
    }
    tag.getCompound("EntityTag").setString("id", prefixedEntity);
    return CraftItemStack.asCraftMirror(itemStack);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound)

Example 9 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project SilkSpawners by timbru31.

the class NMSHandler method getVanillaNBTEntityID.

@Override
@Nullable
public String getVanillaNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_15_R1.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("BlockEntityTag")) {
        return null;
    }
    tag = tag.getCompound("BlockEntityTag");
    if (tag.hasKey("EntityId")) {
        return tag.getString("EntityId");
    } else if (tag.hasKey("SpawnData") && tag.getCompound("SpawnData").hasKey("id")) {
        return tag.getCompound("SpawnData").getString("id");
    } else if (tag.hasKey("SpawnPotentials") && !tag.getList("SpawnPotentials", 8).isEmpty()) {
        return tag.getList("SpawnPotentials", 8).getCompound(0).getCompound("Entity").getString("id");
    } else {
        return null;
    }
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) Nullable(javax.annotation.Nullable)

Example 10 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project SilkSpawners by timbru31.

the class NMSHandler method getSilkSpawnersNBTEntityID.

@Override
@Nullable
public String getSilkSpawnersNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_15_R1.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    final NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("SilkSpawners")) {
        return null;
    }
    return tag.getCompound("SilkSpawners").getString("entity");
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) Nullable(javax.annotation.Nullable)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack)10 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)9 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)7 ItemStack (org.bukkit.inventory.ItemStack)7 net.minecraft.server.v1_15_R1 (net.minecraft.server.v1_15_R1)5 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)5 CraftChunk (org.bukkit.craftbukkit.v1_15_R1.CraftChunk)5 Container (net.minecraft.server.v1_15_R1.Container)3 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)3 Player (org.bukkit.entity.Player)3 UUID (java.util.UUID)2 Nullable (javax.annotation.Nullable)2 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)2 ChunkSection (net.minecraft.server.v1_15_R1.ChunkSection)2 ContainerAnvil (net.minecraft.server.v1_15_R1.ContainerAnvil)2 EntityLiving (net.minecraft.server.v1_15_R1.EntityLiving)2 Chunk (org.bukkit.Chunk)2 Location (org.bukkit.Location)2 CraftEntity (org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity)2 CraftContainer (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftContainer)2