Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.3] Edit Vanilla Items
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 2
Luis_ST

[1.16.3] Edit Vanilla Items

By Luis_ST, October 23, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 23, 2020 (edited)

I'm just new in modding Minecraft. And I want to edit the sugar. When the player eats the sugar, he should get an effect (like speed).

Edited October 23, 2020 by Luis_ST
  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    75

Beethoven92

Beethoven92    75

  • Dragon Slayer
  • Beethoven92
  • Members
  • 75
  • 577 posts
Posted October 23, 2020

You would need to create your custom edible sugar item and register it in place of the vanilla sugar

  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 23, 2020

okay

 

"edible sugar item and register it in place of the vanilla sugar" Whats the best way to do this

 

Sorry but I'm new

  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    75

Beethoven92

Beethoven92    75

  • Dragon Slayer
  • Beethoven92
  • Members
  • 75
  • 577 posts
Posted October 23, 2020

You have to create your custom item class, with your custom logic (apply potion effect when consumed) and make it be a food item (you can see how vanilla specifies that some items are to be treated as food in the Items class). Then you have to register your custom item with the same registry name as vanilla sugar, so it will replace it

  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 24, 2020

okay i creat the item class :

 

package net.luis.cave.items.vanilla;

import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;

public class Sugar extends Item {

	public Sugar() {
		
		super(new Item.Properties()
				.group(ItemGroup.FOOD)
				.food(new Food.Builder()
						.hunger(2)
						.saturation(1.0f)
						.effect(new EffectInstance(Effects.SPEED, 300, 3), 1)
						.setAlwaysEdible()
						.build()));

	}

}

 

and I register the item with the same vanilla name but it dosen't work

and I don't know where is the error :

 

	public static final RegistryObject<Sugar> SUGAR = ITEMS.register("sugar", Sugar::new);
  • Quote

Share this post


Link to post
Share on other sites

poopoodice    117

poopoodice

poopoodice    117

  • Dragon Slayer
  • poopoodice
  • Members
  • 117
  • 927 posts
Posted October 24, 2020

Although I've never done one before, but if you register with your mod id it won't work.

  • Quote

Share this post


Link to post
Share on other sites

MostafaSabry55    2

MostafaSabry55

MostafaSabry55    2

  • Stone Miner
  • MostafaSabry55
  • Members
  • 2
  • 59 posts
Posted October 24, 2020
Quote

You have to create your custom item class, with your custom logic (apply potion effect when consumed) and make it be a food item (you can see how vanilla specifies that some items are to be treated as food in the Items class). Then you have to register your custom item with the same registry name as vanilla sugar, so it will replace it

Just for curiosity, wouldn't that cause issues if multiple mods override the same item?

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 24, 2020
29 minutes ago, poopoodice said:

Although I've never done one before, but if you register with your mod id it won't work.

	public static final DeferredRegister<Item> VANILLA_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "minecraft");
      
    public static final RegistryObject<Sugar> SUGAR = VANILLA_ITEMS.register("sugar", Sugar::new);

 

It doesent work with the minecraft id

  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    75

Beethoven92

Beethoven92    75

  • Dragon Slayer
  • Beethoven92
  • Members
  • 75
  • 577 posts
Posted October 24, 2020
7 hours ago, MostafaSabry55 said:

Just for curiosity, wouldn't that cause issues if multiple mods override the same item?

Yes, there could be issues and incompatibilities..

 

7 hours ago, Luis_ST said:

	public static final DeferredRegister<Item> VANILLA_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "minecraft");
      
    public static final RegistryObject<Sugar> SUGAR = VANILLA_ITEMS.register("sugar", Sugar::new);

 

It doesent work with the minecraft id

Define "doesn't work". Maybe show your complete code? Also i found this post where a similar question has been asked. There may another solution to edit the food property of vanilla items without replacing the item: https://forums.minecraftforge.net/topic/90655-making-leaves-edible/?tab=comments#comment-420705

  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 24, 2020
2 minutes ago, Beethoven92 said:

Yes, there could be issues and incompatibilities..

 

Define "doesn't work". Maybe show your complete code? Also i found this post where a similar question has been asked. There may another solution to edit the food property of vanilla items without replacing the item: https://forums.minecraftforge.net/topic/90655-making-leaves-edible/?tab=comments#comment-420705

This is the code of the item (sugar):

 

package net.luis.cave.items.vanilla;

import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;

public class Sugar extends Item {

	public Sugar() {
		
		super(new Item.Properties()
				.group(ItemGroup.FOOD)
				.food(new Food.Builder()
						.hunger(2)
						.saturation(1.0f)
						.effect(new EffectInstance(Effects.SPEED, 300, 3), 1)
						.setAlwaysEdible()
						.build()));
		setRegistryName("minecraft", "sugar");

	}

}

 

and this is the code of the Registry:

 

package net.luis.cave.init;

