工厂界面对接
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
public class TestFactoryGui extends BaseFactoryGui {
public TestFactoryGui(Player viewer) {
super(viewer);
//设置槽位的最大上限
getProperty().setSlotSize(5);
//增加当前制作中物品。
//注意!!请注意顺序,回传也将按照顺序。
getProperty().addCrafting(
CraftingProperty.of("MINELASTDAYSGUNS_DM331", 5)
);
}
@Override
public void onClickSelectRecipe() {
//TODO 当点击【选择配方】按钮后,通常跳转到选择配方页面。
new TestSelectRecipeGui(getViewer()).display();
}
@Override
public void onTryHarvest(int index) {
//TODO 当已完成,玩家点击【取出物品】时,进行物品的收取与页面刷新
System.out.println("try harvest " + index);
}
}public class TestSelectRecipeGui extends BaseSelectRecipeGui {
public TestSelectRecipeGui(Player viewer) {
super(viewer);
//创建配方
RecipeProperty recipe1 = RecipeProperty.of("recipe1");
//设置配方产品
recipe1.setProduct(ItemProperty.of("DIAMOND", 12));//产出:材料ID,材料数量。
//设置配方材质
recipe1.setMaterials(Arrays.asList(
ItemProperty.of("MINELASTDAYSGUNS_DM70", 5),//材料1: 材料ID,材料数量。
ItemProperty.of("MINELASTDAYSGUNS_ALLOY", 4),//材料2: 材料ID,材料数量。
ItemProperty.of("MINELASTDAYSGUNS_GOLDENBRACELET", 3)//材料2: 材料ID,材料数量。
));
//设置时间花费(秒)
recipe1.setTimeCost(500);
//将配方以list存入property中
this.getProperty().setCraftRecipes(Arrays.asList(recipe1));
}
@Override
public void onClickRecipe(String recipeShortName) {
//TODO 当玩家点击【开始制作】时,通常判断玩家是否包含材料等,并开始制作。
System.out.println("click " + recipeShortName);
}
@Override
public void onClickReturn() {
//TODO 当玩家点击【返回】时,通常返回工厂界面。
new TestFactoryGui(getViewer()).display();
}
}