IMCHandler.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:vsminecraft 作者:
@EventHandler
public void onIMCEvent(List<IMCMessage> messages)
{
    for(IMCMessage msg : messages)
    {
        if(msg.isNBTMessage())
        {
            try {
                boolean found = false;

                for(Recipe type : Recipe.values())
                {
                    if(msg.key.equalsIgnoreCase(type.getRecipeName() + "Recipe"))
                    {
                        MachineInput input = type.createInput(msg.getNBTValue());

                        if(input != null && input.isValid())
                        {
                            MachineRecipe recipe = type.createRecipe(input, msg.getNBTValue());

                            if(recipe != null && recipe.recipeOutput != null)
                            {
                                RecipeHandler.addRecipe(type, recipe);
                                Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added recipe of type " + type.getRecipeName() + " to the recipe list.");
                            }
                            else {
                                Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to add recipe of type " + type.getRecipeName() + " with an invalid output.");
                            }
                        }
                        else {
                            Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to add recipe of type " + type.getRecipeName() + " with an invalid input.");
                        }

                        found = true;
                        break;
                    }
                }

                if(!found)
                {
                    Mekanism.logger.error("[Mekanism] " + msg.getSender() + " sent unknown IMC message with key '" + msg.key + ".'");
                }
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号