Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Armor won't repair


Hamster_Furtif
 Share

Recommended Posts

Hey !

I have created a custom armor (actually, it's only a helmet), but it doesn't repairs.

Here is the code:

public class ItemMask extends ItemArmor{

public ItemMask(String nom) {
	super(Masks.armorMask, 1, 0);
	this.setMaxDamage(2);
	this.setUnlocalizedName("mask_"+nom);
	this.canRepair = true;
	this.setCreativeTab(Masks.tabMasks);


}

@Override
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
	return repair.getItem() == Items.clay_ball ? true : false;
}
}

 

Here is the ArmorMaterial:

	static int[] a = {1,1,1,1};
public static ArmorMaterial armorMask = EnumHelper.addArmorMaterial("armorMask", "mask", 2, a, 0);

 

And even this doesn't work:

 

@Override
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
	return true;
}

And there is something else: the armor doesn't break when it has 0HP, it takes one more hit to break it.

 

Thank you for your help !

 

Link to comment
Share on other sites

I think it is normal that the armor breaks when it has -1HP.

 

Try instead of

return repair.getItem() == Items.clay_ball ? true : false;[/Code]

 
[code]    @Override
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
                //input is the itemStack to be repaired, repair is the itemStack that should repair this item.
                //Change the bronze items to your own.
	return input.getItem() == MyItems.bronze_helmet && repair.getItem() == MyItems.bronze_ingot;
}

 

Also, the

? true : false[/Code]

is not necessary, "input.getItem() instanceof ItemBronzeArmor && repair.getItem() == MyItems.bronze_ingo" already returns false or true.

 

Hope this helps.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

 @Override
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
                //input is the itemStack to be repaired, repair is the itemStack that should repair this item.
                //Change the bronze items to your own.
	return input.getItem() == MyItems.bronze_helmet && repair.getItem() == MyItems.bronze_ingot;
}

This is not working. The weird thing is that it didn't work with:

@Override
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
	return true;
}

 

And I know adding

? true : false

