Search in sources :

Example 6 with SpongeTranslation

use of org.spongepowered.common.text.translation.SpongeTranslation in project SpongeCommon by SpongePowered.

the class MixinEnumChatVisibility method construct.

@Inject(method = "<init>", at = @At("RETURN"))
public void construct(String name, int i, int i2, String s2, CallbackInfo ci) {
    this.visibleChatTypes = Sets.newHashSet();
    this.id = SpongeImplHooks.getModIdFromClass(this.getClass()) + ":" + ((EntityPlayer.EnumChatVisibility) (Object) this).name().toLowerCase(Locale.ENGLISH);
    this.translation = new SpongeTranslation(this.resourceKey);
}
Also used : SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 7 with SpongeTranslation

use of org.spongepowered.common.text.translation.SpongeTranslation in project SpongeForge by SpongePowered.

the class SpongeForgeVillagerRegistry method registerForgeCareer.

public static void registerForgeCareer(VillagerRegistry.VillagerCareer career) {
    final VillagerRegistry.VillagerProfession villagerProfession = ((IMixinVillagerCareer) career).getProfession();
    final Optional<Profession> spongeProfession = getProfession(villagerProfession);
    spongeProfession.ifPresent(profession -> {
        Career suggestedCareer = new SpongeCareer(((IMixinVillagerCareer) career).getId(), career.getName(), profession, new SpongeTranslation("entity.Villager." + career.getName()));
        SpongeCareer registeredCareer = validateCareer(career, suggestedCareer);
        CareerRegistryModule.getInstance().registerCareer(registeredCareer);
    });
    if (!spongeProfession.isPresent()) {
        SpongeImpl.getLogger().debug("Delaying registration of career {} until its profession {} is registered with Forge.", career.getName(), villagerProfession.getRegistryName());
    }
}
Also used : IMixinVillagerCareer(org.spongepowered.mod.interfaces.IMixinVillagerCareer) SpongeProfession(org.spongepowered.common.entity.SpongeProfession) Profession(org.spongepowered.api.data.type.Profession) SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation) VillagerRegistry(net.minecraftforge.fml.common.registry.VillagerRegistry) SpongeCareer(org.spongepowered.common.entity.SpongeCareer) Career(org.spongepowered.api.data.type.Career) SpongeCareer(org.spongepowered.common.entity.SpongeCareer) IMixinVillagerCareer(org.spongepowered.mod.interfaces.IMixinVillagerCareer)

Example 8 with SpongeTranslation

use of org.spongepowered.common.text.translation.SpongeTranslation in project SpongeCommon by SpongePowered.

the class MixinPotion method getPotionTranslation.

// TODO: Remove this from the API or change return type to Optional
@Override
public Translation getPotionTranslation() {
    if (this.potionTranslation == null) {
        String name = shadow$getName();
        this.potionTranslation = new SpongeTranslation("potion." + potionMapping.getOrDefault(name, "effect.missing"));
    }
    return this.potionTranslation;
}
Also used : SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation)

Example 9 with SpongeTranslation

use of org.spongepowered.common.text.translation.SpongeTranslation in project SpongeCommon by SpongePowered.

the class MixinAdvancement method onInit.

