Jump to content

Xander402

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by Xander402

  1. I know what a containerItem is, but can this field be somehow utilized in order to make the item stay in the crafting grid? It's not about returning some empty bottle from recipe that requires a bottled substance. It's about a knife staying untouched after crafting something with it. I tried two things: package ... import ... public class UtilityItem extends Item { public UtilityItem(Properties p_i48487_1_) { super(p_i48487_1_); } @Override public ItemStack getContainerItem(ItemStack itemStack) { return new ItemStack(this); } } with regular initialization, and // In item init public static Item knife = new Item(new Item.Properties().group(SushiMod.TOOLS_GROUP)).setRegistryName(rloc("knife")); static { knife = new Item(new Item.Properties() .containerItem(knife) .group(SushiMod.TOOLS_GROUP)).setRegistryName(rloc("knife")); } ...which I actually didn't think through. The first had no effect and the second made the knife turn into a purple-black-checked block.minecraft.air item after crafting.
  2. What is the proper way to make the game do some stuff when a certain mod block is right-clicked if onBlockActivated(BlockState, World, BlockPos, PlayerEntity, Hand, BlockRayTraceResult) method from net.minecraft.block.Block is marked as @Deprecated? Even native Minecraft blocks like the crafting table use this method. Should I too?
  3. Is it possible to write a loot table pool condition that will drop when a certain data value in BlockState is greater than a number? Look at this. All of these pools only differ with one digit (in the "age" parameter) : { "rolls": 1.0, "entries": [ { "type": "minecraft:alternatives", "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:block_state_property", "block": "mod:avocado_tree", "properties": { "age": "2" } } ], "functions": [ { "function": "minecraft:set_count", "count": 2 }, { "function": "minecraft:explosion_decay" } ], "name": "mod:avocado_seed" }, { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:block_state_property", "block": "mod:avocado_tree", "properties": { "age": "3" } } ], "functions": [ { "function": "minecraft:set_count", "count": 2 }, { "function": "minecraft:explosion_decay" } ], "name": "mod:avocado_seed" }, { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:block_state_property", "block": "mod:avocado_tree", "properties": { "age": "4" } } ], "functions": [ { "function": "minecraft:set_count", "count": 2 }, { "function": "minecraft:explosion_decay" } ], "name": "mod:avocado_seed" }, { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:block_state_property", "block": "mod:avocado_tree", "properties": { "age": "5" } } ], "functions": [ { "function": "minecraft:set_count", "count": 2 }, { "function": "minecraft:explosion_decay" } ], "name": "mod:avocado_seed" } ] } ] } Is there a way to make it simpler? Something like this: { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:block_state_property", "block": "mod:avocado_tree", "properties": { "age": "(from 2 to 5)" } } ], "functions": [ { "function": "minecraft:set_count", "count": 2 }, { "function": "minecraft:explosion_decay" } ], "name": "mod:avocado_seed" }
  4. Yes, I thought I wouldn't need to as I've seen no block break events for such things in any Minecraft classes nor modding tutorials. SoundType.CROP*. But anyway, thanks ? I've actually put a World.playsound effect inside the overridden onBlockHarvested method, but it didn't work, so I removed it. I really don't know what to think about the fact that Minecraft extracts more and more game elements into .json files... There will soon be no use of creating mods as you'll be able to add custom items, mobs, and anything else via .json files. Anyways, thank you for help, moving drops into loot tables and removing overridden onBlockHarvested method did the job and everything works fine.
  5. My custom crop class: package ... import ... public class SoybeanCrops extends CropsBlock implements IGrowable { public SoybeanCrops() { super(Properties.create(Material.PLANTS).sound(SoundType.PLANT).doesNotBlockMovement().tickRandomly()); ... } @Override public void onBlockHarvested(World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull PlayerEntity player) { if (!world.isRemote) { if (!player.isCreative()) { if (this.isMaxAge(state)) { spawnAsEntity(world, pos, new ItemStack(ItemList.soybean_seeds, world.rand.nextInt(3) + 1)); spawnAsEntity(world, pos, new ItemStack(ItemList.soybean, 1)); } else { spawnAsEntity(world, pos, new ItemStack(ItemList.soybean_seeds, 1)); } } } } ... } I've successfully made the game play sound minecraft:item.crop.plant when I use the seeds on the farmland. But why minecraft:block.crop.break doesn't play on block break if there's sound(SoundType.PLANT) in the properties?
  6. Xander402

    Mash up

    Yeah, I love that, too. But what's the problem to have both things at once? Just install Forge and put Optifine into the mods folder.
  7. Well, I'm happy to say that this fixed the error. ? Thank you for all your help on this topic!
  8. Well... Although debugging did illuminate some things that are going on when operating the brewing stand, one thing remains a mistery. As for now, the recipe works perfectly as intended... but only once. After one brewing, no further can be performed. My SoySauceRecipe class now: package ... import ... public class SoySauceRecipe implements IBrewingRecipe { private static final ItemStack INGREDIENT = new ItemStack(ItemList.soybean); private static final ItemStack OUTPUT = new ItemStack(ItemList.soy_sauce); SoySauceRecipe() { } @Override public boolean isInput(@Nonnull ItemStack stack) { LOGGER.info("IBrewingRecipe#isInput: return " + PotionUtils.getPotionFromItem(stack) + " == " + Potions.WATER); return PotionUtils.getPotionFromItem(stack) == Potions.WATER; } @Override public boolean isIngredient(@Nonnull ItemStack ingredient) { LOGGER.info("IBrewingRecipe#isIngredient: return " + INGREDIENT.getItem() + " == " + ItemList.soybean); return INGREDIENT.getItem() == ItemList.soybean; } @Nonnull @Override public ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient) { LOGGER.info("IBrewingRecipe#getOutput: isInput(input) = " + isInput(input) + " isIngredient(ingredient) = " + isIngredient(ingredient) + " -> return " + ((isInput(input) && isIngredient(ingredient)) ? "OUTPUT (=" + OUTPUT + ")" : "ItemStack.EMPTY")); LOGGER.info("Target output: " + OUTPUT); if (isInput(input) && isIngredient(ingredient)) return OUTPUT; return ItemStack.EMPTY; } } Now, when I put Soybean to the ingredient slot, but leave the bottles slots empty, the log shows: [...] IBrewingRecipe#isIngredient: return soybean == soybean [...] IBrewingRecipe#isInput: return net.minecraft.potion.Potion@7f70e244 == net.minecraft.potion.Potion@fd14789 [...] IBrewingRecipe#getOutput: isInput(input) = false isIngredient(ingredient) = true -> return ItemStack.EMPTY [...] Target output: 1 soy_sauce First line - shows what is compared in isIngredient method. Second line - shows what is compared in isInput method. Third line - shows results of isIngredient and isInput methods and resulting ItemStack that is returned as the output. Fourth line - shows what should be the output of the recipe (it's the item declared in the OUTPUT field. Looks good for now. After adding water bottles: [...] IBrewingRecipe#isInput: return net.minecraft.potion.Potion@fd14789 == net.minecraft.potion.Potion@fd14789 [...] IBrewingRecipe#isIngredient: return soybean == soybean [...] IBrewingRecipe#getOutput: isInput(input) = true isIngredient(ingredient) = true -> return OUTPUT (=1 soy_sauce) [...] Target output: 1 soy_sauce As you can see, both isInput and isIngredient are returning true, thus getOutput returns ItemStack with Soy Sauce now, and the brewing begins. Target output is still 1 soy sauce. But after it finishes: [...] IBrewingRecipe#isInput: return net.minecraft.potion.Potion@7f70e244 == net.minecraft.potion.Potion@fd14789 [...] IBrewingRecipe#isIngredient: return soybean == soybean [...] IBrewingRecipe#getOutput: isInput(input) = false isIngredient(ingredient) = true -> return ItemStack.EMPTY [...] Target output: 0 air Despite the fact that the ingredient slot hasn't changed (which even the console output agrees with - as shows the second line), the target output somehow has changed to 0 air... Firstly, this state remains the same regardless of the bottles slots contents. Why is that? It should change when I put a water bottle inside, like at the first brewing. And secondly, how on earth is it possible that target output changed if the console reads content of the OUTPUT field which not only isn't changed anywhere in the code, but also is declared as final?? This looks like a Forge bug to me.., but I don't feel suitable to judge such things. Am I missing something..? --- Here's the GitHub repository: [LINK EXPIRED]
  9. diesieben07, I really appreciate that you answer people's question in such way that you make them do some research in their own. I even like that. Learning is more efficient when you put some effort into it. But sometimes this method fails :/. As I said, I learn the best with examples. I'm really tired after sieben hours of trying to do such relatively simple thing as adding a working brewing recipe with my mod items to the game... (yeah, I started this topic 7 hours ago and I've been doing nothing but trying to get this working). My SoySauceRecipe class looks like this now: package ... import ,,, public class SoySauceRecipe implements IBrewingRecipe { private ItemStack input = new ItemStack(Items.POTION); private ItemStack ingredient = new ItemStack(ItemList.soybean); private ItemStack output = new ItemStack(ItemList.soy_sauce); public SoySauceRecipe() { } @Override public boolean isInput(ItemStack input2) { return PotionUtils.getPotionFromItem(input2) == Potions.WATER; } @Override public boolean isIngredient(ItemStack ingredient2) { return ingredient2.getItem() == ingredient.getItem(); } @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { if (ingredient2 != null && input2 != null && isIngredient(ingredient2)) { ItemStack output2 = this.output.copy(); if (input2 != output2) return output2; else return null; } else return null; } } (with the line return PotionUtils.getPotionFromItem(input2) == Potions.WATER; from you plus the IBrewingRecipe#getOutput method found somewhere on this forum), and it all works the same way. Both Awkward Potion and Soy Sauce is still acceptable as the input. Moreover, I just found out that when I don't fill all of the 3 brewing stand output slots with bottles and there is Blaze Powder in its upper-left slot.., it gets replaced with soy sauce after brewing is done. -,- All this mess is shown on the screenshot. So... yeah.. Sorry, but could you please write for me a properly working class SoySauceRecipe that implements IBrewingRecipe with Water Bottle as the only acceptable input, Items.soybean as the ingredient, and Items.soy_sauce as the output..? I believe that this impossible challenge for a beginner modder like me is a piece of cake for somebody like you.
  10. Alright. I created a class SoySauceRecipe which looks like this: package ... import ... public class SoySauceRecipe implements IBrewingRecipe { private ItemStack output = new ItemStack(ItemList.soy_sauce); SoySauceRecipe() { } @Override public boolean isInput(ItemStack input2) { return input2.getItem().equals(Items.POTION) && PotionUtils.getEffectsFromStack(input2).isEmpty(); } @Override public boolean isIngredient(ItemStack ingredient2) { return ingredient2.getItem() == ItemList.soybean; } @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { return output; } } and registered the recipe here, in main mod file: package ... import ... @Mod("...") public class SushiMod { ... public SushiMod() { ... FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); } private void setup(final FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(this::registerPotions); } private void registerPotions() { BrewingRecipeRegistry.addRecipe(new SoySauceRecipe()); } } Works fine... but not entirely. There are two problems: According to you, from Topic #64031: Recipes with Water Bottle ItemStack: a potion with no effect is exclusively a water bottle. But so are potions such as an Awkward Potion as well. Therefore they get accepted as the input for the recipe, too. How to make the recipe only accept pure water bottle? After the soy sauce is brewed and there's still remaining soybean in the ingredient slot, the soy sauce gets brewed again with itself as the input. Why is that happening despite the fact that isInput method returns true only when there's a POTION input slot?
  11. Well, I really tried. I looked at BrewingRecipeRegistry, I found BrewingRecipeRegistry.addRecipe(Ingredient, Ingredient, ItemStack); and I put it here: @SubscribeEvent public void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ItemList.getItems()); BrewingRecipeRegistry.addRecipe( ... ); } but I have no idea how to use Ingredient... I really miss any examples on the internet. I learn the best with examples. My question is: BrewingRecipeRegistry.addRecipe( /* Ingredient input - what to write here? (for example: water bottle*) */, /* Ingredient ingredient - what to write here? (for example: ItemList.ITEM_A) */, new ItemStack(ItemList.ITEM_B, 1) ); // * BTW, I'd like to know how to implement water bottle, since it's not an item, but a Potion
  12. Is there a method to add your own custom brewing stand recipes? It has nothing to do with adding custom potions and their effects. Let's say I just want to brew ITEM_A from ITEM_B as the ingredient and water bottles inside.
  13. Really? ? What a silly reason.. Thank you, anyway. Works fine now.
  14. https://www.dropbox.com/sh/jvfs7y1kkk3tfaq/AABBPAQcr02vbzuZpn6-9iK0a?dl=0 Main file: /src/main/java/com/xander402/wildnaturechemistryaddon/WNChemistryAddon.java Items list: /src/main/java/com/xander402/wildnaturechemistryaddon/lists/ItemList.java Registered in: /src/main/java/com/xander402/wildnaturechemistryaddon/RegistryEvents.java
  15. Like in the title. I've included display names for all of my mod's items in the en_US.json file. When I launch: gradlew RunClient all the names are displayed properly. But after I export the mod running: gradlew build and putting my mod file from /build/libs into the .minecraft/mods folder and launch the actual game, the names are displayed as item.modid.itemname. My selected language on both RunClient and actual Minecraft is English (US). Did I forget something or am I doing something wrong?
  16. Yeah, I know that too, because it simply does what you said: But I haven't found any other method for putting an item in the crafting grid after grabbing the output, that's just why I used setContainerItem(). I would be happy to know if there is one that would solve my problem.
  17. Hello, I added a utility item that is meant to "consists of" two other items. It's crafted like this: GameRegistry.addShapelessRecipe( new ResourceLocation("modid:itemA_and_itemB_merge"), null, new ItemStack(ItemInit.ITEM_A_AND_ITEM_B, 2), Ingredient.fromItem(ItemInit.ITEM_A), Ingredient.fromItem(ItemInit.ITEM_B) ); But I also want to make it uncraftable without any uncrafting table mod. I tried this: GameRegistry.addShapelessRecipe( new ResourceLocation("modid:itemA_and_itemB_separate"), null, new ItemStack(ItemInit.ITEM_A, 1), Ingredient.fromItem(ItemInit.ITEM_A_AND_ITEM_B .setContainerItem(ItemInit.ITEM_B)), Ingredient.fromItem(ItemInit.ITEM_A_AND_ITEM_B) ); Where only one ITEM_A_AND_ITEM_B is meant to change to ITEM_B after grabbing ITEM_A from the crafting output. But instead, both of the ITEM_A_AND_ITEM_B-s change to IITEM_B...: I also just noticed that the ITEM_A_AND_ITEM_B gets changed into ITEM_B after grabbing the output in every recipe that I've added --- So, how can I make it work as I want? Thanks in advance!
  18. Okay, so I'll do. I know what to do with my custom mod items, I don't have any trouble with adding tooltips to them. I do similarly to what you said, but I have all the tooltips in my lang file in case I wanted to translate the mod. But I don't think I'm allowed to re-initialize and override a VANILLA item, like minecraft:diamond...
  19. Hello, I'm going to add tooltips to vanilla items in my mod. I've actually added tooltips to the items I wanted..., but you'll clutch your head in disbelief how stupid is what I've done, it definitely can't take a place in a mod. In my ItemInit class: public static final ModItem DIAMOND = new ModItem("minecraft:diamond", new String[]{"description line 1", "description line 2"}); and the ModItem class: package ... import ... public class ModItem extends Item implements IHasModel { private String[] itemDescription; public ModItem(String name, String[] description) { itemDescription = description; setMaxDamage(0); maxStackSize = 64; if (name.startsWith("minecraft:")) { setUnlocalizedName(Translate.toVanillaNaming(name.substring(10))); } else { setUnlocalizedName(name); } setRegistryName(name); setCreativeTab(CreativeTabs.MISC); ItemInit.ITEMS.add(this); } @Override public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) { if (itemDescription != null) { for (String line : itemDescription) { list.add(line); } } } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } } Yeah... a vanilla item override. Let's not comment this. But I found something called ItemTooltipEvent. I think it should be used like so: In my RegistryHandler class: @SuppressWarnings("unused") @SubscribeEvent @SideOnly(Side.CLIENT) public static void itemToolTip(ItemTooltipEvent event) { ... } But what I have no idea is what to write inside this method to make it working. I couldn't find any clear example anywhere. Could somebody provide me one..? Thanks in advance!
  20. Well, I don't deny it I just don't think that I do need to fully understand every single part of my mod source code, since it's meant to be used only by me, to make my survival world builds look a little better But I'll keep that for future.
  21. Yeah, this might help with some things, thank you.
  22. Well, I've actually copied a ready workspace, so things like Handlers or Proxy weren't made by me.. I don't really know how to write the RegistryHandler without it.
  23. Item model registration code? I'm not sure what do you mean, but I can show you what I think you're talking about. Here's my RegistryHandler: package ... .util.handlers; import ... @EventBusSubscriber public class RegistryHandler { ... @SuppressWarnings("unused") @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for (Item item : ItemInit.ITEMS) { if (item instanceof IHasModel) { ((IHasModel) item).registerModels(); } } ... } ... } The ItemInit class contains a field ITEMS which is an ArrayList<Item> with all registered items. In addition, I can say that I don't have problems with any other Item model, I only have one with the ladder.
  24. I did add a model for the ItemBlock: Now the files look like this: { "parent": "block/block", "textures": { "particle": "modid:blocks/iron_ladder", "texture": "modid:blocks/iron_ladder" }, "elements": [ { "from": [ 0, 0, 15.2 ], "to": [ 16, 16, 15.2 ], "faces": { "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" } } } ] } { "parent": "item/generated", "textures": { "layer0": "modid:items/iron_ladder" } } And the textures are both under assets/textures/blocks/iron_ladder.png and assets/textures/items/iron_ladder.png ...and with all this, it works like I said, that is, it doesn't. And, no, there are no errors in log about the iron ladder.
×
×
  • Create New...

Important Information

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