Posted April 26, 20196 yr Hello guys. Basically I maded a custom recipe with the subscribe event RightClickBlock event. The main recipe class: Spoiler @Mod.EventBusSubscriber public class GroundDiggingProcessing { public static List<DiggingRecipe> RECIPES = new ArrayList<>(); public static void initializeRecipes() { registerRecipe(new DiggingRecipe("grass_ball_recipe", Blocks.GRASS, ModItems.GRASS_BALL, Blocks.DIRT)); } @SubscribeEvent public static void onBlockRightClick(PlayerInteractEvent.RightClickBlock e) { Block b = e.getWorld().getBlockState(e.getPos()).getBlock(); ItemStack i = e.getItemStack(); for(DiggingRecipe r : RECIPES) { if(e.getEntityPlayer() != null) { if(!(e.getWorld().isRemote)) { if(b == r.getMainBlock() && i.getItem() instanceof ItemMiniShovel) { if(e.getEntityPlayer().isSneaking()) { e.getEntityPlayer().dropItem(new ItemStack(r.getBallOutput(), 1), false); e.getEntityLiving().getHeldItemMainhand().damageItem(1, e.getEntityPlayer()); e.getWorld().playSound(null, e.getPos(), b.getSoundType().getBreakSound(), SoundCategory.BLOCKS, b.getSoundType().getVolume() * 0.4F, b.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1)); } } } } } } public static void registerRecipe(DiggingRecipe recipe) { RECIPES.add(recipe); } } The "DiggingRecipe" class, the recipe used: Spoiler public String recipeName; public Block mainBlock; public Item ballOutput; public Block outputBlock; public DiggingRecipe(String recipeName, Block block, Item item, Block blockOutput) { this.setRecipeName(recipeName); this.setMainBlock(block); this.setBallOutput(item); this.setOutputBlock(blockOutput); } public String getRecipeName() { return recipeName; } public Block getOutputBlock() { return outputBlock; } public void setOutputBlock(Block outputBlock) { this.outputBlock = outputBlock; } public Block getMainBlock() { return mainBlock; } public Item getBallOutput() { return ballOutput; } public void setRecipeName(String recipeName) { this.recipeName = recipeName; } public void setMainBlock(Block mainBlock) { this.mainBlock = mainBlock; } public void setBallOutput(Item ballOutput) { this.ballOutput = ballOutput; } In the main class seems that in the subscribe event the game does not give the itemstack to the player. And also it does not damage the item. I dont understand why. Thanks for the help. Edited April 26, 20196 yr by nov4e
April 26, 20196 yr Author I actually registered it with a @EventBusSubscriber. Maybe do I have to register it via MinecraftForge.EVENT_BUS.register(listener);
April 26, 20196 yr for(DiggingRecipe r : RECIPES) { if(e.getEntityPlayer() != null) { if(!(e.getWorld().isRemote)) { if(b == r.getMainBlock() && i.getItem() instanceof ItemMiniShovel) { if(e.getEntityPlayer().isSneaking()) { e.getEntityPlayer().dropItem(new ItemStack(r.getBallOutput(), 1), false); e.getEntityLiving().getHeldItemMainhand().damageItem(1, e.getEntityPlayer()); e.getWorld().playSound(null, e.getPos(), b.getSoundType().getBreakSound(), SoundCategory.BLOCKS,b.getSoundType().getVolume() * 0.4F, b.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1)); } } } } } nooooo dont do it like this first check if the player is null and if the world if remote and then loop over your recipes and now on topic: have you placed a breakpoint on it ??
April 27, 20196 yr Author 13 hours ago, loordgek said: dont do it like this first check if the player is null and if the world if remote and then loop over your recipes So I do have to do this checks after checking if the player is sneaking? 13 hours ago, loordgek said: have you placed a breakpoint on it ?? What do you mean with breakpoint?
April 27, 20196 yr do use idea ?? https://www.jetbrains.com/help/idea/using-breakpoints.html or eclipse https://www.eclipse.org/community/eclipse_newsletter/2017/june/article1.php
April 27, 20196 yr 19 hours ago, nov4e said: I actually registered it with a @EventBusSubscriber. Maybe do I have to register it via MinecraftForge.EVENT_BUS.register(listener); About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
April 27, 20196 yr Author @Cadiboo Yes, I coded it with Mod.EventBusSubscribe using a static void. I just said if i try the other method will it work? 54 minutes ago, loordgek said: do use idea ?? https://www.jetbrains.com/help/idea/using-breakpoints.html or eclipse https://www.eclipse.org/community/eclipse_newsletter/2017/june/article1.php @loordgek So basically I have to run the debug client, right?
April 27, 20196 yr Author 26 minutes ago, loordgek said: yes done. Basically its the same thing it does not work.
April 27, 20196 yr Author https://github.com/nov4e/Exa/tree/master/src/main/java/exa_resources/forge/processing
April 27, 20196 yr got it working. the problem was you set the recipe to early and your grass_ball was null move https://github.com/nov4e/Exa/blob/master/src/main/java/exa_resources/forge/ExaResources.java#L38 to init. the way you register your items and blocks is wrong https://github.com/nov4e/Exa/blob/master/src/main/java/exa_resources/forge/features/ModItems.java#L81 dont do that let forge do that for you, that is why @ObjectHolder exist https://github.com/nov4e/Exa/blob/master/src/main/java/exa_resources/forge/base/ItemMiniShovel.java#L70 dont compare strings like that, read this https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
April 27, 20196 yr Author Thank you @loordgek for your reply!! I finally fixed it. I will fix the item registry and i will give a look to string comparing. Thank you? Can I ask 1 more thing? How can I set a block to another block? Edited April 27, 20196 yr by nov4e
April 27, 20196 yr 21 minutes ago, nov4e said: Can I ask 1 more thing? How can I set a block to another block? ?? i dont understand
April 27, 20196 yr Author 1 hour ago, loordgek said: ?? i dont understand Basically replace a block with another block.
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.