Search in sources :

Example 1 with Spider

use of net.minecraft.world.entity.monster.Spider in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method setVision.

@Override
public void setVision(Player player, EntityType entityType) {
    final net.minecraft.world.entity.LivingEntity entity;
    if (entityType == EntityType.CREEPER) {
        entity = new Creeper(net.minecraft.world.entity.EntityType.CREEPER, ((CraftWorld) player.getWorld()).getHandle());
    } else if (entityType == EntityType.SPIDER) {
        entity = new Spider(net.minecraft.world.entity.EntityType.SPIDER, ((CraftWorld) player.getWorld()).getHandle());
    } else if (entityType == EntityType.CAVE_SPIDER) {
        entity = new CaveSpider(net.minecraft.world.entity.EntityType.CAVE_SPIDER, ((CraftWorld) player.getWorld()).getHandle());
    } else if (entityType == EntityType.ENDERMAN) {
        entity = new EnderMan(net.minecraft.world.entity.EntityType.ENDERMAN, ((CraftWorld) player.getWorld()).getHandle());
    } else {
        return;
    }
    // Spectating an entity then immediately respawning the player prevents a client shader update,
    // allowing the player to retain whatever vision the mob they spectated had.
    send(player, new ClientboundAddMobPacket(entity));
    send(player, new ClientboundSetCameraPacket(entity));
    ((CraftServer) Bukkit.getServer()).getHandle().moveToWorld(((CraftPlayer) player).getHandle(), ((CraftWorld) player.getWorld()).getHandle(), true, player.getLocation(), false);
}
Also used : EnderMan(net.minecraft.world.entity.monster.EnderMan) Creeper(net.minecraft.world.entity.monster.Creeper) CaveSpider(net.minecraft.world.entity.monster.CaveSpider) Spider(net.minecraft.world.entity.monster.Spider) CaveSpider(net.minecraft.world.entity.monster.CaveSpider) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 2 with Spider

use of net.minecraft.world.entity.monster.Spider in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method setVision.

@Override
public void setVision(Player player, EntityType entityType) {
    final net.minecraft.world.entity.LivingEntity entity;
    if (entityType == EntityType.CREEPER) {
        entity = new Creeper(net.minecraft.world.entity.EntityType.CREEPER, ((CraftWorld) player.getWorld()).getHandle());
    } else if (entityType == EntityType.SPIDER) {
        entity = new Spider(net.minecraft.world.entity.EntityType.SPIDER, ((CraftWorld) player.getWorld()).getHandle());
    } else if (entityType == EntityType.CAVE_SPIDER) {
        entity = new CaveSpider(net.minecraft.world.entity.EntityType.CAVE_SPIDER, ((CraftWorld) player.getWorld()).getHandle());
    } else if (entityType == EntityType.ENDERMAN) {
        entity = new EnderMan(net.minecraft.world.entity.EntityType.ENDERMAN, ((CraftWorld) player.getWorld()).getHandle());
    } else {
        return;
    }
    // Spectating an entity then immediately respawning the player prevents a client shader update,
    // allowing the player to retain whatever vision the mob they spectated had.
    send(player, new ClientboundAddMobPacket(entity));
    send(player, new ClientboundSetCameraPacket(entity));
    ((CraftServer) Bukkit.getServer()).getHandle().respawn(((CraftPlayer) player).getHandle(), ((CraftWorld) player.getWorld()).getHandle(), true, player.getLocation(), false);
}
Also used : EnderMan(net.minecraft.world.entity.monster.EnderMan) Creeper(net.minecraft.world.entity.monster.Creeper) CaveSpider(net.minecraft.world.entity.monster.CaveSpider) Spider(net.minecraft.world.entity.monster.Spider) CaveSpider(net.minecraft.world.entity.monster.CaveSpider) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Aggregations

CaveSpider (net.minecraft.world.entity.monster.CaveSpider)2 Creeper (net.minecraft.world.entity.monster.Creeper)2 EnderMan (net.minecraft.world.entity.monster.EnderMan)2 Spider (net.minecraft.world.entity.monster.Spider)2 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1