Posted October 29, 20186 yr Hello my saviour, I'm creating an item/tool that is supposed to change a log into a stripped_log just like the new 1.13 mechanic. I'm using onItemUse (by a saw) to setBlockState. But my problem is that whenever I use the item in game, it doesn't do anything it also doesn't activate the print. Please consider that I'm not too advanced in modding. And I mainly use the Minecraft files and forge docs as reference. This is a GitHub I setup: I think the problem is within Java/objects/item/saw https://github.com/AlmightyElement/thirteen/tree/AlmightyElement-thirteen Thanks in advance, AlmightyElement
October 29, 20186 yr Author Hey diesieben, You're totally right, even dumber is that I've made this mistake before. Do you know how I can resolve this, so I can check the equality? Also I tried to use the debugger, but I have to look further into how to use it;
October 29, 20186 yr Author I tried this but it still doesn't seem to do anything. package com.almightyelement.thirteen.objects.item; import com.almightyelement.thirteen.Main; import com.almightyelement.thirteen.init.ModBlocks; import com.almightyelement.thirteen.init.ModItems; import com.almightyelement.thirteen.items.BlockBase; import com.almightyelement.thirteen.items.ItemBase; import com.almightyelement.thirteen.util.interfaces.IHasModel; import com.mojang.realmsclient.dto.PlayerInfo; import net.minecraft.block.Block; import net.minecraft.block.BlockLog; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class Saw extends ItemBase implements IHasModel{ public Saw(String name){ super(name); } @Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitx, float hity, float hitz) { ItemStack item = playerIn.getHeldItem(hand); IBlockState block = Blocks.LOG.getDefaultState(); Block clickedBlock = worldIn.getBlockState(pos).getBlock(); if (clickedBlock == block.getBlock()) { worldIn.setBlockState(pos, ModBlocks.STRIPPED_LOG.getDefaultState()); System.out.println("The system succeeded."); return EnumActionResult.PASS; } else { System.out.println("The system failed."); return EnumActionResult.FAIL; } } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } } Edited October 29, 20186 yr by AlmightyElement
October 29, 20186 yr Author Hey, So I did what you said and my method isn't being called. I even took away the if-statement that checks for the block (as a test) Is this because onItemUse isn't the right event? I want a block to change into another block whenever you right click it with this 'saw' item.
October 29, 20186 yr 49 minutes ago, AlmightyElement said: IHasModel Code Style Issue #3 16 minutes ago, AlmightyElement said: Is this because onItemUse isn't the right event? You have an @Override annotation. If it was wrong, your IDE would be giving you an error. You're still doing this: 47 minutes ago, diesieben07 said: Why are you first getting the default state from Blocks.LOG only to then immediately call getBlock on it? This roundtrip makes no sense. 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.
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.