@SuppressWarnings("ConstantConditions")
@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(ResourceLocation id, @Nullable Advancement parentIn, @Nullable DisplayInfo displayIn, AdvancementRewards rewardsIn, Map<String, Criterion> criteriaIn, String[][] requirementsIn, CallbackInfo ci) {
    if (displayIn != null) {
        ((IMixinDisplayInfo) displayIn).setAdvancement(this);
    }
    String path = id.getResourcePath();
    this.name = path.replace('/', '_');
    this.spongeId = id.getResourceDomain() + ':' + this.name;
    if (displayIn != null) {
        this.name = SpongeTexts.toPlain(displayIn.getTitle());
    }
    if (!AdvancementRegistryModule.INSIDE_REGISTER_EVENT) {
        AdvancementRegistryModule.getInstance().registerAdditionalCatalog(this);
    } else {
        // Wait to set the parent until the advancement is registered
        this.tempParent = parentIn;
        this.parent = SpongeAdvancementBuilder.DUMMY_ROOT_ADVANCEMENT;
    }
    // This is only possible when REGISTER_ADVANCEMENTS_ON_CONSTRUCT is true
    if (parentIn == null) {
        // Remove the root suffix from json file tree ids
        if (path.endsWith("/root")) {
            path = path.substring(0, path.lastIndexOf('/'));
        }
        path = path.replace('/', '_');
        String name = path;
        if (displayIn != null) {
            name = this.name;
        }
        path = id.getResourceDomain() + ':' + path;
        this.tree = new SpongeAdvancementTree(this, path, name);
        AdvancementTreeRegistryModule.getInstance().registerAdditionalCatalog(this.tree);
    } else {
        this.tree = ((org.spongepowered.api.advancement.Advancement) parentIn).getTree().orElse(null);
    }
    this.text = SpongeTexts.toText(this.displayText);
    final ImmutableList.Builder<Text> toastText = ImmutableList.builder();
    if (this.display != null) {
        final FrameType frameType = this.display.getFrame();
        toastText.add(Text.builder(new SpongeTranslation("advancements.toast." + frameType.getName())).format(((AdvancementType) (Object) frameType).getTextFormat()).build());
        toastText.add(getDisplayInfo().get().getTitle());
    } else {
        toastText.add(Text.of("Unlocked advancement"));
        toastText.add(Text.of(getId()));
    }
    this.toastText = toastText.build();
    final Set<String> scoreCriteria = new HashSet<>();
    final Map<String, ICriterion> criterionMap = new HashMap<>();
    for (Map.Entry<String, Criterion> entry : new HashMap<>(criteriaIn).entrySet()) {
        final IMixinCriterion mixinCriterion = (IMixinCriterion) entry.getValue();
        final ICriterion criterion;
        if (mixinCriterion.getScoreGoal() != null) {
            criterion = new SpongeScoreCriterion(entry.getKey(), mixinCriterion.getScoreGoal(), entry.getValue().getCriterionInstance());
            scoreCriteria.add(entry.getKey());
            ((SpongeScoreCriterion) criterion).internalCriteria.forEach(criterion1 -> criteriaIn.put(criterion1.getName(), (Criterion) criterion1));
        } else {
            criterion = (ICriterion) mixinCriterion;
            ((IMixinCriterion) criterion).setName(entry.getKey());
        }
        criterionMap.put(entry.getKey(), criterion);
    }
    final List<String[]> entries = new ArrayList<>();
    final List<AdvancementCriterion> andCriteria = new ArrayList<>();
    for (String[] array : requirementsIn) {
        final Set<AdvancementCriterion> orCriteria = new HashSet<>();
        for (String name : array) {
            final ICriterion criterion = criterionMap.get(name);
            if (criterion instanceof SpongeScoreCriterion) {
                ((SpongeScoreCriterion) criterion).internalCriteria.forEach(criterion1 -> entries.add(new String[] { criterion1.getName() }));
            } else {
                entries.add(new String[] { criterion.getName() });
            }
            orCriteria.add(criterion);
        }
        andCriteria.add(OrCriterion.of(orCriteria));
    }
    this.criterion = AndCriterion.of(andCriteria);
    if (!scoreCriteria.isEmpty()) {
        scoreCriteria.forEach(criteriaIn::remove);
        this.criteria = ImmutableMap.copyOf(criteriaIn);
        this.requirements = entries.toArray(new String[entries.size()][]);
    }
}
Also used : SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation) SpongeAdvancementTree(org.spongepowered.common.advancement.SpongeAdvancementTree) HashMap(java.util.HashMap) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) SpongeScoreCriterion(org.spongepowered.common.advancement.SpongeScoreCriterion) IMixinDisplayInfo(org.spongepowered.common.interfaces.advancement.IMixinDisplayInfo) Criterion(net.minecraft.advancements.Criterion) AndCriterion(org.spongepowered.api.advancement.criteria.AndCriterion) OrCriterion(org.spongepowered.api.advancement.criteria.OrCriterion) AdvancementCriterion(org.spongepowered.api.advancement.criteria.AdvancementCriterion) ICriterion(org.spongepowered.common.advancement.ICriterion) SpongeScoreCriterion(org.spongepowered.common.advancement.SpongeScoreCriterion) IMixinCriterion(org.spongepowered.common.interfaces.advancement.IMixinCriterion) FrameType(net.minecraft.advancements.FrameType) ICriterion(org.spongepowered.common.advancement.ICriterion) HashSet(java.util.HashSet) Text(org.spongepowered.api.text.Text) IMixinCriterion(org.spongepowered.common.interfaces.advancement.IMixinCriterion) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Advancement(net.minecraft.advancements.Advancement) IMixinAdvancement(org.spongepowered.common.interfaces.advancement.IMixinAdvancement) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 10 with SpongeTranslation