is useless, but I tried everything I could.  :(

 

 

Link to comment
Share on other sites

System.out.println("Trying to repair: " + input.getItem() == MyItems.bronze_helmet + " && " + repair.getItem() == MyItems.bronze_ingot);

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

What you sent me caused an error, so I used this:

		System.out.println("Trying to repair: ");
	System.out.println(input.getItem() == Masks.mask_cow);
	System.out.println("&&");
	System.out.println(repair.getItem() == Items.clay_ball);
	return input.getItem() == Masks.mask_cow && repair.getItem() == Items.clay_ball;

 

And it printed:

Trying to repair
true
&&
true

Link to comment
Share on other sites

The latest version is:

package com.hamsterfurtif.masks.masques;

import net.minecraft.init.Items;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

import com.hamsterfurtif.masks.Masks;

public class ItemMask extends ItemArmor{

public ItemMask(String nom) {
	super(Masks.armorMask, 1, 0);
	this.setMaxDamage(2);
	this.setUnlocalizedName("mask_"+nom);
	this.canRepair = true;
	this.setCreativeTab(Masks.tabMasks);


}

@Override
public boolean getIsRepairable(ItemStack input, ItemStack repair)
{
	boolean compatible = false;
	for (int i=0; i < Masks.masques.length; i++)
	{
		System.out.println("Trying to repair: ");
		System.out.println(input.getItem() == Masks.masques[i]);
		System.out.println("&&");
		System.out.println(repair.getItem() == Items.clay_ball);


			if (input.getItem() == Masks.masques[i] && repair.getItem() == Items.clay_ball)
				compatible = true;

	}

	return compatible;
}
}

 

With this in the main class:

public static Item mask_clay = new ItemMask("clay");
public static Item mask_spider = new ItemMaskSpider();
public static Item mask_cow = new ItemMaskCow();
public static Item mask_mouton = new ItemMaskMouton();
public static Item mask_gardien = new ItemMaskGardien();
public static Item mask_squelette = new ItemMaskSquelette();
    
public static Item[] masques= {mask_clay, mask_spider, mask_cow, mask_mouton, mask_gardien, mask_squelette};

 

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I'm not sure if its true for 1.8 but after some lengthy research I came across the solution for 1.7.10.

 

Remove that getIsRepairable from your itemarmor class and put this in your main registry class/method put the following.

 

//your enum name fallowed by the .customCraftingMaterial, than just set it to your item you want it to repair.
ARMORCOPPER.customCraftingMaterial = ingotCopper;

 

I use a register method, and I put this after everything was set in that method.

 

So [Made in short hand]:

 

Main class

@mod()
public void preInit()
MyModsItemClass.registerItems();

 

MyModsItemClass class

public static final ItemArmor.ArmorMaterial ARMORCOPPER = EnumHelper.addArmorMaterial("COPPER", 10, new int[]{2,3,2,2}, 12);

public static Item myArmor;
public static Item ingotCopper

public static void registerItems(){

  myArmor = new MyArmor(ARMORCOPPER, 0, 0, "", "");

  ingotCopper = new MyItems();

  ARMORCOPPER.customCraftingMaterial = ingotCopper;

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Your command is wrong, you are missing the -jar option C:\forge>java -jar forge-1.16.5-36.2.34.jar
    • p.s. I reset windows on the server because I originally thought it might have been an issue of newer java version conflicts
    • [01Jul2022 07:51:52.834] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.34, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge] [01Jul2022 07:51:52.834] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_332 by Temurin [01Jul2022 07:51:53.193] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [01Jul2022 07:51:53.240] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/forge/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=SERVER [01Jul2022 07:51:54.193] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, .]  
    • I have tried 5 versions of java 8 (Open JDK, ZULU, JRE 8u333, 8u321, 8u291) The error i receive is regardless of version reads as follows: C:\forge>java forge-1.16.5-36.2.34.jar Error: Could not find or load main class forge-1.16.5-36.2.34.jar I can load a vanilla minecraft server just fine, this only occurs when loading Forge. I can also point directly to the java 8 install java.exe and the same occurs. It seems this line is a syntax error that is common for all of this [07:49:22] [main/INFO] [STDERR/]: [org.antlr.v4.runtime.ConsoleErrorListener:syntaxError:38]: line 1:0 token recognition error at: '~'
    • So I tried to download mods and play with them on minecraft forge 1.12.2.  When I tried to launch an error came and there was this text : The game crashed whilst initializing game Error: java.util.zip.ZipError: zip END header not found Exit-Code: -1 I don't know what that means but I want to fix it. Then I opened the crash report and this popped up : ---- Minecraft Crash Report ---- // Why did you do that? Time: 7/1/22 4:30 PM Description: Initializing game java.util.zip.ZipError: zip END header not found at com.sun.nio.zipfs.ZipFileSystem.zerror(ZipFileSystem.java:1605) at com.sun.nio.zipfs.ZipFileSystem.findEND(ZipFileSystem.java:1021) at com.sun.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1030) at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:130) at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139) at java.nio.file.FileSystems.newFileSystem(FileSystems.java:390) at net.minecraftforge.common.crafting.CraftingHelper.loadFactories(CraftingHelper.java:657) at net.minecraftforge.common.crafting.CraftingHelper.loadFactories(CraftingHelper.java:644) at net.minecraftforge.common.crafting.CraftingHelper$$Lambda$1075/413509104.accept(Unknown Source) at java.util.ArrayList.forEach(ArrayList.java:1249) at net.minecraftforge.common.crafting.CraftingHelper.loadRecipes(CraftingHelper.java:632) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:747) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336) at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378) at net.minecraft.client.main.Main.main(SourceFile:123) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.sun.nio.zipfs.ZipFileSystem.zerror(ZipFileSystem.java:1605) at com.sun.nio.zipfs.ZipFileSystem.findEND(ZipFileSystem.java:1021) at com.sun.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1030) at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:130) at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139) at java.nio.file.FileSystems.newFileSystem(FileSystems.java:390) at net.minecraftforge.common.crafting.CraftingHelper.loadFactories(CraftingHelper.java:657) at net.minecraftforge.common.crafting.CraftingHelper.loadFactories(CraftingHelper.java:644) at net.minecraftforge.common.crafting.CraftingHelper$$Lambda$1075/413509104.accept(Unknown Source) at java.util.ArrayList.forEach(ArrayList.java:1249) at net.minecraftforge.common.crafting.CraftingHelper.loadRecipes(CraftingHelper.java:632) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:747) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336) at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535)  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.