calc-mcp

calc-mcp

Okay, here's a simplified explanation of how you could create a simple Minecraft server mod (using MCP - Minecraft Coder Pack) that adds a calculator tool. I'll outline the key steps and provide conceptual code snippets. Keep in mind that this is a simplified example, and a fully functional mod would require more detailed code and setup. **Conceptual Overview** The basic idea is to: 1. **Set up your MCP environment:** This involves downloading MCP, deobfuscating the Minecraft code, and setting up your development environment (usually Eclipse or IntelliJ IDEA). 2. **Create a new item (the calculator):** You'll define a new item class that represents your calculator. 3. **Register the item:** You need to register your new item with Minecraft so it can be used in the game. 4. **Add functionality to the item:** When the player right-clicks with the calculator, you'll trigger the calculator logic. This might involve opening a GUI (graphical user interface) where the player can enter numbers and operations. 5. **Handle the GUI (if needed):** If you're using a GUI, you'll need to create the GUI class and handle user input (button clicks, text input, etc.). 6. **Perform calculations:** Implement the actual calculator logic (addition, subtraction, multiplication, division, etc.). 7. **Display the result:** Show the result of the calculation to the player (e.g., in the GUI, in chat, or as a floating text entity). **Simplified Code Snippets (Conceptual)** ```java // Example Item Class (CalculatorItem.java) package com.example.calculator; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.text.TextComponentString; public class CalculatorItem extends Item { public CalculatorItem() { super(); this.setRegistryName("calculator"); // Important: Set the registry name this.setUnlocalizedName("calculator"); // Set the unlocalized name (for localization) } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (!worldIn.isRemote) { // Server-side only // Simple example: Just send a message to the player playerIn.sendMessage(new TextComponentString("Calculator Activated!")); // In a real mod, you would: // 1. Open a GUI (if you have one) // 2. Start the calculation process } return ActionResult.newResult(net.minecraft.util.EnumActionResult.SUCCESS, itemstack); } } // Example Mod Class (CalculatorMod.java) package com.example.calculator; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraft.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.SidedProxy; @Mod(modid = CalculatorMod.MODID, version = CalculatorMod.VERSION, name = CalculatorMod.NAME) public class CalculatorMod { public static final String MODID = "calculator"; public static final String VERSION = "1.0"; public static final String NAME = "Calculator Mod"; @SidedProxy(clientSide = "com.example.calculator.ClientProxy", serverSide = "com.example.calculator.CommonProxy") public static CommonProxy proxy; public static Item calculator; @EventHandler public void preInit(FMLPreInitializationEvent event) { // Initialize your item here (but don't register it yet) calculator = new CalculatorItem(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerItemRenderer(calculator, 0, "calculator"); } @Mod.EventBusSubscriber public static class RegistrationHandler { @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().register(calculator); } } } // CommonProxy.java package com.example.calculator; import net.minecraft.item.Item; public class CommonProxy { public void registerItemRenderer(Item item, int meta, String id) { } } // ClientProxy.java package com.example.calculator; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ClientProxy extends CommonProxy { @Override public void registerItemRenderer(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(CalculatorMod.MODID + ":" + id, "inventory")); } } ``` **Explanation of the Code Snippets:** * **`CalculatorItem.java`:** * This defines the `CalculatorItem` class, which extends `Item`. * `onItemRightClick()` is the method that's called when the player right-clicks with the item. This is where you'd put your calculator logic. In this simplified example, it just sends a message to the player. * `setRegistryName()` and `setUnlocalizedName()` are *crucial*. The registry name is how Minecraft identifies the item internally. The unlocalized name is used for localization (making the item name appear correctly in different languages). * **`CalculatorMod.java`:** * This is the main mod class. * `@Mod` annotation: Defines the mod's ID, version, and name. * `@EventHandler preInit`: This method is called before the game loads. You initialize your item here. * `@EventHandler init`: This method is called during game initialization. This is where you register the item renderer. * `@Mod.EventBusSubscriber`: This is used to register the item. * `@SubscribeEvent registerItems`: This method registers the item with the game. * **`CommonProxy.java` and `ClientProxy.java`:** * These are used for handling client-side and server-side code separately. The `ClientProxy` is responsible for registering the item's model (how it looks in the inventory and in the world). **Steps to Implement (More Detailed):** 1. **MCP Setup:** * Download the correct version of MCP for your target Minecraft version. * Extract MCP to a directory. * Run `decompile.bat` (or `decompile.sh` on Linux/macOS) to deobfuscate the Minecraft code. This will take a while. * Run `recompile.bat` (or `recompile.sh`). * Run `reobfuscate.bat` (or `reobfuscate.sh`). * Run `createMcpToEclipse.bat` (or the equivalent for IntelliJ IDEA). 2. **Create the Project:** * In Eclipse or IntelliJ IDEA, create a new Java project. * Import the MCP source code into your project. 3. **Create the Item Class:** * Create the `CalculatorItem.java` file (as shown above). 4. **Create the Mod Class:** * Create the `CalculatorMod.java` file (as shown above). 5. **Create the Proxy Classes:** * Create the `CommonProxy.java` and `ClientProxy.java` files (as shown above). 6. **Register the Item:** * Make sure the `@Mod.EventBusSubscriber` and `@SubscribeEvent` annotations are correctly set up in your `CalculatorMod.java` file to register the item. 7. **Item Model (Important):** * Create a JSON file in `src/main/resources/assets/calculator/models/item/calculator.json` (replace "calculator" with your mod ID if different). This file defines how the item looks. A simple example: ```json { "parent": "item/generated", "textures": { "layer0": "calculator:items/calculator" // Replace with your texture path } } ``` * You'll also need a texture file (a `.png` image) in `src/main/resources/assets/calculator/textures/items/calculator.png`. Create a simple image for your calculator. 8. **GUI (If you want one):** * Create a GUI class that extends `net.minecraft.client.gui.GuiScreen`. * Override the `drawScreen()` method to draw the GUI elements (buttons, text fields, etc.). * Override the `mouseClicked()` method to handle button clicks. * In your `CalculatorItem.onItemRightClick()`, open the GUI using `playerIn.openGui(instance, guiID, worldIn, x, y, z);` You'll need to implement `IGuiHandler` in your main mod class and create a `GuiFactory` to handle the GUI opening. 9. **Calculator Logic:** * Implement the calculator logic (addition, subtraction, etc.) in a separate class or within the GUI class. 10. **Build and Test:** * Build your mod. * Copy the resulting `.jar` file to your Minecraft `mods` folder. * Run Minecraft and test your mod. **Important Considerations:** * **Minecraft Forge:** You'll need to use Minecraft Forge to load your mod. Make sure you have the correct Forge version for your Minecraft version. * **GUI Complexity:** Creating a good GUI is the most complex part of this. Consider using a library like Minecraft's built-in GUI system or a third-party GUI library. * **Error Handling:** Add error handling to your calculator logic to prevent crashes (e.g., division by zero). * **Localization:** Use localization files to make your mod's text translatable. * **Permissions:** If you want to restrict the use of the calculator, you can add permission checks. * **Networking:** If you want to perform calculations on the server-side (e.g., for security), you'll need to use Minecraft's networking system to send data between the client and the server. **Chinese Translation of Key Terms:** * **Minecraft Server Mod:** Minecraft服务器模组 (Minecraft Fúwùqì Mózǔ) * **Calculator Tool:** 计算器工具 (Jìsuànqì Gōngjù) * **MCP (Minecraft Coder Pack):** Minecraft代码包 (Minecraft Dàimǎ Bāo) * **Item:** 物品 (Wùpǐn) * **GUI (Graphical User Interface):** 图形用户界面 (Túxíng Yònghù Jièmiàn) * **Register:** 注册 (Zhùcè) * **Deobfuscate:** 反混淆 (Fǎn Hùnyáo) * **Reobfuscate:** 重新混淆 (Chóngxīn Hùnyáo) * **Forge:** Forge (usually kept in English) * **Texture:** 纹理 (Wénlǐ) * **Model:** 模型 (Móxíng) * **Client-side:** 客户端 (Kèhùduān) * **Server-side:** 服务器端 (Fúwùqìduān) This is a complex project, but hopefully, this detailed explanation and the code snippets give you a good starting point. Good luck!

