net.minecraft.village.VillagerType Java Examples

The following examples show how to use net.minecraft.village.VillagerType. 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: MoonVillagerEntity.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public MoonVillagerEntity createChild(PassiveEntity passiveEntity) {
    double d = this.random.nextDouble();
    VillagerType villagerType3;
    if (d < 0.5D) {
        villagerType3 = VillagerType.forBiome(this.world.getBiome(this.getBlockPos()));
    } else if (d < 0.75D) {
        villagerType3 = this.getVillagerData().getType();
    } else {
        villagerType3 = ((MoonVillagerEntity) passiveEntity).getVillagerData().getType();
    }
    if (Galacticraft.MOON_VILLAGER_TYPE_REGISTRY.getId(villagerType3) == null) {
        if (this.random.nextBoolean() && Galacticraft.MOON_VILLAGER_TYPE_REGISTRY.getId(this.getVillagerData().getType()) != null) {
            villagerType3 = this.getVillagerData().getType();
        } else {
            villagerType3 = MOON_VILLAGER_TYPE;
        }
    }

    MoonVillagerEntity villagerEntity = new MoonVillagerEntity(GalacticraftEntityTypes.MOON_VILLAGER, this.world, villagerType3);
    villagerEntity.initialize(this.world, this.world.getLocalDifficulty(villagerEntity.getBlockPos()), SpawnReason.BREEDING, null, null);
    return villagerEntity;
}
 
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: MoonVillagerEntity.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
public MoonVillagerEntity(EntityType<? extends MoonVillagerEntity> entityType, World world, VillagerType type) {
    super(entityType, world, type);
    createLivingAttributes();
    assert Galacticraft.MOON_VILLAGER_TYPE_REGISTRY.getId(type) != null;
    setHealth(20.0F);

}
 
Example #4
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 #5
Source File: TypeAwareBuyForOneEmeraldFactoryMixin.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@SuppressWarnings("UnnecessaryQualifiedMemberReference")
@Redirect(method = "Lnet/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFactory;<init>(IIILjava/util/Map;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/DefaultedRegistry;stream()Ljava/util/stream/Stream;"))
private Stream<VillagerType> skipCheck(DefaultedRegistry<VillagerType> defaultedRegistry) {
    return Stream.empty(); //skip check
}
 
Example #6
Source File: TypeAwareBuyForOneEmeraldFactoryMixin.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@SuppressWarnings("UnnecessaryQualifiedMemberReference")
@Inject(method = "Lnet/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFactory;<init>(IIILjava/util/Map;)V", at = @At(value = "RETURN"))
private void addMoonVillagerTrades(int i, int j, int experience, Map<VillagerType, Item> map, CallbackInfo ci) {
    this.map = new HashMap<>(this.map);
    this.map.put(MoonVillagerEntity.MOON_VILLAGER_TYPE, Items.AIR);
}