Jump to content

Recommended Posts

Posted

The way I want this to work:

You throw the dragon bone ax on top of a Gigas Cedar Log and right-click the log with an empty hand and it gives you a Gigas Cedar Branch if you are above y = 200.

 

Log method

@Override
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
		
		AxisAlignedBB above = new AxisAlignedBB(pos.up());
		boolean hasAxe = false;
		List<EntityItem> entities = worldIn.getEntitiesWithinAABB(EntityItem.class, above);
		
		for(EntityItem ei : entities) {
			if (ei.getItem().getItem().equals(ModItems.DRAGON_BONE_AXE)) {
				hasAxe = true;
			}
		}
		
		if (pos.getY() > 200 && playerIn.inventory.getCurrentItem() == ItemStack.EMPTY && hasAxe) {
			playerIn.addItemStackToInventory(new ItemStack(ModItems.GIGAS_CEDAR_BRANCH, 1));
		}
		return false;
	}

 

Dragon Bone Ax code (unnecessary variables and stuff excluded)

public class ModItems {
	
	public static final List<Item> ITEMS = new ArrayList<Item>();
	
	//Tooltips
	
	//Object Priorities
	public static final int P_DRAGON_BONE_AXE = 10;
	
	//Materials
	public static final ToolMaterial M_DRAGON_BONE = EnumHelper.addToolMaterial("m_dragon_bone", P_DRAGON_BONE_AXE, P_DRAGON_BONE_AXE*60, P_DRAGON_BONE_AXE/4.0f, P_DRAGON_BONE_AXE/3.0f, 10);
	
	//Tools
	public static final ItemAxe DRAGON_BONE_AXE = new ToolAxe("dragon_bone_axe", M_DRAGON_BONE, P_DRAGON_BONE_AXE, SAOM.saoModTab);
	
	//Items
	
}

 

but it doesn't work

Posted
17 minutes ago, TheGoldenProof said:

playerIn.inventory.getCurrentItem() == ItemStack.EMPTY

Don't do this, use ItemStack#isEmpty instead. An item stack may be empty but not equal to ItemStack.EMPTY.

 

17 minutes ago, TheGoldenProof said:

public static final ItemAxe DRAGON_BONE_AXE = new ToolAxe("dragon_bone_axe", M_DRAGON_BONE, P_DRAGON_BONE_AXE, SAOM.saoModTab);

Don't ever use static initializers. Instantinate your stuff directly in the appropriate registry event.

 

Apart from that use the debugger to see which items are actually selected within the AABB specified and whether ut contains your axe item. You might need to extend it a bit. Also consider using java 8's streams instead of loops in cases like this one.

Posted
5 minutes ago, V0idWa1k3r said:

Don't ever use static initializers. Instantinate your stuff directly in the appropriate registry event.

I'm new at modding (you can tell) and so I don't know what registry events are or how to instantiate my objects in them

 

5 minutes ago, V0idWa1k3r said:

Apart from that use the debugger to see which items are actually selected within the AABB specified and whether ut contains your axe item. You might need to extend it a bit. Also consider using java 8's streams instead of loops in cases like this one.

Also somewhat new to java and eclipse. I've never used Eclipse's debugger and I have heard of streams but I don't really know what they are.

 

I'll look into streams and try the debugger but if you could explain how to do the registry thing a little more that would be great

Posted
4 minutes ago, TheGoldenProof said:

so I don't know what registry events are

Yes you do. Registry events are events where you register your things. RegistryEvent.Register<? extends IForgeRegistryEntry>. If you have any items/blocks present in your mod you are using registry events.

 

5 minutes ago, TheGoldenProof said:

how to instantiate my objects in them

Yes you do. You are currently instantinating your objects in static initializers. Just do the same in the registry event instead.

 

6 minutes ago, TheGoldenProof said:

I've never used Eclipse's debugger

Well maybe it is time to start. You can't really solve issues without a debugger and you can't write pretty much anything above a hello world application if you can't solve issues.

 

6 minutes ago, TheGoldenProof said:

I have heard of streams but I don't really know what they are.

They are a java feature. If you don't know java then you need to learn it before making a mod otherwise you are constructing a rocket without any instructions.

Posted
1 minute ago, V0idWa1k3r said:

If you don't know java then you need to learn it before making a mod otherwise you are constructing a rocket without any instructions.

k i guess ill just stop and think about how many hours of my life i just wasted

Posted

If you know any other Object Oriented Programming already, it won’t be impossible to go straight into modding, and all you really need is a basic java tutorial. It shouldn’t take very long at all to learn java, and that time is definitely not “wasted”

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

Posted

Someone's been watching Sword Art Online season 3. ?

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
1 minute ago, Cadiboo said:

If you know any other Object Oriented Programming already, it won’t be impossible to go straight into modding, and all you really need is a basic java tutorial. It shouldn’t take very long at all to learn java, and that time is definitely not “wasted

Thanks, I didn't really mean what I said, I was just frustrated. I have a decent understanding of java stuff but I definitely don't know everything, because there is SO much to learn.

 

2 minutes ago, Draco18s said:

Someone's been watching Sword Art Online season 3. ?

In fact I am, however I was impatient and started reading the alicization books (9+) and now I'm on 12

Posted

You can also use println statements to see what is going on during runtime. Just print out the list of entities to the console to check whether your axe is in the list. Perhaps not as fancy as using the debugger, but it often gets the job done. You should still take the time to learn how to use the debugger. There are times when it's super helpful, particularly when you need to see the details of what vanilla code is doing.

 

5 minutes ago, TheGoldenProof said:

Thanks, I didn't really mean what I said, I was just frustrated. I have a decent understanding of java stuff but I definitely don't know everything, because there is SO much to learn.

You can make mods perfectly fine without knowing what Java 8 streams are or how to use them. You do, however, need to know Java basics well.

 

29 minutes ago, V0idWa1k3r said:

Don't ever use static initializers. Instantinate your stuff directly in the appropriate registry event.

I've heard this a few times, but never with any reason given. What's so horrific about using static initializers?

Posted
1 minute ago, Daeruin said:

I've heard this a few times, but never with any reason given. What's so horrific about using static initializers?

Because you can't control when it executes and Forge may not have done all the things it needs to for the Registries, so your item is missing a key bit of information and won't register correctly.

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
1 minute ago, Daeruin said:

I've heard this a few times, but never with any reason given. What's so horrific about using static initializers?

What draco18s said as well as

You can’t control the order of when they are instantiated. This poses a problem for items with creative tabs, and creative tabs with item icons, either the item will have a null creative tab, or the creative tab will have a null item, and you can’t control which one it is.

 

Also, you should use @ObjectHolder so people can override your objects

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

Posted
13 minutes ago, Daeruin said:

What's so horrific about using static initializers?

In addition to what everyone else said I've seen people say that people using static initializers is the only thing that prevents registries from being reloadable during runtime.

Posted
On 10/30/2018 at 2:32 PM, V0idWa1k3r said:

registries being reloadable during runtime

^ This would allow mods to be added and removed without restarting the game

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.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)

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

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