JIE__
RT,请附上指令,和way

泰米瑞斯
哈?这是mod问答版撒,如果要再服务器禁止物品的话,可以用banitem插件哦。(mod物品也可用)
指令是/banitem+物品ID

JIE__
泰米瑞斯 发表于 2015-8-11 15:00
哈?这是mod问答版撒,如果要再服务器禁止物品的话,可以用banitem插件哦。(mod物品也可用)
指令是/banit ...

不是服务器,请看清楚标题

泰米瑞斯
1048139283 发表于 2015-8-11 15:03
不是服务器,请看清楚标题

这就复杂了、、应该针对客户端修改N个java文件...

theEinstein
http://www.mcbbs.net/thread-306970-1-1.html用这个mod就可以了

JIE__
我要源代码=.=

ksjsk
一看到RT就想到了我刚做的解直角三角形的题。

west.myth
不需要自定义合成mod,只要在npc mod全局设置里删掉你不要的合成方式即可。满意请给最佳,如有问题请回复我,我会尽力为你解答

JIE__
我要源代码=.=

west.myth

[1.8beta-1.6.x][SSP/SMP/LAN]Custom NPCs-自定义NPC[1710d更新]
http://www.mcbbs.net/thread-165632-1-1.html
下载这个mod,用npc魔杖右击地面打开全局设置,然后你会看到一个管理合成的菜单,在里面编辑你想要的合成方式即可

JIE__
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的语法

west.myth
1048139283 发表于 2015-8-12 06:45
我不要mod啊
我要反注册的代码
java的语法

原版删除我不知道,但要删mod合成方式我还是略懂。除非你会做mod,否则只有npc mod是可以做到你的要求并且方法够简单。其实npcmod挺好的,你要ban物品合成是为了服务器吧?(我的猜测)很多服都有npc mod。如果真的是服务器,插件就够了

JIE__
west.myth 发表于 2015-8-12 12:09
原版删除我不知道,但要删mod合成方式我还是略懂。除非你会做mod,否则只有npc mod是可以做到你的要求并 ...

就是做mod,不知道才问的

2545320709
west.myth 发表于 2015-8-11 18:11
不需要自定义合成mod,只要在npc mod全局设置里删掉你不要的合成方式即可。满意请给最佳,如有问题请回复我 ...

NPCmod只能删除NPCmod新创建的合成,其他的都不行

fyfly
1048139283 发表于 2015-8-12 12:42
就是做mod,不知道才问的

花了十几分钟写了个Helper类,吐槽一下MC坑爹的代码,ItemStack和IRecipe的equals()方法竟然都没有Override,导致我的写的这个方法这么麻烦。

这个类我放在Gist上,你可以到这里来查看: https://gist.github.com/Meow-J/61e2ab64a9bd5a48447b
由于代码太多而且不好看就不贴在论坛里了,如果你打不开我再帮你贴过来。

使用:
  1.         // 删除指定物品的合成
  2.         RecipeRemover.removeRecipe(new ItemStack(Items.stick));

  3.         // 删除指定无序合成
  4.         List<ItemStack> inputList = new ArrayList<ItemStack>();
  5.         inputList.add(new ItemStack(Items.ender_pearl, 1));
  6.         inputList.add(new ItemStack(Items.blaze_powder, 1));

  7.         RecipeRemover.removeShapelessRecipe(new ShapelessRecipes(new ItemStack(Items.ender_eye, 1), inputList));
  8.         // 删除指定有序合成
  9.         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
fyfly 发表于 2015-8-12 21:42
花了十几分钟写了个Helper类,吐槽一下MC坑爹的代码,ItemStack和IRecipe的equals()方法竟然都没有Overri ...

补充一下原理:

通过下面这段代码可以获取所有注册过的合成表,类型为List(其实是List<IRecipe>,但是要转换):
  1. List recipeList = CraftingManager.getInstance().getRecipeList();
复制代码

获取之后你就可以随意操作这个List了,如果想要删除一个配方,直接使用remove()方法就行了。

我的那个Helper目前暂时无法修改使用OreDict的配方(不过你改的原版配方应该用不到),回来再改,不过如果使用利用物品删的那个是可以的。

推荐如果不是有多种合成方法的,都用查找物品那个方法删,那个肯定是没问题的,不过只能删一个配方。另外如果你不知道如何创建ShapedRecipes和ShapelessRecipes可以去CraftingManager的addRecipe和addShapelessRecipe来查看,虽然的确复杂了点。

fyfly
fyfly 发表于 2015-8-12 22:30
补充一下原理:

通过下面这段代码可以获取所有注册过的合成表,类型为List(其实是List,但是要转换):

继续更新,已经添加了OreDictionary的支持,脑子抽了拖得有点久,地址仍然在这里不变: https://gist.github.com/Meow-J/61e2ab64a9bd5a48447b

示例:
  1.         RecipeRemover.removeShapedOreRecipe(new ShapedOreRecipe(Items.minecart, "X X", "XXX", 'X', "ingotIron"));
  2.         RecipeRemover.removeShapelessOreRecipe(new ShapelessOreRecipe(Items.flint_and_steel, Items.flint, "ingotIron"));
