Jump to content

[1.7.10] i want to know "when i craft item, how to it doesn't disappear item?"


PuKom

Recommended Posts

Hello.

when i craft item, how to it doesn't disappear item?

Ex)

[crafting table]

(ITEM A) (ITEM B) (NONE)

(NONE)  (NONE)  (NONE)     [None]

(NONE)  (NONE)  (NONE)

craft 

(ITEM A) (NONE) (NONE)

(NONE) (NONE) (NONE)     [Item C]

(NONE) (NONE) (NONE)

 

Here My mod source:

Item A = CoffeeGr

Item B = BakedCoffeeSeeds

Item C = MisCoffee

package impress.pukom;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import impress.pukom.blocks.ImpCrop;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
//임포트 끝 
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;

@Mod(modid=ImpressMOD.MODID, name=ImpressMOD.MODNAME, version=ImpressMOD.MODVER)
public class ImpressMOD
{
	public static final String MODID = "Impress"; // 모드 아이디
	public static final String MODNAME = "Impress Coffee"; // 모드 이름
	public static final String MODVER = "1.1.4"; // 모드 버전
	
	@Instance(value = ImpressMOD.MODID)
	public static ImpressMOD instance;
	int maxDamage = 64;

	/* 농작물 */
	ItemStack emptyItem = null;
	public static Item cropCoffee;
	public static Item cropCoffeeSeeds;
	public static Block cropCoffeePlant;
	public static Item BakedCoffeeSeeds; // 구워진 커피
	
