RT,请附上指令,和way
哈?这是mod问答版撒,如果要再服务器禁止物品的话,可以用banitem插件哦。(mod物品也可用)
指令是/banitem+物品ID
指令是/banitem+物品ID
泰米瑞斯 发表于 2015-8-11 15:00
哈?这是mod问答版撒,如果要再服务器禁止物品的话,可以用banitem插件哦。(mod物品也可用)
指令是/banit ...
不是服务器,请看清楚标题
1048139283 发表于 2015-8-11 15:03
不是服务器,请看清楚标题
这就复杂了、、应该针对客户端修改N个java文件...
我要源代码=.=
一看到RT就想到了我刚做的解直角三角形的题。
不需要自定义合成mod,只要在npc mod全局设置里删掉你不要的合成方式即可。满意请给最佳,如有问题请回复我,我会尽力为你解答
我要源代码=.=
1048139283 发表于 2015-8-11 20:25
我要源代码=.=
[1.8beta-1.6.x][SSP/SMP/LAN]Custom NPCs-自定义NPC[1710d更新]
http://www.mcbbs.net/thread-165632-1-1.html
下载这个mod,用npc魔杖右击地面打开全局设置,然后你会看到一个管理合成的菜单,在里面编辑你想要的合成方式即可
west.myth 发表于 2015-8-11 22:28
[1.8beta-1.6.x][SSP/SMP/LAN]Custom NPCs-自定义NPC[1710d更新]
http://www.mcbbs.net/thread-165632-1- ...
我不要mod啊
我要反注册的代码
java的语法
1048139283 发表于 2015-8-12 06:45
我不要mod啊
我要反注册的代码
java的语法
原版删除我不知道,但要删mod合成方式我还是略懂。除非你会做mod,否则只有npc mod是可以做到你的要求并且方法够简单。其实npcmod挺好的,你要ban物品合成是为了服务器吧?(我的猜测)很多服都有npc mod。如果真的是服务器,插件就够了
west.myth 发表于 2015-8-12 12:09
原版删除我不知道,但要删mod合成方式我还是略懂。除非你会做mod,否则只有npc mod是可以做到你的要求并 ...
就是做mod,不知道才问的
west.myth 发表于 2015-8-11 18:11
不需要自定义合成mod,只要在npc mod全局设置里删掉你不要的合成方式即可。满意请给最佳,如有问题请回复我 ...
NPCmod只能删除NPCmod新创建的合成,其他的都不行
1048139283 发表于 2015-8-12 12:42
就是做mod,不知道才问的
花了十几分钟写了个Helper类,吐槽一下MC坑爹的代码,ItemStack和IRecipe的equals()方法竟然都没有Override,导致我的写的这个方法这么麻烦。
这个类我放在Gist上,你可以到这里来查看: https://gist.github.com/Meow-J/61e2ab64a9bd5a48447b
由于代码太多而且不好看就不贴在论坛里了,如果你打不开我再帮你贴过来。
使用:
- // 删除指定物品的合成
- RecipeRemover.removeRecipe(new ItemStack(Items.stick));
- // 删除指定无序合成
- List<ItemStack> inputList = new ArrayList<ItemStack>();
- inputList.add(new ItemStack(Items.ender_pearl, 1));
- inputList.add(new ItemStack(Items.blaze_powder, 1));
- RecipeRemover.removeShapelessRecipe(new ShapelessRecipes(new ItemStack(Items.ender_eye, 1), inputList));
- // 删除指定有序合成
- RecipeRemover.removeShapedRecipe(new ShapedRecipes(1, 1, new ItemStack[]{new ItemStack(Blocks.log, 1, BlockPlanks.EnumType.OAK.getMetadata())}, new ItemStack(Blocks.planks, 4, BlockPlanks.EnumType.OAK.getMetadata())));
这三个方法分别删除了木棍,末影之眼和橡木木板的合成,放到你的init里面(注意不是preInit或者是postInit)就行了
fyfly 发表于 2015-8-12 21:42
花了十几分钟写了个Helper类,吐槽一下MC坑爹的代码,ItemStack和IRecipe的equals()方法竟然都没有Overri ...
补充一下原理:
通过下面这段代码可以获取所有注册过的合成表,类型为List(其实是List<IRecipe>,但是要转换):
- List recipeList = CraftingManager.getInstance().getRecipeList();
获取之后你就可以随意操作这个List了,如果想要删除一个配方,直接使用remove()方法就行了。
我的那个Helper目前暂时无法修改使用OreDict的配方(不过你改的原版配方应该用不到),回来再改,不过如果使用利用物品删的那个是可以的。
推荐如果不是有多种合成方法的,都用查找物品那个方法删,那个肯定是没问题的,不过只能删一个配方。另外如果你不知道如何创建ShapedRecipes和ShapelessRecipes可以去CraftingManager的addRecipe和addShapelessRecipe来查看,虽然的确复杂了点。
fyfly 发表于 2015-8-12 22:30
补充一下原理:
通过下面这段代码可以获取所有注册过的合成表,类型为List(其实是List,但是要转换):
继续更新,已经添加了OreDictionary的支持,脑子抽了拖得有点久,地址仍然在这里不变: https://gist.github.com/Meow-J/61e2ab64a9bd5a48447b
示例:
- RecipeRemover.removeShapedOreRecipe(new ShapedOreRecipe(Items.minecart, "X X", "XXX", 'X', "ingotIron"));
- RecipeRemover.removeShapelessOreRecipe(new ShapelessOreRecipe(Items.flint_and_steel, Items.flint, "ingotIron"));
仍然和上面一样添加到Init里面,现在这两行代码删除了矿车和打火石的配方,不得不承认Forge终于把Recipe的构造器改得像人样了。注意原版一共有200+配方被替换成了OreDictionary形式,如果用上上贴那两个方法是不能删除的(当然如果只搜索物品删除还是可以的)。
对了,我一直是在1.8版本下的测试的,到1.7.10应该也一样,如果不行再叫我。还有一点,每个方法都是有返回值的,如果删除成功会返回true,删除失败会返回false.
fyfly 发表于 2015-8-13 01:08
继续更新,已经添加了OreDictionary的支持,脑子抽了拖得有点久,地址仍然在这里不变: https://gist.gith ...
鉴于最近各种屏蔽外网,现在把代码直接从Gist上贴上来,我仍然建议你去Gist上查看代码: https://gist.github.com/Meow-J/61e2ab64a9bd5a48447b
代码(注:Meow J就是我,代码很难看别吐槽了orz):
- /**
- * A collection of methods that help remove recipes from the registered recipes list.(Code is soooooooo ugly. I blame Mojang)
- *
- * [url=home.php?mod=space&uid=1231151]@author[/url] Meow J
- */
- public class RecipeRemover {
- /**
- * Removes the first recipe found by its output.
- *
- * @param stack The output itemStack
- * [url=home.php?mod=space&uid=491268]@Return[/url] true if successfully removed the recipe
- */
- public static boolean removeRecipe(ItemStack stack) {
- for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
- if (rcp != null && rcp instanceof IRecipe && ((IRecipe) rcp).getRecipeOutput() != null
- && ((IRecipe) rcp).getRecipeOutput().isItemEqual(stack)) {
- CraftingManager.getInstance().getRecipeList().remove(rcp);
- return true;
- }
- }
- return false;
- }
- /**
- * Remove the exact shaped recipe from the registered recipe list.
- *
- * @param shapedRecipe The shaped recipe you want to remove
- * @return true if successfully removed the recipe
- */
- public static boolean removeShapedRecipe(ShapedRecipes shapedRecipe) {
- for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
- if (rcp != null && rcp instanceof ShapedRecipes && shapedRecipe.getRecipeOutput().isItemEqual(((ShapedRecipes) rcp).getRecipeOutput())
- && shapedRecipe.recipeItems.length == ((ShapedRecipes) rcp).recipeItems.length) {
- // The equals() method in IRecipe is not overridden!!!!!!!!
- boolean equalRecipe = true;
- ItemStack stack1, stack2;
- for (int i = 0; i < shapedRecipe.recipeItems.length; ++i) {
- stack1 = shapedRecipe.recipeItems[i];
- stack2 = ((ShapedRecipes) rcp).recipeItems[i];
- if (!(stack1 == null && stack2 == null || ((stack1 != null && stack2 != null) && stack1.isItemEqual(stack2))))
- equalRecipe = false;
- }
- if (equalRecipe) {
- CraftingManager.getInstance().getRecipeList().remove(rcp);
- return true;
- }
- }
- }
- return false;
- }
- /**
- * Remove the exact shapeless recipe from the registered recipe list.
- *
- * @param shapelessRecipes The shapeless recipe you want to remove
- * @return true if successfully removed the recipe
- */
- @SuppressWarnings("unchecked")
- public static boolean removeShapelessRecipe(ShapelessRecipes shapelessRecipes) {
- for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
- if (rcp != null && rcp instanceof ShapelessRecipes && shapelessRecipes.getRecipeOutput().isItemEqual(((ShapelessRecipes) rcp).getRecipeOutput())) {
- if (areItemStackListsEqual(shapelessRecipes.recipeItems, ((ShapelessRecipes) rcp).recipeItems)) {
- CraftingManager.getInstance().getRecipeList().remove(rcp);
- return true;
- }
- }
- }
- return false;
- }
- /**
- * Remove the exact shaped ore recipe from the registered recipe list.
- *
- * @param shapedOreRecipe The shaped ore recipe you want to remove
- * @return true if successfully removed the recipe
- */
- @SuppressWarnings("unchecked")
- public static boolean removeShapedOreRecipe(ShapedOreRecipe shapedOreRecipe) {
- for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
- if (rcp != null && rcp instanceof ShapedOreRecipe && shapedOreRecipe.getRecipeOutput().isItemEqual(((ShapedOreRecipe) rcp).getRecipeOutput())
- && shapedOreRecipe.getInput().length == ((ShapedOreRecipe) rcp).getInput().length) {
- boolean equalRecipe = true;
- Object stack1, stack2;
- for (int i = 0; i < shapedOreRecipe.getInput().length; ++i) {
- stack1 = shapedOreRecipe.getInput()[i];
- stack2 = ((ShapedOreRecipe) rcp).getInput()[i];
- if (stack1 instanceof ItemStack && stack2 instanceof ItemStack) {
- if (!((ItemStack) stack1).isItemEqual(((ItemStack) stack2)))
- equalRecipe = false;
- } else if (stack1 instanceof List && stack2 instanceof List) {
- if (!areItemStackListsEqual((List<ItemStack>) stack1, (List<ItemStack>) stack2))
- equalRecipe = false;
- } else if (stack1 == null || stack2 == null) {
- // My brain explodes
- if (stack1 != null || stack2 != null) {
- equalRecipe = false;
- }
- } else {
- equalRecipe = false;
- }
- }
- if (equalRecipe) {
- CraftingManager.getInstance().getRecipeList().remove(rcp);
- return true;
- }
- }
- }
- return false;
- }
- /**
- * Remove the exact shapeless ore recipe from the registered recipe list.
- *
- * @param shapelessOreRecipe The shaped ore recipe you want to remove
- * @return true if successfully removed the recipe
- */
- @SuppressWarnings("unchecked")
- public static boolean removeShapelessOreRecipe(ShapelessOreRecipe shapelessOreRecipe) {
- for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
- if (rcp != null && rcp instanceof ShapelessOreRecipe && shapelessOreRecipe.getRecipeOutput().isItemEqual(((ShapelessOreRecipe) rcp).getRecipeOutput())) {
- boolean equalRecipe = true;
- for (Object stack1 : shapelessOreRecipe.getInput()) {
- boolean equalItem = false;
- for (Object stack2 : ((ShapelessOreRecipe) rcp).getInput()) {
- if (stack1 instanceof ItemStack && stack2 instanceof ItemStack) {
- if (((ItemStack) stack1).isItemEqual(((ItemStack) stack2)))
- equalItem = true;
- } else if (stack1 instanceof List && stack2 instanceof List) {
- if (areItemStackListsEqual(((List) stack1), (List) stack2))
- equalItem = true;
- }
- }
- if (!equalItem) equalRecipe = false;
- }
- if (equalRecipe) {
- CraftingManager.getInstance().getRecipeList().remove(rcp);
- return true;
- }
- }
- }
- return false;
- }
- /**
- * Determine whether the two input lists are equal
- *
- * @return true if the two lists are equal
- */
- private static boolean areItemStackListsEqual(List<ItemStack> list1, List<ItemStack> list2) {
- // The equals() method in ItemStack is not overridden!!!!!!!!
- boolean equalList = true;
- for (ItemStack stack1 : list1) {
- boolean containsItem = false;
- for (ItemStack stack2 : list2) {
- if (stack1 != null && stack2 != null && stack1.isItemEqual(stack2))
- containsItem = true;
- }
- if (!containsItem) equalList = false;
- }
- return equalList;
- }
- }
fyfly 发表于 2015-8-13 14:08
鉴于最近各种屏蔽外网,现在把代码直接从Gist上贴上来,我仍然建议你去Gist上查看代码: https://gist.git ...
代码被mcbbs编辑器搞得有点问题,还是建议去Gist上看
minetweaker转载自Minetweaker wiki
1.6.4
1.7
简单来说就是打代码
例如recipes.removeShapeless(<tile.cloth:*>, [<tile.cloth>]); 移除所有羊毛染色配方recipes.remove(<minecraft:stick>); 移除输出木棍的所有配方
1.6.4
1.7
简单来说就是打代码
例如recipes.removeShapeless(<tile.cloth:*>, [<tile.cloth>]); 移除所有羊毛染色配方recipes.remove(<minecraft:stick>); 移除输出木棍的所有配方
MC.cdasc 发表于 2015-8-13 17:42
minetweaker转载自Minetweaker wiki
1.6.4
有1.8的吗??
1048139283 发表于 2015-8-13 17:53
有1.8的吗??
那几个命令是mod定义出来的脚本(并且不是代码!)必须要安装mod才能够使用。如果你想自己写mod删除原版的合成方法,请看我上面的几个帖子,用我的那个RecipeHelper。(正好对应是1.8版本的)