use of org.spongepowered.common.text.translation.SpongeTranslation in project SpongeCommon by SpongePowered.

the class EntityTypeRegistryModule method registerDefaults.

@Override
public void registerDefaults() {
    this.entityTypeMappings.put("item", newEntityTypeFromName("Item"));
    this.entityTypeMappings.put("experience_orb", newEntityTypeFromName("xp_orb"));
    this.entityTypeMappings.put("area_effect_cloud", newEntityTypeFromName("area_effect_cloud"));
    this.entityTypeMappings.put("dragon_fireball", newEntityTypeFromName("dragon_fireball"));
    this.entityTypeMappings.put("leash_hitch", newEntityTypeFromName("leash_knot"));
    this.entityTypeMappings.put("painting", newEntityTypeFromName("painting"));
    this.entityTypeMappings.put("tipped_arrow", newEntityTypeFromName("arrow"));
    this.entityTypeMappings.put("snowball", newEntityTypeFromName("snowball"));
    this.entityTypeMappings.put("fireball", newEntityTypeFromName("LargeFireball", "fireball"));
    this.entityTypeMappings.put("small_fireball", newEntityTypeFromName("small_fireball"));
    this.entityTypeMappings.put("ender_pearl", newEntityTypeFromName("ender_pearl"));
    this.entityTypeMappings.put("eye_of_ender", newEntityTypeFromName("eye_of_ender_signal"));
    this.entityTypeMappings.put("splash_potion", newEntityTypeFromName("potion"));
    this.entityTypeMappings.put("thrown_exp_bottle", newEntityTypeFromName("xp_bottle"));
    this.entityTypeMappings.put("item_frame", newEntityTypeFromName("item_frame"));
    this.entityTypeMappings.put("wither_skull", newEntityTypeFromName("wither_skull"));
    this.entityTypeMappings.put("primed_tnt", newEntityTypeFromName("tnt"));
    this.entityTypeMappings.put("falling_block", newEntityTypeFromName("falling_block"));
    this.entityTypeMappings.put("firework", newEntityTypeFromName("fireworks_rocket"));
    this.entityTypeMappings.put("armor_stand", newEntityTypeFromName("armor_stand"));
    this.entityTypeMappings.put("boat", newEntityTypeFromName("boat"));
    this.entityTypeMappings.put("rideable_minecart", newEntityTypeFromName("minecart"));
    this.entityTypeMappings.put("chested_minecart", newEntityTypeFromName("chest_minecart"));
    this.entityTypeMappings.put("furnace_minecart", newEntityTypeFromName("furnace_minecart"));
    this.entityTypeMappings.put("tnt_minecart", newEntityTypeFromName("tnt_minecart"));
    this.entityTypeMappings.put("hopper_minecart", newEntityTypeFromName("hopper_minecart"));
    this.entityTypeMappings.put("mob_spawner_minecart", newEntityTypeFromName("spawner_minecart"));
    this.entityTypeMappings.put("commandblock_minecart", newEntityTypeFromName("commandblock_minecart"));
    this.entityTypeMappings.put("evocation_fangs", newEntityTypeFromName("evocation_fangs"));
    this.entityTypeMappings.put("evocation_illager", newEntityTypeFromName("evocation_illager"));
    this.entityTypeMappings.put("vex", newEntityTypeFromName("vex"));
    this.entityTypeMappings.put("vindication_illager", newEntityTypeFromName("vindication_illager"));
    this.entityTypeMappings.put("creeper", newEntityTypeFromName("creeper"));
    this.entityTypeMappings.put("skeleton", newEntityTypeFromName("skeleton"));
    this.entityTypeMappings.put("stray", newEntityTypeFromName("stray"));
    this.entityTypeMappings.put("wither_skeleton", newEntityTypeFromName("wither_skeleton"));
    this.entityTypeMappings.put("spider", newEntityTypeFromName("spider"));
    this.entityTypeMappings.put("giant", newEntityTypeFromName("giant"));
    this.entityTypeMappings.put("zombie", newEntityTypeFromName("zombie"));
    this.entityTypeMappings.put("husk", newEntityTypeFromName("husk"));
    this.entityTypeMappings.put("slime", newEntityTypeFromName("slime"));
    this.entityTypeMappings.put("ghast", newEntityTypeFromName("ghast"));
    this.entityTypeMappings.put("pig_zombie", newEntityTypeFromName("zombie_pigman"));
    this.entityTypeMappings.put("enderman", newEntityTypeFromName("enderman"));
    this.entityTypeMappings.put("cave_spider", newEntityTypeFromName("cave_spider"));
    this.entityTypeMappings.put("silverfish", newEntityTypeFromName("silverfish"));
    this.entityTypeMappings.put("blaze", newEntityTypeFromName("blaze"));
    this.entityTypeMappings.put("magma_cube", newEntityTypeFromName("magma_cube"));
    this.entityTypeMappings.put("ender_dragon", newEntityTypeFromName("ender_dragon"));
    this.entityTypeMappings.put("wither", newEntityTypeFromName("wither"));
    this.entityTypeMappings.put("bat", newEntityTypeFromName("bat"));
    this.entityTypeMappings.put("witch", newEntityTypeFromName("witch"));
    this.entityTypeMappings.put("endermite", newEntityTypeFromName("endermite"));
    this.entityTypeMappings.put("guardian", newEntityTypeFromName("guardian"));
    this.entityTypeMappings.put("elder_guardian", newEntityTypeFromName("elder_guardian"));
    this.entityTypeMappings.put("pig", newEntityTypeFromName("pig"));
    this.entityTypeMappings.put("sheep", newEntityTypeFromName("sheep"));
    this.entityTypeMappings.put("cow", newEntityTypeFromName("cow"));
    this.entityTypeMappings.put("chicken", newEntityTypeFromName("chicken"));
    this.entityTypeMappings.put("squid", newEntityTypeFromName("squid"));
    this.entityTypeMappings.put("wolf", newEntityTypeFromName("wolf"));
    this.entityTypeMappings.put("mushroom_cow", newEntityTypeFromName("mooshroom"));
    this.entityTypeMappings.put("snowman", newEntityTypeFromName("snowman"));
    this.entityTypeMappings.put("ocelot", newEntityTypeFromName("Ocelot"));
    this.entityTypeMappings.put("iron_golem", newEntityTypeFromName("villager_golem"));
    this.entityTypeMappings.put("horse", newEntityTypeFromName("horse"));
    this.entityTypeMappings.put("skeleton_horse", newEntityTypeFromName("skeleton_horse"));
    this.entityTypeMappings.put("zombie_horse", newEntityTypeFromName("zombie_horse"));
    this.entityTypeMappings.put("donkey", newEntityTypeFromName("donkey"));
    this.entityTypeMappings.put("mule", newEntityTypeFromName("mule"));
    this.entityTypeMappings.put("llama", newEntityTypeFromName("llama"));
    this.entityTypeMappings.put("llama_spit", newEntityTypeFromName("llama_spit"));
    this.entityTypeMappings.put("rabbit", newEntityTypeFromName("rabbit"));
    this.entityTypeMappings.put("villager", newEntityTypeFromName("villager"));
    this.entityTypeMappings.put("zombie_villager", newEntityTypeFromName("zombie_villager"));
    this.entityTypeMappings.put("ender_crystal", newEntityTypeFromName("ender_crystal"));
    this.entityTypeMappings.put("shulker", newEntityTypeFromName("shulker"));
    this.entityTypeMappings.put("shulker_bullet", newEntityTypeFromName("shulker_bullet"));
    this.entityTypeMappings.put("spectral_arrow", newEntityTypeFromName("spectral_arrow"));
    this.entityTypeMappings.put("polar_bear", newEntityTypeFromName("polar_bear"));
    this.entityTypeMappings.put("egg", new SpongeEntityType(-1, "egg", EntityEgg.class, new SpongeTranslation("item.egg.name")));
    this.entityTypeMappings.put("fishing_hook", new SpongeEntityType(-2, "FishingHook", EntityFishHook.class, new SpongeTranslation("item.fishingRod.name")));
    this.entityTypeMappings.put("lightning", new SpongeEntityType(-3, "lightning", EntityLightningBolt.class, null));
    this.entityTypeMappings.put("weather", new SpongeEntityType(-4, "Weather", EntityWeatherEffect.class, new SpongeTranslation("soundCategory.weather")));
    this.entityTypeMappings.put("player", new SpongeEntityType(-5, "Player", EntityPlayerMP.class, new SpongeTranslation("soundCategory.player")));
    this.entityTypeMappings.put("complex_part", new SpongeEntityType(-6, "ComplexPart", MultiPartEntityPart.class, null));
    // TODO: Figure out what id to use, as negative ids no longer work
    this.entityTypeMappings.put("human", registerCustomEntity(EntityHuman.class, "human", "Human", 300, null));
    // this.entityClassToTypeMappings.put("human", new SpongeEntityType(-6))
    this.entityTypeMappings.put("parrot", newEntityTypeFromName("parrot"));
    this.entityTypeMappings.put("illusion_illager", newEntityTypeFromName("illusion_illager"));
}
Also used : EntityHuman(org.spongepowered.common.entity.living.human.EntityHuman) SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation) SpongeEntityType(org.spongepowered.common.entity.SpongeEntityType) EntityFishHook(net.minecraft.entity.projectile.EntityFishHook) EntityWeatherEffect(net.minecraft.entity.effect.EntityWeatherEffect) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MultiPartEntityPart(net.minecraft.entity.MultiPartEntityPart) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityEgg(net.minecraft.entity.projectile.EntityEgg)

Aggregations

SpongeTranslation (org.spongepowered.common.text.translation.SpongeTranslation)11 ItemFishFood (net.minecraft.item.ItemFishFood)2 CookedFish (org.spongepowered.api.data.type.CookedFish)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 SpongeCookedFish (org.spongepowered.common.data.type.SpongeCookedFish)2 SpongeEntityType (org.spongepowered.common.entity.SpongeEntityType)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Advancement (net.minecraft.advancements.Advancement)1 Criterion (net.minecraft.advancements.Criterion)1 FrameType (net.minecraft.advancements.FrameType)1 IMerchant (net.minecraft.entity.IMerchant)1 MultiPartEntityPart (net.minecraft.entity.MultiPartEntityPart)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityWeatherEffect (net.minecraft.entity.effect.EntityWeatherEffect)1 AbstractHorse (net.minecraft.entity.passive.AbstractHorse)1