复制代码

仍然和上面一样添加到Init里面,现在这两行代码删除了矿车和打火石的配方,不得不承认Forge终于把Recipe的构造器改得像人样了。注意原版一共有200+配方被替换成了OreDictionary形式,如果用上上贴那两个方法是不能删除的(当然如果只搜索物品删除还是可以的)。

对了,我一直是在1.8版本下的测试的,到1.7.10应该也一样,如果不行再叫我。还有一点,每个方法都是有返回值的,如果删除成功会返回true,删除失败会返回false.

fyfly
fyfly 发表于 2015-8-13 01:08
继续更新,已经添加了OreDictionary的支持,脑子抽了拖得有点久,地址仍然在这里不变: https://gist.gith ...

鉴于最近各种屏蔽外网,现在把代码直接从Gist上贴上来,仍然建议你去Gist上查看代码: https://gist.github.com/Meow-J/61e2ab64a9bd5a48447b

代码(注:Meow J就是我,代码很难看别吐槽了orz):
  1. /**
  2. * A collection of methods that help remove recipes from the registered recipes list.(Code is soooooooo ugly. I blame Mojang)
  3. *
  4. * [url=home.php?mod=space&uid=1231151]@author[/url] Meow J
  5. */
  6. public class RecipeRemover {

  7.     /**
  8.      * Removes the first recipe found by its output.
  9.      *
  10.      * @param stack The output itemStack
  11.      * [url=home.php?mod=space&uid=491268]@Return[/url] true if successfully removed the recipe
  12.      */
  13.     public static boolean removeRecipe(ItemStack stack) {
  14.         for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
  15.             if (rcp != null && rcp instanceof IRecipe && ((IRecipe) rcp).getRecipeOutput() != null
  16.                     && ((IRecipe) rcp).getRecipeOutput().isItemEqual(stack)) {
  17.                 CraftingManager.getInstance().getRecipeList().remove(rcp);
  18.                 return true;
  19.             }
  20.         }
  21.         return false;
  22.     }

  23.     /**
  24.      * Remove the exact shaped recipe from the registered recipe list.
  25.      *
  26.      * @param shapedRecipe The shaped recipe you want to remove
  27.      * @return true if successfully removed the recipe
  28.      */
  29.     public static boolean removeShapedRecipe(ShapedRecipes shapedRecipe) {
  30.         for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
  31.             if (rcp != null && rcp instanceof ShapedRecipes && shapedRecipe.getRecipeOutput().isItemEqual(((ShapedRecipes) rcp).getRecipeOutput())
  32.                     && shapedRecipe.recipeItems.length == ((ShapedRecipes) rcp).recipeItems.length) {
  33.                 // The equals() method in IRecipe is not overridden!!!!!!!!
  34.                 boolean equalRecipe = true;
  35.                 ItemStack stack1, stack2;
  36.                 for (int i = 0; i < shapedRecipe.recipeItems.length; ++i) {
  37.                     stack1 = shapedRecipe.recipeItems[i];
  38.                     stack2 = ((ShapedRecipes) rcp).recipeItems[i];
  39.                     if (!(stack1 == null && stack2 == null || ((stack1 != null && stack2 != null) && stack1.isItemEqual(stack2))))
  40.                         equalRecipe = false;
  41.                 }
  42.                 if (equalRecipe) {
  43.                     CraftingManager.getInstance().getRecipeList().remove(rcp);
  44.                     return true;
  45.                 }
  46.             }
  47.         }
  48.         return false;
  49.     }

  50.     /**
  51.      * Remove the exact shapeless recipe from the registered recipe list.
  52.      *
  53.      * @param shapelessRecipes The shapeless recipe you want to remove
  54.      * @return true if successfully removed the recipe
  55.      */
  56.     @SuppressWarnings("unchecked")
  57.     public static boolean removeShapelessRecipe(ShapelessRecipes shapelessRecipes) {
  58.         for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
  59.             if (rcp != null && rcp instanceof ShapelessRecipes && shapelessRecipes.getRecipeOutput().isItemEqual(((ShapelessRecipes) rcp).getRecipeOutput())) {
  60.                 if (areItemStackListsEqual(shapelessRecipes.recipeItems, ((ShapelessRecipes) rcp).recipeItems)) {
  61.                     CraftingManager.getInstance().getRecipeList().remove(rcp);
  62.                     return true;
  63.                 }
  64.             }
  65.         }
  66.         return false;
  67.     }

  68.     /**
  69.      * Remove the exact shaped ore recipe from the registered recipe list.
  70.      *
  71.      * @param shapedOreRecipe The shaped ore recipe you want to remove
  72.      * @return true if successfully removed the recipe
  73.      */
  74.     @SuppressWarnings("unchecked")
  75.     public static boolean removeShapedOreRecipe(ShapedOreRecipe shapedOreRecipe) {
  76.         for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
  77.             if (rcp != null && rcp instanceof ShapedOreRecipe && shapedOreRecipe.getRecipeOutput().isItemEqual(((ShapedOreRecipe) rcp).getRecipeOutput())
  78.                     && shapedOreRecipe.getInput().length == ((ShapedOreRecipe) rcp).getInput().length) {
  79.                 boolean equalRecipe = true;
  80.                 Object stack1, stack2;
  81.                 for (int i = 0; i < shapedOreRecipe.getInput().length; ++i) {
  82.                     stack1 = shapedOreRecipe.getInput()[i];
  83.                     stack2 = ((ShapedOreRecipe) rcp).getInput()[i];
  84.                     if (stack1 instanceof ItemStack && stack2 instanceof ItemStack) {
  85.                         if (!((ItemStack) stack1).isItemEqual(((ItemStack) stack2)))
  86.                             equalRecipe = false;
  87.                     } else if (stack1 instanceof List && stack2 instanceof List) {
  88.                         if (!areItemStackListsEqual((List<ItemStack>) stack1, (List<ItemStack>) stack2))
  89.                             equalRecipe = false;
  90.                     } else if (stack1 == null || stack2 == null) {
  91.                         // My brain explodes
  92.                         if (stack1 != null || stack2 != null) {
  93.                             equalRecipe = false;
  94.                         }
  95.                     } else {
  96.                         equalRecipe = false;
  97.                     }
  98.                 }
  99.                 if (equalRecipe) {
  100.                     CraftingManager.getInstance().getRecipeList().remove(rcp);
  101.                     return true;
  102.                 }
  103.             }
  104.         }
  105.         return false;
  106.     }

  107.     /**
  108.      * Remove the exact shapeless ore recipe from the registered recipe list.
  109.      *
  110.      * @param shapelessOreRecipe The shaped ore recipe you want to remove
  111.      * @return true if successfully removed the recipe
  112.      */
  113.     @SuppressWarnings("unchecked")
  114.     public static boolean removeShapelessOreRecipe(ShapelessOreRecipe shapelessOreRecipe) {
  115.         for (Object rcp : CraftingManager.getInstance().getRecipeList()) {
  116.             if (rcp != null && rcp instanceof ShapelessOreRecipe && shapelessOreRecipe.getRecipeOutput().isItemEqual(((ShapelessOreRecipe) rcp).getRecipeOutput())) {
  117.                 boolean equalRecipe = true;
  118.                 for (Object stack1 : shapelessOreRecipe.getInput()) {
  119.                     boolean equalItem = false;
  120.                     for (Object stack2 : ((ShapelessOreRecipe) rcp).getInput()) {
  121.                         if (stack1 instanceof ItemStack && stack2 instanceof ItemStack) {
  122.                             if (((ItemStack) stack1).isItemEqual(((ItemStack) stack2)))
  123.                                 equalItem = true;
  124.                         } else if (stack1 instanceof List && stack2 instanceof List) {
  125.                             if (areItemStackListsEqual(((List) stack1), (List) stack2))
  126.                                 equalItem = true;
  127.                         }
  128.                     }
  129.                     if (!equalItem) equalRecipe = false;
  130.                 }
  131.                 if (equalRecipe) {
  132.                     CraftingManager.getInstance().getRecipeList().remove(rcp);
  133.                     return true;
  134.                 }
  135.             }
  136.         }
  137.         return false;
  138.     }

  139.     /**
  140.      * Determine whether the two input lists are equal
  141.      *
  142.      * @return true if the two lists are equal
  143.      */
  144.     private static boolean areItemStackListsEqual(List<ItemStack> list1, List<ItemStack> list2) {
  145.         // The equals() method in ItemStack is not overridden!!!!!!!!
  146.         boolean equalList = true;

  147.         for (ItemStack stack1 : list1) {
  148.             boolean containsItem = false;
  149.             for (ItemStack stack2 : list2) {
  150.                 if (stack1 != null && stack2 != null && stack1.isItemEqual(stack2))
  151.                     containsItem = true;
  152.             }
  153.             if (!containsItem) equalList = false;
  154.         }
  155.         return equalList;
  156.     }
  157. }
复制代码




fyfly
fyfly 发表于 2015-8-13 14:08
鉴于最近各种屏蔽外网,现在把代码直接从Gist上贴上来,我仍然建议你去Gist上查看代码: https://gist.git ...

代码被mcbbs编辑器搞得有点问题,还是建议去Gist上看

MC.cdasc
minetweaker转载自Minetweaker wiki
1.6.4


1.7


简单来说就是打代码
例如recipes.removeShapeless(<tile.cloth:*>, [<tile.cloth>]); 移除所有羊毛染色配方recipes.remove(<minecraft:stick>); 移除输出木棍的所有配方

JIE__
MC.cdasc 发表于 2015-8-13 17:42
minetweaker转载自Minetweaker wiki
1.6.4

有1.8的吗??

fyfly

那几个命令是mod定义出来的脚本(并且不是代码!)必须要安装mod才能够使用。如果你想自己写mod删除原版的合成方法,请看我上面的几个帖子,用我的那个RecipeHelper。(正好对应是1.8版本的)