use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.
the class V1_17EntityAccessor method createFakeEntity.
@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
Preconditions.checkNotNull(entityType, "entity type can't be null!");
Preconditions.checkNotNull(location, "location can't be null!");
Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
CraftWorld world = ((CraftWorld) location.getWorld());
if (world == null) {
throw new IllegalStateException("location's world is null!");
}
net.minecraft.world.entity.Entity entity = world.createEntity(location, entityType.getEntityClass());
Packet<?> spawnEntityPacket;
if (entity instanceof EntityLiving) {
spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
} else {
spawnEntityPacket = new PacketPlayOutSpawnEntity(entity);
}
return new FakeEntity(entity.getId(), spawnEntityPacket);
}
use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.
the class V1_10R1EntityAccessor method createFakeEntity.
@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
Preconditions.checkNotNull(entityType, "entity type can't be null!");
Preconditions.checkNotNull(location, "location can't be null!");
Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
CraftWorld world = ((CraftWorld) location.getWorld());
if (world == null) {
throw new IllegalStateException("location's world is null!");
}
Entity entity = world.createEntity(location, entityType.getEntityClass());
Packet<?> spawnEntityPacket;
if (entity instanceof EntityLiving) {
spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
} else {
spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
}
return new FakeEntity(entity.getId(), spawnEntityPacket);
}
use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.
the class V1_18EntityAccessor method createFakeEntity.
@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
Preconditions.checkNotNull(entityType, "entity type can't be null!");
Preconditions.checkNotNull(location, "location can't be null!");
Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
CraftWorld world = ((CraftWorld) location.getWorld());
if (world == null) {
throw new IllegalStateException("location's world is null!");
}
net.minecraft.world.entity.Entity entity = world.createEntity(location, entityType.getEntityClass());
Packet<?> spawnEntityPacket;
if (entity instanceof EntityLiving) {
spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
} else {
spawnEntityPacket = new PacketPlayOutSpawnEntity(entity);
}
// ae() zwraca aT czyli chyba getId
return new FakeEntity(entity.ae(), spawnEntityPacket);
}
use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.
the class WarAttackRequest method execute.
@Override
public void execute() throws Exception {
for (Map.Entry<Guild, FakeEntity> entry : GuildEntityHelper.getGuildEntities().entrySet()) {
if (entry.getValue().getId() != entityId) {
continue;
}
Guild guild = entry.getKey();
Option<Player> playerOption = this.user.getPlayer();
if (playerOption.isEmpty()) {
return;
}
Player player = playerOption.get();
if (SecuritySystem.onHitCrystal(player, guild)) {
return;
}
if (!SimpleEventHandler.handle(new GuildHeartAttackEvent(EventCause.SYSTEM, user, guild))) {
return;
}
WarSystem.getInstance().attack(player, entry.getKey());
return;
}
}
use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.
the class GuildEntityHelper method spawnGuildHeart.
public static void spawnGuildHeart(Guild guild, Player... players) {
try {
FunnyGuilds plugin = FunnyGuilds.getInstance();
FakeEntity guildHeartEntity;
if (!ENTITY_MAP.containsKey(guild)) {
Option<Location> locationOption = guild.getEnderCrystal();
if (locationOption.isEmpty()) {
return;
}
guildHeartEntity = plugin.getNmsAccessor().getEntityAccessor().createFakeEntity(plugin.getPluginConfiguration().heart.createEntityType, locationOption.get());
ENTITY_MAP.put(guild, guildHeartEntity);
} else {
guildHeartEntity = ENTITY_MAP.get(guild);
}
plugin.getNmsAccessor().getEntityAccessor().spawnFakeEntityFor(guildHeartEntity, players);
} catch (Exception exception) {
FunnyGuilds.getPluginLogger().error("Could not spawn guild heart", exception);
}
}
Aggregations