Java Code Examples for net.minecraft.village.VillagerProfession#NONE

The following examples show how to use net.minecraft.village.VillagerProfession#NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractNpcRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public boolean shouldRender(M model, T entity, Wearable wearable, IGear gear) {

    boolean special = PonyTextures.isBestPony(entity);

    if (wearable == Wearable.SADDLE_BAGS) {
        VillagerProfession profession = entity.getVillagerData().getProfession();
        return !special && profession != VillagerProfession.NONE && (
                profession == VillagerProfession.CARTOGRAPHER
             || profession == VillagerProfession.FARMER
             || profession == VillagerProfession.FISHERMAN
             || profession == VillagerProfession.LIBRARIAN
             || profession == VillagerProfession.SHEPHERD);
    }

    if (wearable == Wearable.MUFFIN) {
        return PonyTextures.isCrownPony(entity);
    }

    return super.shouldRender(model, entity, wearable, gear);
}
 
Example 2
Source File: PonyTextures.java    From MineLittlePony with MIT License 6 votes vote down vote up
private Identifier getTexture(final VillagerType type, final VillagerProfession profession) {

        if (profession == VillagerProfession.NONE) {
            return fallback;
        }

        String key = String.format("pony/%s/%s", type, profession);

        if (cache.containsKey(key)) {
            return cache.get(key); // People often complain that villagers cause lag,
                                   // so let's do better than Mojang and rather NOT go
                                   // through all the lambda generations if we can avoid it.
        }

        Identifier result = verifyTexture(formatter.supplyTexture(key)).orElseGet(() -> {
            if (type == VillagerType.PLAINS) {
                // if texture loading fails, use the fallback.
                return fallback;
            }

            return getTexture(VillagerType.PLAINS, profession);
        });

        cache.put(key, result);
        return result;
    }
 
Example 3
Source File: NpcClothingFeature.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public void render(MatrixStack matrixStack, VertexConsumerProvider provider, int i, T entity, float f, float g, float h, float j, float k, float l) {
    if (!entity.isInvisible()) {

        VillagerData data = entity.getVillagerData();
        VillagerType type = data.getType();
        VillagerProfession profession = data.getProfession();

        HatType typeHatLayer = getHatType(typeHatCache, "type", Registry.VILLAGER_TYPE, type);
        HatType profHatLayer = getHatType(profHatCache, "profession", Registry.VILLAGER_PROFESSION, profession);
        M entityModel = getContextModel();

        entityModel.setHatVisible(
                   profHatLayer == VillagerResourceMetadata.HatType.NONE
               || (profHatLayer == VillagerResourceMetadata.HatType.PARTIAL && typeHatLayer != VillagerResourceMetadata.HatType.FULL)
        );

        Identifier typeSkin = findTexture("type", Registry.VILLAGER_TYPE.getId(type));

        getContext().getInternalRenderer().updateMetadata(typeSkin);
        renderModel(entityModel, typeSkin, matrixStack, provider, i, entity, 1, 1, 1);

        entityModel.setHatVisible(true);

        if (profession != VillagerProfession.NONE && !entity.isBaby()) {
            Identifier professionSkin = findTexture("profession", Registry.VILLAGER_PROFESSION.getId(profession));

            getContext().getInternalRenderer().updateMetadata(professionSkin);
            renderModel(entityModel, professionSkin, matrixStack, provider, i, entity, 1, 1, 1);

            if (profession != VillagerProfession.NITWIT) {
                Identifier levelSkin = findTexture("profession_level", LEVEL_TO_ID.get(MathHelper.clamp(data.getLevel(), 1, LEVEL_TO_ID.size())));

                renderModel(entityModel, levelSkin, matrixStack, provider, i, entity, 1, 1, 1);
            }
        }
    }
}
 
Example 4
Source File: VillagerPonyModel.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public void animateModel(T entity, float limbSwing, float limbSwingAmount, float partialTickTime) {
    boolean special = PonyTextures.isBestPony(entity);

    VillagerProfession profession = entity.getVillagerData().getProfession();

    attributes.visualHeight = PonyTextures.isCrownPony(entity) ? 2.3F : 2;
    apron.visible = !special && profession == VillagerProfession.BUTCHER;
    trinket.visible = !special && !apron.visible && profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT;
}