import net.luis.cave.Cave;
import net.luis.cave.items.BaseItem;
import net.luis.cave.items.RubyApple;
import net.luis.cave.items.vanilla.Sugar;
import net.minecraft.item.Item;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class CaveItems {
	
	public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Cave.Mod_Id);
	public static final DeferredRegister<Item> VANILLA_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "minecraft");
	
	//Item
	public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", BaseItem::new);
	
	public static final RegistryObject<Item> ENDERITE_SCRAP = ITEMS.register("enderite_scrap", BaseItem::new);
	
	public static final RegistryObject<Item> ENDERITE_INGOT = ITEMS.register("enderite_ingot", BaseItem::new);
	
	public static final RegistryObject<RubyApple> RUBY_APPLE = ITEMS.register("ruby_apple", RubyApple::new);
	
	public static final RegistryObject<Item> SUGAR = VANILLA_ITEMS.register("sugar", Sugar::new);
	
}

 

  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    75

Beethoven92

Beethoven92    75

  • Dragon Slayer
  • Beethoven92
  • Members
  • 75
  • 577 posts
Posted October 24, 2020
setRegistryName("minecraft", "sugar");

	

You don't need this in your item class. Your deferred register already handles that

  • Thanks 1
  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

Danebi    26

Danebi

Danebi    26

  • Diamond Finder
  • Danebi
  • Members
  • 26
  • 432 posts
Posted October 24, 2020

Are you registering VANILLA_ITEMS on the mod bus?

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 24, 2020 (edited)
31 minutes ago, Beethoven92 said:

setRegistryName("minecraft", "sugar");

	

You don't need this in your item class. Your deferred register already handles that

okay

6 minutes ago, Danebi said:

Are you registering VANILLA_ITEMS on the mod bus?

it already set the mod id to minecraft because when i use my mod id (cave) i creat a new item but i want to replace a vanilla item(suger)

 

Edited October 24, 2020 by Luis_ST
  • Quote

Share this post


Link to post
Share on other sites

Danebi    26

Danebi

Danebi    26

  • Diamond Finder
  • Danebi
  • Members
  • 26
  • 432 posts
Posted October 24, 2020
1 minute ago, Luis_ST said:

it already set the mod id to minecraft

Do you have a line like this?

VANILLA_ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());

 

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    6

Luis_ST

Luis_ST    6

  • Diamond Finder
  • Luis_ST
  • Members
  • 6
  • 363 posts
Posted October 24, 2020 (edited)
5 minutes ago, Danebi said:

Do you have a line like this?


VANILLA_ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());

 

no I forgot it

thanks for helping

Edited October 24, 2020 by Luis_ST
  • Quote

Share this post


Link to post
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.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • brok4d
      OBJ MODELS

      By brok4d · Posted 46 minutes ago

      Hello, this mod is the source, you have to get boredhttps://gitlab.com/Lycanite/LycanitesMobs
    • JayNeedsHelp
      Logger not working

      By JayNeedsHelp · Posted 1 hour ago

      So I'm currently creating a forge mod and I'm having an issue where the console stops logging after some errors. It seems to be connected to the access transformers that I'm using as before I added at's my console was working fine.   Here is my at file:  public-f net.minecraft.client.Minecraft session public net.minecraft.client.Minecraft timer public net.minecraft.client.gui.GuiScreen buttonList public net.minecraft.util.Timer tickLength public net.minecraft.network.play.client.CPacketPlayer onGround public net.minecraft.network.play.server.SPacketEntityVelocity motionX public net.minecraft.network.play.server.SPacketEntityVelocity motionY public net.minecraft.network.play.server.SPacketEntityVelocity motionZ public net.minecraft.network.play.server.SPacketExplosion motionX public net.minecraft.network.play.server.SPacketExplosion motionY public net.minecraft.network.play.server.SPacketExplosion motionZ public net.minecraft.client.renderer.entity.RenderManager renderPosX public net.minecraft.client.renderer.entity.RenderManager renderPosY public net.minecraft.client.renderer.entity.RenderManager renderPosZ   Any help is greatly appreciated thank you!
    • cadbane86140
      Minecraft: Hunger Games Game #36- Shear FIGHT!

      By cadbane86140 · Posted 2 hours ago

      Hello There! Today we are back on Hunger Games after a little break but we are finally back! In this episode we are on the good ol' map Survival Games 4 and it ACTUALLY went well for once. Also we have so many great battles on rooftops, small rooms and just out in the open! We also use shears to fight at one point and that was pretty crazy! There are so many hilarious moments in this episode that I know you guys are gonna love! I hope you all enjoy this video and if you did don't forget to like and sub for more Hunger Games in the future!  
    • Sad Whale
      Game crashes whenever I try to increase the RAM

      By Sad Whale · Posted 2 hours ago

      latest.log
    • diesieben07
      Game crashes whenever I try to increase the RAM

      By diesieben07 · Posted 3 hours ago

      In the logs folder of your game directory.
  • Topics

    • Milk_Shak3s
      1
      OBJ MODELS

      By Milk_Shak3s
      Started 16 hours ago

    • JayNeedsHelp
      0
      Logger not working

      By JayNeedsHelp
      Started 1 hour ago

    • cadbane86140
      0
      Minecraft: Hunger Games Game #36- Shear FIGHT!

      By cadbane86140
      Started 2 hours ago

    • Sad Whale
      6
      Game crashes whenever I try to increase the RAM

      By Sad Whale
      Started 4 hours ago

    • Unusualty
      0
      GUI'S and player editing

      By Unusualty
      Started 3 hours ago

  • Who's Online (See full list)

    • CptPICHU
    • rhinitis
    • Draco18s
    • xcheetoezx
    • brok4d
    • Twu
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.3] Edit Vanilla Items
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community