Jump to content

Recommended Posts

Posted

I have a recipe in which I use a vanilla item from minecraft. But when crafting, this item disappears, how to make sure that the vanilla item does not disappear when crafting?馃槄

Posted

Dieseben07 already told you what to do..if you want a more specific suggestion, some classes you may find helpful to look at are the SpecialRecipe class and its subclasses. In particular you can see how vanilla uses the getRemainingItems method in BannerDuplicateRecipe and BookCloningRecipe classes

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

Posted
  On 1/4/2021 at 6:58 PM, Beethoven92 said:

Dieseben07 already told you what to do..if you want a more specific suggestion, some classes you may find helpful to look at are the SpecialRecipe class and its subclasses. In particular you can see how vanilla uses the getRemainingItems method in BannerDuplicateRecipe and BookCloningRecipe classes

Expand  

I don't know where to define getRemainingItems and how to make it "work" later

Posted
  On 1/4/2021 at 2:09 PM, diesieben07 said:

You need a custom crafting recipe implementation and override getRemainingItems.

Expand  

You override the method getRemainingItems in your custom recipe class.. if you looked at the classes i suggested you you would see exactly how vanilla does that

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

Posted
  On 1/4/2021 at 7:12 PM, Beethoven92 said:

You override the method getRemainingItems in your custom recipe class.. if you looked at the classes i suggested you you would see exactly how vanilla does that

Expand  

Will I need to add a recipe using code and not a json file?

Posted
  On 1/4/2021 at 7:12 PM, Beethoven92 said:

You override the method getRemainingItems in your custom recipe class.. if you looked at the classes i suggested you you would see exactly how vanilla does that

Expand  

God, how difficult. Why is there no documentation?

public class White_dust extends SpecialRecipe{
	public White_dust(ResourceLocation idIn) {
	      super(idIn);
	   }

	public boolean matches(CraftingInventory inv, World worldIn) {
	      DyeColor dyecolor = null;
	      ItemStack itemstack = null;
	      ItemStack itemstack1 = null;

	      for(int i = 0; i < inv.getSizeInventory(); ++i) {
	         ItemStack itemstack2 = inv.getStackInSlot(i);
	         Item item = itemstack2.getItem();
	         if (item instanceof BannerItem) {
	            BannerItem banneritem = (BannerItem)item;
	            if (dyecolor == null) {
	               dyecolor = banneritem.getColor();
	            } else if (dyecolor != banneritem.getColor()) {
	               return false;
	            }

	            int j = BannerTileEntity.getPatterns(itemstack2);
	            if (j > 6) {
	               return false;
	            }

	            if (j > 0) {
	               if (itemstack != null) {
	                  return false;
	               }

	               itemstack = itemstack2;
	            } else {
	               if (itemstack1 != null) {
	                  return false;
	               }

	               itemstack1 = itemstack2;
	            }
	         }
	      }

	      return itemstack != null && itemstack1 != null;
	   }

	   /**
	    * Returns an Item that is the result of this recipe
	    */
	   public ItemStack getCraftingResult(CraftingInventory inv) {
	      for(int i = 0; i < inv.getSizeInventory(); ++i) {
	         ItemStack itemstack = inv.getStackInSlot(i);
	         if (!itemstack.isEmpty()) {
	            int j = BannerTileEntity.getPatterns(itemstack);
	            if (j > 0 && j <= 6) {
	               ItemStack itemstack1 = itemstack.copy();
	               itemstack1.setCount(1);
	               return itemstack1;
	            }
	         }
	      }

	      return ItemStack.EMPTY;
	   }

	   public NonNullList<ItemStack> getRemainingItems(CraftingInventory inv) {
	      NonNullList<ItemStack> nonnulllist = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

	      for(int i = 0; i < nonnulllist.size(); ++i) {
	         ItemStack itemstack = inv.getStackInSlot(i);
	         if (!itemstack.isEmpty()) {
	            if (itemstack.hasContainerItem()) {
	               nonnulllist.set(i, itemstack.getContainerItem());
	            } else if (itemstack.hasTag() && BannerTileEntity.getPatterns(itemstack) > 0) {
	               ItemStack itemstack1 = itemstack.copy();
	               itemstack1.setCount(1);
	               nonnulllist.set(i, itemstack1);
	            }
	         }
	      }

	      return nonnulllist;
	   }

	   public IRecipeSerializer<?> getSerializer() {
	      return IRecipeSerializer.CRAFTING_SPECIAL_BANNERDUPLICATE;
	   }

	   
	   public boolean canFit(int width, int height) {
	      return width * height >= 2;
	   }
	
}

