本文整理汇总了Java中net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer类的典型用法代码示例。如果您正苦于以下问题:Java VillagerCareer类的具体用法?Java VillagerCareer怎么用?Java VillagerCareer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VillagerCareer类属于net.minecraftforge.fml.common.registry.VillagerRegistry包,在下文中一共展示了VillagerCareer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
public static void init() {
mechanicProfession = new VillagerProfession(Names.MOD_ID + ":mechanic",
Textures.VILLAGER_MECHANIC, "minecraft:textures/entity/zombie_villager/zombie_villager.png");
VillagerCareer career = new VillagerCareer(mechanicProfession, Names.MOD_ID + ".mechanic");
career.addTrade(1,
new ListItemForEmeralds(Itemss.PCB_BLUEPRINT, new PriceInfo(10, 19)),
new ListItemForEmeralds(Itemss.NUKE_VIRUS, new PriceInfo(1, 5)),
new ListItemForEmeralds(Itemss.STOP_WORM, new PriceInfo(1, 5))
);
for (int i = 0; i < ItemAssemblyProgram.PROGRAMS_AMOUNT; i++) {
career.addTrade(1,
new ListItemForEmeralds(new ItemStack(Itemss.ASSEMBLY_PROGRAM, 1, i), new PriceInfo(5, 11)));
}
}
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:15,代码来源:VillagerHandler.java
示例2: addTradeToCareer
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
/**
* Creates a new villager trade from the supplied JSON object and adds it to the specified career
* @param career The VillagerCareer instance to add the new trade to
* @param careerLevel the level at which the new trade should be added
* @param jsonRecipeObject the JSON object representing the new trade
*/
private static void addTradeToCareer(VillagerCareer career, int careerLevel, JsonObject jsonRecipeObject)
{
JsonElement jsonBuyElement = jsonRecipeObject.get("buy");
JsonElement jsonBuyElementB = (jsonRecipeObject.has("buyB") ? jsonRecipeObject.get("buyB") : null);
JsonElement jsonSellElement = jsonRecipeObject.get("sell");
ExtraTradeData extraTradeData = new ExtraTradeData();
extraTradeData.chance = (jsonRecipeObject.has("chance") ? jsonRecipeObject.get("chance").getAsDouble() : 1);
if (jsonRecipeObject.has("rewardExp")) extraTradeData.rewardsExp = jsonRecipeObject.get("rewardExp").getAsBoolean();
if (jsonRecipeObject.has("maxUses")) extraTradeData.maxTradeUses = jsonRecipeObject.get("maxUses").getAsInt();
ItemStacksAndPrices buy = getItemStacksAndPrices(jsonBuyElement);
ItemStacksAndPrices buyB = (jsonBuyElementB != null ? getItemStacksAndPrices(jsonBuyElementB) : null);
ItemStacksAndPrices sell = getItemStacksAndPrices(jsonSellElement);
boolean isVillagerBuying = containsCurrencyItems(sell.getItemStacks());
boolean isVillagerSelling = (containsCurrencyItems(buy.getItemStacks()) || (buyB != null ? containsCurrencyItems(buyB.getItemStacks()) : false));
if (isVillagerBuying)
{
career.addTrade(careerLevel, new VTTVillagerBuyingTrade(buy, buyB, sell, extraTradeData));
}
else if (isVillagerSelling)
{
career.addTrade(careerLevel, new VTTVillagerSellingTrade(buy, buyB, sell, extraTradeData));
}
else
{
career.addTrade(careerLevel, new VTTVillagerTradeBase(buy, buyB, sell, extraTradeData));
}
}
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:39,代码来源:TradeLoader.java
示例3: clearCareerTrades
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
private static void clearCareerTrades(VillagerCareer career)
{
List<List<ITradeList>> trades = new VTTVillagerCareer(career).getTrades();
for (List<ITradeList> careerTrades : trades)
{
careerTrades.clear();
}
trades.clear();
}
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:10,代码来源:TradeLoader.java
示例4: execute
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
World world = sender.getEntityWorld();
if (!world.isRemote)
{
if (args.length == 0)
{
for (Map.Entry<Integer, String> kvp : VillagerRegistryHelper.getProfessionIdsAndNamesSortedById())
{
sender.sendMessage(new TextComponentString(kvp.getKey() + ": " + kvp.getValue()));
}
return;
}
if (args.length == 2 && args[0].equals("profession"))
{
VillagerProfession profession = VillagerRegistryHelper.getProfession(args[1]);
if (profession != null)
{
for (VillagerCareer career : new VTTVillagerProfession(profession).getCareers())
{
VTTVillagerCareer vttCareer = new VTTVillagerCareer(career);
sender.sendMessage(new TextComponentString(vttCareer.getId() + ": " + vttCareer.getName()));
sender.sendMessage(new TextComponentString(" " + vttCareer.getCareerLevels() + " levels"));
}
}
}
}
}
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:33,代码来源:ModCommand.java
示例5: addVillager
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
private void addVillager(String name, EntityVillager.ITradeList[][] trades) {
VillagerProfession prof = new VillagerProfession(Const.MODRES + name,
Const.MODRES + "textures/entity/villager/" + name + ".png",
"minecraft:textures/entity/zombie_villager/zombie_villager.png");
VillagerProfRegistry.register(prof);
VillagerCareer villager = new VillagerCareer(prof, name);
for (int i = 0; i < trades.length; i++) {
villager.addTrade(i + 1, trades[i]);
}
}
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:11,代码来源:VillagerCreateModule.java
示例6: registerUselessVillager
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
public static void registerUselessVillager() {
final VillagerProfession prof = new VillagerProfession(
"openblocks:radio",
"openblocks:textures/models/king-ish.png",
"minecraft:textures/entity/zombie_villager/zombie_villager.png"); // TODO: zombie texture?
GameRegistry.findRegistry(VillagerProfession.class).register(prof);
final VillagerCareer career = new VillagerCareer(prof, "audiophile")
.addTrade(1, new EmeraldForItems(Item.getItemFromBlock(Blocks.NOTEBLOCK), new PriceInfo(5, 7)))
.addTrade(2, new ListItemForEmeralds(Item.getItemFromBlock(Blocks.JUKEBOX), new PriceInfo(10, 15))); // extra for sound quality!
for (ItemStack record : OreDictionary.getOres("record"))
career.addTrade(3, new ListItemForEmeralds(record.getItem(), new PriceInfo(3, 6)));
}
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:16,代码来源:RadioVillagerTrades.java
示例7: regCareer
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
private static VillagerCareer regCareer(VillagerProfession parent, String name, HarshenTrade trade)
{
return new VillagerCareer(parent, name).addTrade(1, trade);
}
开发者ID:kenijey,项目名称:harshencastle,代码行数:5,代码来源:HarshenVillagers.java
示例8: loadTradesFromFile
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
/**
* Parses the contents of an individual trade file, and adds or removes the trades to or from the specified profession and career
* @param fileContents
*/
private static void loadTradesFromFile(String fileContents)
{
// parse the provided string as JSON
JsonObject jsonObject = new JsonParser().parse(fileContents).getAsJsonObject();
// identify the profession and career to apply these trades to
String jsonProfession = jsonObject.get("Profession").getAsString();
String jsonCareer = jsonObject.get("Career").getAsString();
// get the specified career and profession from the villager registry
VillagerProfession profession = VillagerRegistryHelper.getProfession(jsonProfession);
if (profession == null) throw new UnknownProfessionException(jsonProfession);
VillagerCareer career = new VTTVillagerProfession(profession).getCareer(jsonCareer);
if (career == null) throw new UnknownCareerException(jsonCareer);
// iterate over the trade recipes included in the offers object
JsonArray jsonRecipes = jsonObject.get("Offers").getAsJsonObject().get("Recipes").getAsJsonArray();
for (JsonElement jsonRecipe : jsonRecipes)
{
JsonObject jsonRecipeObject = jsonRecipe.getAsJsonObject();
// get the level this trade change applies to, and what type of change it is
String jsonRecipeAction = jsonRecipeObject.get("action").getAsString();
int jsonCareerLevel = (jsonRecipeObject.has("CareerLevel") ? jsonRecipeObject.get("CareerLevel").getAsInt() : 0);
// add a new trade if we're supposed to add one
if (jsonRecipeAction.equals("add"))
{
addTradeToCareer(career, jsonCareerLevel, jsonRecipeObject);
}
// or remove a trade if we're supposed to remove one
else if (jsonRecipeAction.equals("remove"))
{
removeTradeFromCareer(career, jsonCareerLevel, jsonRecipeObject);
}
// if we're supposed to replace a trade
else if (jsonRecipeAction.equals("replace"))
{
// remove the old one, and add a new one
removeTradeFromCareer(career, jsonCareerLevel, jsonRecipeObject);
addTradeToCareer(career, jsonCareerLevel, jsonRecipeObject);
}
// if we're supposed to clear the trades
else if (jsonRecipeAction.equals("clear"))
{
// if a career level was specified...
if (jsonCareerLevel > 0)
{
// clear the trades for that level
clearCareerTrades(career, jsonCareerLevel);
}
// if not...
else
{
// clear all the trades from the career
clearCareerTrades(career);
}
}
}
// sort them so that the buying trades appear before the selling trades for each level (like vanilla)
if (ModConfiguration.sortTrades) sortCareerTrades(career);
}
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:72,代码来源:TradeLoader.java
示例9: sortCareerTrades
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
/**
* Sorts the trades at each level of a career so that the buying trades appear before the selling trades
* @param career The VillagerCareer instance on which to sort the trades
*/
private static void sortCareerTrades(VillagerCareer career)
{
// get the trades from the career instance in a modifiable form
List<List<ITradeList>> trades = new VTTVillagerCareer(career).getTrades();
// iterate over the trades at each career level
for (List<ITradeList> levelTrades : trades)
{
// sort the trades using a comparator
Collections.sort(levelTrades, new Comparator<ITradeList>()
{
@Override
public int compare(ITradeList tradeA, ITradeList tradeB)
{
// get the appropriate trade handler for the two trades being compared
ITradeHandler handlerA = TradeHandlers.tradeHandlers.get(tradeA.getClass());
ITradeHandler handlerB = TradeHandlers.tradeHandlers.get(tradeB.getClass());
if (handlerA != null && handlerB != null)
{
// if one is a buying trade and the other a selling trade, put the buying trade first
if (handlerA instanceof VTTVillagerBuyingHandler && handlerB instanceof VTTVillagerSellingHandler)
{
return -1;
}
else if (handlerA instanceof VTTVillagerSellingHandler && handlerB instanceof VTTVillagerBuyingHandler)
{
return 1;
}
}
// otherwise leave their current positions unmodified
return 0;
}
});
}
}
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:45,代码来源:TradeLoader.java
示例10: addInformation
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn)
{
NBTTagCompound tagItemStack = stack.getTagCompound();
if(tagItemStack == null)
return;
StringBuilder tooltipText = new StringBuilder();
String name = tagItemStack.getString("Name");
if((name != null) && (name.length() > 0))
{
tooltipText.append("Name:§b");
tooltipText.append(name);
tooltipText.append("§r");
tooltip.add(tooltip.toString());
}
String professionString = tagItemStack.getString("prf");
if((professionString == null) || (professionString.length() == 0))
professionString = "minecraft:farmer";
ResourceLocation professionName = new ResourceLocation(professionString);
VillagerProfession profession = BlockVillagerTrader.PROFESSIONS.getObject(professionName);
int careerId = TypeTransformer.fromUnsignedByte(tagItemStack.getByte("car"));
VillagerCareer career = profession.getCareer(careerId);
tooltipText = new StringBuilder();
tooltipText.append("entity.Villager.");
tooltipText.append(career.getName());
String localizedCareer = I18n.format(tooltipText.toString());
tooltipText = new StringBuilder();
tooltipText.append("Profession:§b");
tooltipText.append(localizedCareer);
tooltipText.append("§r");
tooltip.add(tooltipText.toString());
tooltipText = new StringBuilder();
tooltipText.append("Level:§b");
tooltipText.append(TypeTransformer.fromUnsignedByte(tagItemStack.getByte("lov")));
tooltipText.append("§r");
tooltip.add(tooltipText.toString());
}
开发者ID:a1lic,项目名称:McMod-CubicVillager,代码行数:45,代码来源:BlockVillagerTrader.java
注:本文中的net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论