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

[Solved] Making a RP2 Handsaw type item help.


Rowsell99
 Share

Recommended Posts

I'm working on a mod at the moment and I'm trying to make a Red Power 2 handsaw or Equivalent Exchange 3 minium stone type item where you can use it in a crafting recipe and it will give it back but more damaged but I cant figure out how, if anybody knew I would be really thankful.

Link to comment
Share on other sites

Hey,

you need a crafting handler, create a new class an name it as you want.

Then define it in your mod_xxx.java in the "public void init..." method with

GameRegistry.registerCraftingHandler(new CraftingHandler());

In this example I called the CraftingHandler "CraftingHandler" :)

Now you have to make your Item and then add the following:

aloeVeraMilk = (new ItemXXX(975)).setIconIndex(75).setItemName("Test Item").setMaxDamage(10); // Add your Max. Damge here!!!

Now we want, that you won't loose your Item after crafting. Go the crafting handler and add:

public class CraftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {

	for(int i=0; i < craftMatrix.getSizeInventory(); i++)
    {
        if(craftMatrix.getStackInSlot(i) != null)
        {
            ItemStack j = craftMatrix.getStackInSlot(i);
            if(j.getItem() != null && j.getItem() == mod_eltrixscience.vaporizerItem)
            {
                ItemStack k = new ItemStack(mod_xxx.xxxItem, 2, (j.getItemDamage() - 1)); // <-- Set the Damage after crafting...
                craftMatrix.setInventorySlotContents(i, k); //<-- Put the item back into the crafting gui!
            }
            
        }
    }

}

}

 

Hope I helped you!

Greetings from germany!

Link to comment
Share on other sites

Oh by the way this line of code:

ItemStack k = new ItemStack(mod_xxx.xxxItem, 2, (j.getItemDamage() - 1));

 

Should be changed to:

ItemStack k = new ItemStack(mod_xxx.xxxItem, 2, (j.getItemDamage() + 1));

 

Because otherwise you are taking away from the damage value which adds to the durability so it will go from 123 to 124 instead of 123 to 122.

Link to comment
Share on other sites

Also you will want to remove this piece of code at the bottom of the code:

craftMatrix.setInventorySlotContents(i, k);

 

And put in this if else statement so if the item has no durability left it gets destroyed:

if(k.getItemDamage() < k.getMaxDamage()){
	craftMatrix.setInventorySlotContents(i, k);
  }else{
	ItemStack l = new ItemStack(Block.blockClay, 0);
	craftMatrix.setInventorySlotContents(i, j);
   }

 

The Block.blockClay can be replaced with anything because the 0 after it means that 0 of whatever item is stated will be put in your inventory.

 

So the final code should look like this:

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {
	for(int i = 0; i < craftMatrix.getSizeInventory(); i++ ){
		if(craftMatrix.getStackInSlot(i) != null){
			ItemStack j = craftMatrix.getStackInSlot(i);
			if(j.getItem() != null && j.getItem() == YourMod.yourItem){
				ItemStack k = new ItemStack(YourMod.yourItem, 2, (j.getItemDamage() + 1));
				if(k.getItemDamage() < k.getMaxDamage()){
					craftMatrix.setInventorySlotContents(i, k);
				}else{
					ItemStack l = new ItemStack(Block.blockClay, 0);
					craftMatrix.setInventorySlotContents(i, j);
				}	
			}
		}
	}

}

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.

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

    • I can run forge server jar and server runs, but i want to allocate certan ram to it and use BAT   What seems to be the problem, what should I do? Thanks   I always used bat the past days, but when i stopped server and re ran it and it Keeps saying PAUSE, This is the .bat file text,   [16:57:51] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.8, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [16:57:51] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_301 by Oracle Corporation [16:57:52] [main/INFO] [ne.mi.fm.lo.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [16:57:52] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/Jon/Desktop/Server/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=SERVER Exception in thread "main" [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.RuntimeException: Failed to load FML config from C:\Users\Jon\Desktop\Server\config\fml.toml [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.fml.loading.FMLConfig.loadFrom(FMLConfig.java:64) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.fml.loading.FMLConfig.load(FMLConfig.java:77) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.fml.loading.FMLServiceProvider.initialize(FMLServiceProvider.java:81) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.util.HashMap$Values.forEach(Unknown Source) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.run(Launcher.java:76) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.file.AutoreloadFileConfig.load(AutoreloadFileConfig.java:41) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.fml.loading.FMLConfig.loadFrom(FMLConfig.java:60) [16:57:52] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         ... 12 more C:\Users\Jon\Desktop\Server>PAUSE Press any key to continue . . .  
    • Thank you! Both of you were very helpful.
    • When I install Forge 1.12.2 i installs into the folder with the log, library, forge.jar thing, and the minecraft server jar. wont run so it wont install the mods folder the eula or anything i will only run the minecraft server.jar. Help me please im trying to play a game with one of my friends.
    • Well, if you mean this, it doesn't work either. public static final RegistryObject<Block> GRIMSTONESTAIRS= BLOCKS.register("grimstone_bricks_stairs",() -> new StairBlock(GRIMSTONEBRICK.get(), BlockBehaviour.Properties.of(Material.HEAVY_METAL).strength(1.5f,0.5f).sound(SoundType.DEEPSLATE)));  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.