	/* 아이템 추가 */
	public static Item Basecoffee;
	public static Item Heyz;
	public static Item CoffeeGr;
	public static Item Water;
	public static Item BoilWater;
	public static Item Moca;
	public static Item Cup;
	public static Item Latte;
	public static Item Maki;
	public static Item HeyzC;
	public static Item Capu;
	public static Item PulaPu;
	public static Item MisCoffee;
	public static Item As;
	public static Item Heart;
	public static Item Man;
	public static Item Five;
	public static Item Cun;
	public static Item CoffeeCan;

	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		
		CoffeeGr = new ImpressItem(1, tabMyFirstMod, "CoffeeGr").setTextureName("Impress:CoffeeGr").setUnlocalizedName("CoffeeGr").setMaxDamage (128);
		CoffeeGr.setNoRepair ();
		Cup = new ImpressItem(1, tabMyFirstMod, "Cup").setTextureName("Impress:Cup");
		/* 아이템 추가 정보입력 */
		Basecoffee = new ImpressItem(16, tabMyFirstMod, "BaseCoffee").setUnlocalizedName("BaseCoffee").setTextureName("Impress:BaseCoffee").setCreativeTab(tabMyFirstMod);; 
		Water = new ImpressItem(16, tabMyFirstMod,"Water").setUnlocalizedName("Water").setTextureName("Impress:Water");
		BoilWater = new ImpressItem(16, tabMyFirstMod, "BoilWater").setTextureName("Impress:BoilWater");
		Moca = new ImpressItem(16, tabMyFirstMod, "Moca").setTextureName("Impress:CoffeeMoca");
		CoffeeCan = new ImpressItem(64, tabMyFirstMod, "CoffeeCan").setTextureName("Impress:CoffeeCan");
		Latte = new ImpressItem(16, tabMyFirstMod, "Latte").setTextureName("Impress:Latte");
		Maki = new ImpressItem(16, tabMyFirstMod, "Maki").setTextureName("Impress:Maki");
		Capu = new ImpressItem(16, tabMyFirstMod, "Capu").setTextureName("Impress:Capu");
		PulaPu = new ImpressItem(16, tabMyFirstMod, "PulaPu").setTextureName("Impress:PulaPu");
		MisCoffee = new ImpressItem(64, tabMyFirstMod, "MisCoffee").setTextureName("Impress:MisCoffee");
		As = new ImpressItem(16, tabMyFirstMod, "As").setTextureName("Impress:As");
		Heart = new ImpressItem(1, tabMyFirstMod, "Heart").setTextureName("Impress:Heart");
		Man = new ImpressItem(64, tabMyFirstMod, "Man").setTextureName("Impress:Man");
		Five = new ImpressItem(64, tabMyFirstMod, "Five").setTextureName("Impress:five");
		Cun = new ImpressItem(64, tabMyFirstMod, "Cun").setTextureName("Impress:Cun");
		GameRegistry.registerItem(Basecoffee, Basecoffee.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(BoilWater, BoilWater.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Water, Water.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Cup, Cup.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Latte, Latte.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Maki, Maki.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Capu, Capu.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(PulaPu, PulaPu.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(MisCoffee, MisCoffee.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(As, As.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Heart, Heart.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Man, Man.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Five, Five.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Cun, Cun.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(CoffeeCan, CoffeeCan.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(Moca, Moca.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(CoffeeGr, CoffeeGr.getUnlocalizedName().substring(5));
		/* 농작물 */
		cropCoffee = new ItemFood(1, 0.5F, false).setUnlocalizedName("Coffee").setTextureName("Impress:Coffee").setCreativeTab(tabMyFirstMod);
		cropCoffeePlant = new ImpCrop().setBlockName("CoffeePlant");
		cropCoffeeSeeds = new ItemSeeds(cropCoffeePlant, Blocks.farmland).setUnlocalizedName("CoffeeSeeds").setTextureName("Impress:CoffeeSeed").setCreativeTab(tabMyFirstMod);
		BakedCoffeeSeeds = new ItemFood(2, 1.0F, false).setUnlocalizedName("BakedCoffee").setTextureName("Impress:BCoffee").setCreativeTab(tabMyFirstMod);
		
		GameRegistry.registerItem(cropCoffeeSeeds, cropCoffeeSeeds.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(cropCoffee, cropCoffee.getUnlocalizedName().substring(5));
		GameRegistry.registerBlock(cropCoffeePlant, cropCoffeePlant.getUnlocalizedName().substring(5));
		GameRegistry.registerItem(BakedCoffeeSeeds, BakedCoffeeSeeds.getUnlocalizedName().substring(5));
		
		/* 조합법 */
		GameRegistry.addSmelting(Water, new ItemStack(BoilWater, 1), 1.0F);
		GameRegistry.addSmelting(cropCoffeeSeeds, new ItemStack(BakedCoffeeSeeds, 1), 1.0F); // 화로 조합
	}
	@EventHandler
	public void load(FMLInitializationEvent event)
	{
		
		
	}
	@EventHandler
	public void postInit(FMLPostInitializationEvent event)
	{
		
	}

	public static CreativeTabs tabMyFirstMod = new CreativeTabs("tabMyFirstMod") 
	{
	
	
	public void init(FMLInitializationEvent event) {
	}
		@Override
		public Item getTabIconItem() {
			return new ItemStack(Basecoffee).getItem();
		}
	};
}

 

Please Help me! T_T

 

Edited by PuKom
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • What's the issue your running into? The link for the image you posted is also broken.
    • What does NetworkHooks.openScreen(player, blockEntity, pPos) do?
    • At an attempt at answering my first question I thought I might be able to change the code to this public static final RegistryObject<StatType<?>> FIREWORK_BOOSTS_USED = STATISTICS.register("firework_boosts_used", () -> new StatType<>(ForgeRegistries.STAT_TYPES, Component.literal("firework_boosts"))); or to this public static final RegistryObject<StatType<?>> FIREWORK_BOOSTS_USED = STATISTICS.register("firework_boosts_used", () -> new StatType<>(BuiltInRegistries.STAT_TYPE, Component.literal("firework_boosts"))); but for the first code snippet the StatType constructor requires a Registry not an IForgeRegistry and for the second code snippet we run into the same NPE issue from above.
    • Hi guys,   I'm using Crafty installed on CasaOS and i want to create a BetterMC4 Server. Unfortunatly i got an error message. This error only appear when using my "online" server because when i create a singleplayer adventure, everythings works just fine. https://github.com/OwNuT/Errors/issues/1   Thank you !
    • I am attempting to create a mod that adds custom statistics to Minecraft. I've had some help from LexManos on the Discord server, but posting a lot of what I posted in the #mod-dev-support-1.20 channel here to have a more permanent spot for discussion.   ---   Minecraft creates their stats like this: and some of the registries in the code above are located in BuiltInRegistries.java like this: and the ForgeRegistries#STAT_TYPES looks like this: So, attempting to follow that and the forge documentation on registries I arrived at this: Clearly, registering a stat twice in a row is the wrong way to do it, but the makeRegistryStatType function was used as it does give the correct return type for the code I had come up with so far.   ---   At this point the game crashes upon trying to use Player#awardStat, because of a NPE that occurs in Stat#locationToKey. Which happens in the 2nd Stat#locationToKey in the Stat#buildName function. The .getRegistry returns the this.registry class variable with a value of {MappedRegistry@#####} "Registry[ResourceKey[minecraft:root / minecraft:custom_stat] (Stable)]" The value passed into .getKey is "samplemod:fireworks_boosts_used" but the reference found is null. So Lex's conclusion was that "[I'm] passing in null because the registry doesnt have an entry for your custom stat instance. So.. register your custom stat instance in that registry."   ---   So I suppose at this point my questions are 1. How can I create a supplier that returns a Supplier<? extends StatType<?>> to replace the () -> makeRegistryStatType("firework_boosts_used", BuiltInRegistries.CUSTOM_STAT) line of code. 2. Is my registry entry public static final RegistryObject<StatType<?>> FIREWORK_BOOSTS_USED the correct type? 3. Do I need to do anything additional, like create my own StatType<> or my own Stat<> ?
  • Topics

×
×
  • Create New...

Important Information

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