I just look and do not understand what and why it causes? What are all these methods for? I only figured out "public IRecipeSerializer <?> GetSerializer ()", then it seems that I should return not CRAFTING_SPECIAL_BANNERDUPLICATE, but CRAFTING_SHAPELESS. But I'm not sure about that either

 

Posted
  On 1/4/2021 at 8:23 PM, arturkr said:

Will I need to add a recipe using code and not a json file?

Expand  

Depends on the complexity of the recipe. If there is no requirement for dynamic manipulation, you can get away with making a custom recipe with serializer and building a json off of that.

  On 1/4/2021 at 8:36 PM, arturkr said:

I just look and do not understand what and why it causes? What are all these methods for? I only figured out "public IRecipeSerializer <?> GetSerializer ()", then it seems that I should return not CRAFTING_SPECIAL_BANNERDUPLICATE, but CRAFTING_SHAPELESS. But I'm not sure about that either

Expand  

You haven't created the recipe serializer. Take a look at ShapedRecipe for that.

Also, every method within IRecipe except for basically two (I'm not counting the getters) has documentation associated with it. The other two gets the items that are supposed to be left over in the inventory using container items while the other gets the recipe ingredients.

Posted
  On 1/4/2021 at 8:41 PM, ChampionAsh5357 said:

Depends on the complexity of the recipe. If there is no requirement for dynamic manipulation, you can get away with making a custom recipe with serializer and building a json off of that.

Expand  

What is a complex recipe? I have a simple craft on the workbench

Posted
  On 1/4/2021 at 8:43 PM, arturkr said:

What is a complex recipe? I have a simple craft on the workbench

Expand  

You have to answer that question yourself. What are you attempting to do in a generic form? I see you trying to keep a specific item in the crafting table and not be used. Is that the only case or does this expand to any item for a specific recipe? These are questions that need to be answered.

Posted
  On 1/4/2021 at 8:52 PM, ChampionAsh5357 said:

You have to answer that question yourself. What are you attempting to do in a generic form? I see you trying to keep a specific item in the crafting table and not be used. Is that the only case or does this expand to any item for a specific recipe? These are questions that need to be answered.

Expand  

I'll tell you in detail:

I added three items to the game -

1.pounder

2.Ore

3.milled ore

 

I also made a recipe:

1.bowl

2.Ore

3.pounder

Result:

1.milled ore

The recipe is shapeless.

 

I have implemented functions so that when crafting the pestle is not wasted, but -1 damage. It remains to make sure that the bowl does not disappear.

 

1357791503_.png.3130b0f177e58019d4d74a3fb4709ef8.png

 

382355769_.png.5b33d459e1133ff9ef090d08b85a058f.png

 

 

Posted
  On 1/4/2021 at 9:40 PM, diesieben07 said:

You need an IRecipeSerializer. This is a normal registry entry. Refer to the documentation as for how to register them.

Then in your recipe json file you need to set the type property to the resource location of your serializer. Your serializer will then be called with the JSON of your recipe and needs to return an ICraftingRecipe instance.

Expand  

WHERE? IN WHICH PLACE? Where does this documentation refer to the IRecipeSerializer? Maybe I'm blind, but I haven't read the worse documentation yet

Posted (edited)

1351843699_.thumb.png.7ed05e1df81ea947d8dec01431159cf8.png

Is it real? Only three Google pages? 99.9% of the results are not about what is needed, but 0.1% is the CLICK, and they did not help him...

Really worst help. How are they recruited into the forum team?
It's the same as if you ask "How to put the door?" And I answer "Put the door"

 

 

Edited by arturkr
Posted
  On 1/5/2021 at 12:03 PM, diesieben07 said:

Dude.

You asked "how to register IRecipeSerializer"? I linked you the documentation that explains you how to register any registry entry.

Expand  

Yes, but I don't even know where and how to build the "register IRecipeSerializer" correctly

Posted
  On 1/5/2021 at 12:10 PM, diesieben07 said:

I don't know what you mean by that. Have you even tried following the documentation?

Expand  

Yes, but the only thing I came up with is this:

public static final RegistryObject<IRecipeSerializer<IRecipe<?>>> WHITE_DUST = IRecipeSerializer.CRAFTING_SHAPELESS.IDK(((;

 

But I understand that this is nonsense

Posted
  On 1/5/2021 at 12:16 PM, diesieben07 said:

You need to start out by making a DeferredRegister instance for it. It works exactly the same as for blocks and items, which you have already done.

This is why I am having a hard time understanding your struggle.

Expand  
public static final DeferredRegister<IRecipeSerializer<?>> RECIPE = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS,
            Main.MOD_ID);

public static final RegistryObject<IRecipeSerializer<IRecipe<?>>> WHITE_DUST_RECIPE = RECIPE.register("white_dust_recipe",
            () -> new NEXT IDK

 

Posted
  On 1/5/2021 at 1:54 PM, diesieben07 said:

You need to implement IRecipeSerializer.

Expand  

Then?

public class Mortar implements IRecipeSerializer<IRecipe<?>>{

			@Override
			public IRecipeSerializer<?> setRegistryName(ResourceLocation name) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public ResourceLocation getRegistryName() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public Class<IRecipeSerializer<?>> getRegistryType() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public IRecipe<?> read(ResourceLocation recipeId, JsonObject json) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public IRecipe<?> read(ResourceLocation recipeId, PacketBuffer buffer) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public void write(PacketBuffer buffer, IRecipe<?> recipe) {
				// TODO Auto-generated method stub
				
			}
	
}

 

Posted

Start by making the stubs not-stubs.
You can look at the other recipe implementations for help. Heck, you may even want to extend one of them to make your life easier.

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.

Posted
  On 1/5/2021 at 2:10 PM, Draco18s said:

Start by making the stubs not-stubs.
You can look at the other recipe implementations for help. Heck, you may even want to extend one of them to make your life easier.

Expand  

I still don't know what to do (

You speak as if it is very easy.
So if it's easy, just show where and what to write. I will understand how IRecipeSerializer works faster

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You are using Create 6 - some addons are not compatible with it Remove all addons and add these one by one littlecontraptions is mentioned - keep this one removed
    • Different problem now. https://paste.ee/p/iDo8lS35
    • I would like to have a BoP sapling drop from my block if it is also installed. I think I have done everything and I cannot pinpoint the problem, which is the error in the logs that appears when joining a world:   [Worker-Main-11/ERROR] [ne.mi.co.ForgeHooks/]: Couldn't parse element loot_tables:grasses:blocks/leaves_block com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'biomesoplenty:magic_sapling' My code:   LootItemConditions.CONDITIONS.register(modEventBus); public class LootItemConditions { public static final DeferredRegister<LootItemConditionType> CONDITIONS = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Grasses.MOD_ID); public static final RegistryObject<LootItemConditionType> IS_MOD_LOADED = CONDITIONS.register("is_mod_loaded", () -> new LootItemConditionType(new IsModLoaded.ConditionSerializer())); } public class IsModLoaded implements LootItemCondition { private final boolean exists; private final String modID; public IsModLoaded(String modID) { this.exists = ModList.get().isLoaded(modID); this.modID = modID; } @Override public LootItemConditionType getType() { return LootItemConditions.IS_MOD_LOADED.get(); } @Override public boolean test(LootContext context) { return this.exists; } public static LootItemCondition.Builder builder(String modid) { return () -> new IsModLoaded(modid); } public static class ConditionSerializer implements Serializer<IsModLoaded> { @Override public void serialize(JsonObject json, IsModLoaded instance, JsonSerializationContext ctx) { json.addProperty("modid", instance.modID); } @Override public IsModLoaded deserialize(JsonObject json, JsonDeserializationContext ctx) { return new IsModLoaded(GsonHelper.getAsString(json, "modid")); } } } protected LootTable.Builder createLeavesDropsWithModIDCheck(Block selfBlock, Item sapling, Property<?>[] properties, String modIDToCheck, float... chances) { CopyBlockState.Builder blockStateCopyBuilder = CopyBlockState.copyState(selfBlock); for(Property<?> property : properties) { blockStateCopyBuilder.copy(property); } return LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(LootItem.lootTableItem(selfBlock) .when(HAS_SHEARS_OR_SILK_TOUCH) .apply(blockStateCopyBuilder))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionCondition(selfBlock, LootItem.lootTableItem(sapling)) .when(IsModLoaded.builder(modIDToCheck))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, chances)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH)) .withPool(LootPool.lootPool().name("sticks").setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionDecay(selfBlock, LootItem.lootTableItem(Items.STICK). apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F)))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, NORMAL_LEAVES_STICK_CHANCES)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH))); } I don't know. Am I making a mistake somewhere? Am I forgetting something? Should there be something else?
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

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