Everything posted by Frontsalat
-
Damage Item when use in craft recipes code works, but crafting item with itself?
Basically I was using code from inside this thread, to make items getting damaged when used in certain crafting recipes. This turned out to be working very good, but unfortunately rendered one nasty bug, that I can't get seem to get solved. What happens if I use two of the same damageable items in the crafting menu, it will craft the same item, see this picture to understand what I mean: What you see in the picture is a mortar and pestle that should regularily be used to crush sugar cane, which, like mentioned before, works perfectly fine. But getting an undamaged item out of crafting the item with itself, was not exactly what I wanted. It does not matter if I use two damaged or two undamaged items, or combine damaged and undamaged items, it does however, not do that when I put more then two item into the crafting menu. Here's the code I'm using... Any idea?
-
New tool does not get recognized as tool when using .setRequiresTool on wood
public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.wood.blockID || par1Block.blockID == Block.chest.blockID || par1Block.blockID == Block.planks.blockID || par1Block.blockID == Block.bookShelf.blockID || par1Block.blockID == Block.stoneDoubleSlab.blockID || par1Block.blockID == Block.stoneSingleSlab.blockID || par1Block.blockID == Block.pumpkin.blockID || par1Block.blockID == Block.pumpkinLantern.blockID; }
-
New tool does not get recognized as tool when using .setRequiresTool on wood
I think I found the solution. Of what ever reason the game treated my tool as weapon, so I had to put this code snippet into the axe class... public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.wood.blockID; } ...I believe that the video tutorial that learned me how to import tools/weapons mixed both items. It's obvious that tools need another method of coding. However, it's working now, plus the code like I imported now, is much easier then the actual tool code needed...
-
New tool does not get recognized as tool when using .setRequiresTool on wood
Again me, the title basically says it. I'm using a reflection method in my main class to prevent chopping wood with your bare hands, so that you'll need proper tools to actually chop the wood. Works fine so far, but when trying to chop the wood with one of my newly imported copper axe (which I assume is the proper tool), it does not harvest the wooden block. Either it does not get recognized as tool, or it is recognized as weapon. But then, there seems to benothing wrong with the code? Axe Code package MetallurgyRealism; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemAxe; public class ToolAxeCopper extends ItemAxe{ public ToolAxeCopper(int i, EnumToolMaterial enumToolMaterial){ super(i, enumToolMaterial); setMaxStackSize(1); setCreativeTab(MetallurgyRealismModBase.MetallurgyRealismTab); } @Override public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("MetallurgyRealism:axecopper"); } } Enum Code public static EnumToolMaterial CopperMaterial = EnumHelper.addToolMaterial("CopperMaterial", 3, 5, 15.0F, 1, 15); Register and ID code public static Item toolAxeCopper; int toolAxeCopperID = 6029; toolAxeCopper = new ToolAxeCopper(toolAxeCopperID, CopperMaterial).setUnlocalizedName("axecopper"); GameRegistry.registerItem(toolAxeCopper, "ToolAxeCopper"); LanguageRegistry.addName(toolAxeCopper, "Copper Axe");
-
Reflection method working in Eclipse, not in universal forged Minecraft!
Thank you very much. Works like a charm now. Could you answer another question then? I set up a new copper axe as tool, but when trying to chop wood with it (when including the code that prevents chopping wood with your bare hands only), the axe does not seem to get recognized as tool, but rather as normal weapon, or the wrong tool. Here's the code: Axe Code package MetallurgyRealism; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemAxe; public class ToolAxeCopper extends ItemAxe{ public ToolAxeCopper(int i, EnumToolMaterial enumToolMaterial){ super(i, enumToolMaterial); setMaxStackSize(1); setCreativeTab(MetallurgyRealismModBase.MetallurgyRealismTab); } @Override public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("MetallurgyRealism:axecopper"); } } Enum Code public static EnumToolMaterial CopperMaterial = EnumHelper.addToolMaterial("CopperMaterial", 3, 5, 15.0F, 1, 15); Register and ID code public static Item toolAxeCopper; int toolAxeCopperID = 6029; toolAxeCopper = new ToolAxeCopper(toolAxeCopperID, CopperMaterial).setUnlocalizedName("axecopper"); GameRegistry.registerItem(toolAxeCopper, "ToolAxeCopper"); LanguageRegistry.addName(toolAxeCopper, "Copper Axe");
-
Reflection method working in Eclipse, not in universal forged Minecraft!
Hey folks, I'm having this code... Method m = ReflectionHelper.findMethod(Material.class, Material.wood, new String[] {"f", "setRequiresTool"}); try { m.invoke(Material.wood); } catch (Throwable t) { t.printStackTrace(); } public void breakSpeed(PlayerEvent.BreakSpeed event) { if (event.block.blockMaterial == Material.wood) { if (!ForgeHooks.canToolHarvestBlock(event.block, event.metadata, event.entityPlayer.getCurrentEquippedItem())) event.newSpeed = 0f; } } ...which makes it so that you can't harvest wood without proper tools. This is working perfectly in Eclipse, but does not after reobfuscating and using it on a universal forged Minecraft. I'm aware that "f", "setRequiresTool" gets reobfuscated to something that Minecraft can't read. Anyone has an idea how to transport the source code to something properly reobfuscated and useable in Minecraft?
IPS spam blocked by CleanTalk.