Jump to content

Recommended Posts

Posted

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

Posted

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; :)

Posted (edited)

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 by AlmightyElement
Posted

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.

Posted
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.

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

    • seguridad seguridad
    • I am creating a server with mods but when i try tostart it it say in the logs:   [29Jan2025 20:36:50.715] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/fmlcore/1.20.1-47.3.27/fmlcore-1.20.1-47.3.27.jar is missing mods.toml file 159[29Jan2025 20:36:50.717] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/javafmllanguage/1.20.1-47.3.27/javafmllanguage-1.20.1-47.3.27.jar 160[29Jan2025 20:36:50.717] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/javafmllanguage/1.20.1-47.3.27/javafmllanguage-1.20.1-47.3.27.jar is missing mods.toml file 161[29Jan2025 20:36:50.718] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/lowcodelanguage/1.20.1-47.3.27/lowcodelanguage-1.20.1-47.3.27.jar 162[29Jan2025 20:36:50.718] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/lowcodelanguage/1.20.1-47.3.27/lowcodelanguage-1.20.1-47.3.27.jar is missing mods.toml file 163[29Jan2025 20:36:50.719] [main/DEBUG] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Considering mod file candidate /server/libraries/net/minecraftforge/mclanguage/1.20.1-47.3.27/mclanguage-1.20.1-47.3.27.jar 164[29Jan2025 20:36:50.719] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file /server/libraries/net/minecraftforge/mclanguage/1.20.1-47.3.27/mclanguage-1.20.1-47.3.27.jar is missing mods.toml file
    • How do you configure the entity reach of a custom weapon? Asking for 1.21 Minecraft parchment
    • This topic is over a year old. If you are having an issue, please read the FAQ for the proper way to post logs, and create your own thread.
    • hello i have been trying to put this specific pack for a while now but ive been hit with a new error everytime. no matter if its a previous version or if i change the pack format it will just not work please help latest log:https://mclo.gs/b6Qra5d <----- this is with pack version 1.20 no changes done to it debug log: https://mclo.gs/jczkfRK
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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