Search in sources :

Example 6 with VillagerData

use of net.minecraft.world.entity.npc.VillagerData in project MyPet by xXKeyleXx.

the class EntityMyVillager method defineSynchedData.

@Override
protected void defineSynchedData() {
    super.defineSynchedData();
    getEntityData().define(AGE_WATCHER, false);
    if (MyPetApi.getCompatUtil().isCompatible("1.14.1")) {
        getEntityData().define(UNUSED_WATCHER, 0);
    }
    getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.PLAINS, VillagerProfession.NONE, 1));
}
Also used : VillagerData(net.minecraft.world.entity.npc.VillagerData)

Example 7 with VillagerData

use of net.minecraft.world.entity.npc.VillagerData in project MyPet by xXKeyleXx.

the class EntityMyZombieVillager method updateVisuals.

@Override
public void updateVisuals() {
    getEntityData().set(BABY_WATCHER, getMyPet().isBaby());
    String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey();
    VillagerProfession profession = Registry.VILLAGER_PROFESSION.get(new ResourceLocation(professionKey));
    // TODO
    VillagerType type = Registry.VILLAGER_TYPE.get(new ResourceLocation(getMyPet().getType().getKey()));
    getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getTradingLevel()));
    Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> {
        if (getMyPet().getStatus() == MyPet.PetState.Here) {
            for (EquipmentSlot slot : EquipmentSlot.values()) {
                setPetEquipment(slot, CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)));
            }
        }
    }, 5L);
}
Also used : VillagerType(net.minecraft.world.entity.npc.VillagerType) VillagerProfession(net.minecraft.world.entity.npc.VillagerProfession) ResourceLocation(net.minecraft.resources.ResourceLocation) EquipmentSlot(de.Keyle.MyPet.api.entity.EquipmentSlot) VillagerData(net.minecraft.world.entity.npc.VillagerData)

Example 8 with VillagerData

use of net.minecraft.world.entity.npc.VillagerData in project MyPet by xXKeyleXx.

the class EntityMyZombieVillager method updateVisuals.

@Override
public void updateVisuals() {
    getEntityData().set(BABY_WATCHER, getMyPet().isBaby());
    String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey();
    VillagerProfession profession = Registry.VILLAGER_PROFESSION.get(new ResourceLocation(professionKey));
    // TODO
    VillagerType type = Registry.VILLAGER_TYPE.get(new ResourceLocation(getMyPet().getType().getKey()));
    getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getTradingLevel()));
    Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> {
        if (getMyPet().getStatus() == MyPet.PetState.Here) {
            for (EquipmentSlot slot : EquipmentSlot.values()) {
                setPetEquipment(slot, CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)));
            }
        }
    }, 5L);
}
Also used : VillagerType(net.minecraft.world.entity.npc.VillagerType) VillagerProfession(net.minecraft.world.entity.npc.VillagerProfession) ResourceLocation(net.minecraft.resources.ResourceLocation) EquipmentSlot(de.Keyle.MyPet.api.entity.EquipmentSlot) VillagerData(net.minecraft.world.entity.npc.VillagerData)

Example 9 with VillagerData

use of net.minecraft.world.entity.npc.VillagerData in project Tropicraft by Tropicraft.

the class EntityKoaBase method updateTrades.

/**
 * New main override for villager "trades" aka offers
 * @return
 */
@Override
protected void updateTrades() {
    VillagerData villagerdata = this.getVillagerData();
    Int2ObjectMap<VillagerTrades.ItemListing[]> int2objectmap = getOfferMap();
    if (int2objectmap != null && !int2objectmap.isEmpty()) {
        VillagerTrades.ItemListing[] avillagertrades$itrade = int2objectmap.get(villagerdata.getLevel());
        if (avillagertrades$itrade != null) {
            MerchantOffers merchantoffers = this.getOffers();
            this.addOffersFromItemListings(merchantoffers, avillagertrades$itrade, 2);
        }
    }
}
Also used : VillagerTrades(net.minecraft.world.entity.npc.VillagerTrades) MerchantOffers(net.minecraft.world.item.trading.MerchantOffers) VillagerData(net.minecraft.world.entity.npc.VillagerData)

Aggregations

VillagerData (net.minecraft.world.entity.npc.VillagerData)9 ResourceLocation (net.minecraft.resources.ResourceLocation)4 VillagerProfession (net.minecraft.world.entity.npc.VillagerProfession)4 VillagerType (net.minecraft.world.entity.npc.VillagerType)4 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)2 VillagerTrades (net.minecraft.world.entity.npc.VillagerTrades)1 MerchantOffers (net.minecraft.world.item.trading.MerchantOffers)1