lee-t

研究与数据
访问服务器

README

calc-mcp

简单的 mcp 服务器,添加了一个计算器工具

推荐服务器

Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

一个模型上下文协议 (MCP) 服务器,它使用 CoinCap API 提供全面的加密货币分析。该服务器通过一个易于使用的界面提供实时价格数据、市场分析和历史趋势。 (Alternative, slightly more formal and technical translation): 一个模型上下文协议 (MCP) 服务器,利用 CoinCap API 提供全面的加密货币分析服务。该服务器通过用户友好的界面,提供实时价格数据、市场分析以及历史趋势数据。

精选
TypeScript
MCP PubMed Search

MCP PubMed Search

用于搜索 PubMed 的服务器(PubMed 是一个免费的在线数据库,用户可以在其中搜索生物医学和生命科学文献)。 我是在 MCP 发布当天创建的,但当时正在度假。 我看到有人在您的数据库中发布了类似的服务器,但还是决定发布我的服务器。

精选
Python
mixpanel

mixpanel

连接到您的 Mixpanel 数据。 从 Mixpanel 分析查询事件、留存和漏斗数据。

精选
TypeScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。

精选
Python
Nefino MCP Server

Nefino MCP Server

为大型语言模型提供访问德国可再生能源项目新闻和信息的能力,允许按地点、主题(太阳能、风能、氢能)和日期范围进行筛选。

官方
Python
Vectorize

Vectorize

将 MCP 服务器向量化以实现高级检索、私有深度研究、Anything-to-Markdown 文件提取和文本分块。

官方
JavaScript
Mathematica Documentation MCP server

Mathematica Documentation MCP server

一个服务器,通过 FastMCP 提供对 Mathematica 文档的访问,使用户能够从 Wolfram Mathematica 检索函数文档和列出软件包符号。

本地
Python
kb-mcp-server

kb-mcp-server

一个 MCP 服务器,旨在实现便携性、本地化、简易性和便利性,以支持对 txtai “all in one” 嵌入数据库进行基于语义/图的检索。任何 tar.gz 格式的 txtai 嵌入数据库都可以被加载。

本地
Python
Research MCP Server

Research MCP Server

这个服务器用作 MCP 服务器,与 Notion 交互以检索和创建调查数据,并与 Claude Desktop Client 集成以进行和审查调查。

本地
Python
Cryo MCP Server

Cryo MCP Server

一个API服务器,实现了模型补全协议(MCP),用于Cryo区块链数据提取,允许用户通过任何兼容MCP的客户端查询以太坊区块链数据。

本地
Python
calc-mcp