net.minecraft.village.VillagerProfession Java Examples

The following examples show how to use net.minecraft.village.VillagerProfession. 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: Protocol_1_13_2.java    From multiconnect with MIT License 6 votes vote down vote up
private static VillagerProfession getVillagerProfession(int id) {
    switch (id) {
        case 0:
            return VillagerProfession.FARMER;
        case 1:
            return VillagerProfession.LIBRARIAN;
        case 2:
            return VillagerProfession.CLERIC;
        case 3:
            return VillagerProfession.ARMORER;
        case 4:
            return VillagerProfession.BUTCHER;
        case 5:
        default:
            return VillagerProfession.NITWIT;
    }
}
 
Example #2
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 #3
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 #4
Source File: VillagerProfession_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "register(Ljava/lang/String;Lnet/minecraft/world/poi/PointOfInterestType;Lnet/minecraft/sound/SoundEvent;)Lnet/minecraft/village/VillagerProfession;", cancellable = true, at = @At("HEAD"))
private static void registerCleric(String key, PointOfInterestType pointOfInterestType, SoundEvent soundEvent, CallbackInfoReturnable<VillagerProfession> cir)
{
    if (key.equals("cleric"))
    {
        cir.setReturnValue(register(key, pointOfInterestType, ImmutableSet.of(Items.NETHER_WART), ImmutableSet.of(Blocks.SOUL_SAND), soundEvent));
    }
}
 
Example #5
Source File: VillagerTaskListProvider_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "createWorkTasks", at = @At(
        value = "FIELD",
        target = "Lnet/minecraft/village/VillagerProfession;FARMER:Lnet/minecraft/village/VillagerProfession;"
))
private static VillagerProfession redirectFarmer(VillagerProfession profession, float f)
{
    if(CarpetExtraSettings.clericsFarmWarts && profession == VillagerProfession.CLERIC)
        return VillagerProfession.CLERIC;
    return VillagerProfession.FARMER;
}
 
Example #6
Source File: SecondaryPointOfInterestSensor_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "sense", at = @At("HEAD"), cancellable = true)
private void notVanillaCleric(ServerWorld serverWorld, VillagerEntity villagerEntity, CallbackInfo ci)
{
    if(!CarpetExtraSettings.clericsFarmWarts && villagerEntity.getVillagerData().getProfession() == VillagerProfession.CLERIC)
    {
        // in vanilla we want not to find secondary POI for clerics
        Brain<?> brain = villagerEntity.getBrain();
        brain.forget(MemoryModuleType.SECONDARY_JOB_SITE);
        ci.cancel();

    }
}
 
Example #7
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "shouldRun", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/village/VillagerData;getProfession()Lnet/minecraft/village/VillagerProfession;"
))
private VillagerProfession disguiseAsFarmer(VillagerData villagerData)
{
    isFarmingCleric = false;
    VillagerProfession profession = villagerData.getProfession();
    if (CarpetExtraSettings.clericsFarmWarts && profession == VillagerProfession.CLERIC)
    {
        isFarmingCleric = true;
        return VillagerProfession.FARMER;
    }
    return profession;
}
 
Example #8
Source File: VillagerEntity_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "canGather", at = @At("HEAD"), cancellable = true)
private void canClericGather(Item item, CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetExtraSettings.clericsFarmWarts && item == Items.NETHER_WART &&
            getVillagerData().getProfession()== VillagerProfession.CLERIC )
    {
        cir.setReturnValue(true);
    }
}
 
Example #9
Source File: VillagerEntity_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "hasSeedToPlant", at = @At("HEAD"), cancellable = true)
private void hasWartsToPlant(CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetExtraSettings.clericsFarmWarts && getVillagerData().getProfession()== VillagerProfession.CLERIC )
    {
        cir.setReturnValue(getInventory().containsAnyInInv(ImmutableSet.of(Items.NETHER_WART)));
    }
}
 
Example #10
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 #11
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;
}
 
Example #12
Source File: MixinVillagerProfession.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public IForgeRegistryEntry<VillagerProfession> setRegistryName(Identifier name) {
	this.registryName = name;

	return this;
}
 
Example #13
Source File: MixinVillagerProfession.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Identifier getRegistryName() {
	VillagerProfession villagerProfession = (VillagerProfession) (Object) this;

	return Identifiers.getOrFallback(Registry.VILLAGER_PROFESSION, villagerProfession, registryName);
}
 
Example #14
Source File: MixinVillagerProfession.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Class<VillagerProfession> getRegistryType() {
	return VillagerProfession.class;
}
 
Example #15
Source File: NpcClothingFeature.java    From MineLittlePony with MIT License 4 votes vote down vote up
public static Identifier getClothingTexture(VillagerDataContainer entity, String entityType) {
    VillagerProfession profession = entity.getVillagerData().getProfession();

    return createTexture("minelittlepony", "profession", entityType, Registry.VILLAGER_PROFESSION.getId(profession));
}
 
Example #16
Source File: VillagerProfession_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 votes vote down vote up
@Shadow static VillagerProfession register(String string, PointOfInterestType pointOfInterestType, ImmutableSet<Item> immutableSet, ImmutableSet<Block> immutableSet2, /*@Nullable*/ SoundEvent soundEvent) {return null;}