Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm working on a new mod, but I've become insistent upon extending the progression tree. Doing this, however, would require modifying a few different enums as well as changing the properties of multiple blocks and items to match.
I have limited experience with Java, I do have experience, but not nearly enough to know how to modify these values.

What I want to do, explicitly, is this:

  • Modify harvest levels of blocks and tool tiers to insert new tiers in between for certain ores, creating a more Terraria-like progression
  • Potentially override vanilla values with modded ones, without forcibly prying into the vanilla values to modify them on loadup

 

Any clues as to how to accomplish either or both of these tasks?

8 hours ago, peefTube said:

Modify harvest levels of blocks and tool tiers to insert new tiers in between for certain ores, creating a more Terraria-like progression

you can use events to modify blocks and tools

- PlayerEvent#HarvestCheck -> harvestLevel
- PlayerEvent#BreakSpeed -> breakSpeed
- LivingDamageEvent -> damage of tools
- LivingEntityUseItemEvent -> durablity

read the description of the events for more information about the function of the events and what they do

 

8 hours ago, peefTube said:

Potentially override vanilla values with modded ones, without forcibly prying into the vanilla values to modify them on loadup

what kind of values do you mean exactly can you give an example of that what you want to change?

 

  • Author
1 minute ago, Luis_ST said:

what kind of values do you mean exactly can you give an example of that what you want to change?

I want to change specifically the values already mentioned, though what you've provided solves both questions, so thank you!

  • Author
2 hours ago, Luis_ST said:

you can use events to modify blocks and tools

- PlayerEvent#HarvestCheck -> harvestLevel
- PlayerEvent#BreakSpeed -> breakSpeed
- LivingDamageEvent -> damage of tools
- LivingEntityUseItemEvent -> durablity

read the description of the events for more information about the function of the events and what they do

I'm working with events but I cannot figure out for the life of me how to access harvestLevel or breakSpeed :/

1 hour ago, peefTube said:

I'm working with events but I cannot figure out for the life of me how to access harvestLevel or breakSpeed

do you mean how you use the event?

then use this:

	@SubscribeEvent
	public static void HarvestCheck(PlayerEvent.HarvestCheck event) {
		
	}
	
	@SubscribeEvent
	public static void BreakSpeed(PlayerEvent.BreakSpeed event) {
		
	}

 

  • Author

These things don't give me access to the tools' harvest level or efficiency or any of those values. They're protected somehow.

8 hours ago, peefTube said:

I don't think that will do what I need it to.

what do you want to do exactly?

5 minutes ago, peefTube said:

Well, now I've made progress thanks to the help of the Slimeknights server
But I have these two files and the latter is not running when called:

do not use:

item.getItem().equals(Items.WOODEN_PICKAXE) || item.getItem().equals(Items.GOLDEN_PICKAXE)

use instead:

item.getItem() == Items.WOODEN_PICKAXE

 

Edit: that should fix your problem

Edited by Luis_ST

  • Author

That NOT including the OR statement, yea?
Regardless, that wouldn't change anything. It acknowledges things this way just fine.

Edited by peefTube

1 minute ago, peefTube said:

That NOT including the OR statement, yea?

no no no.

the equals method comes from the java object class and minecrft item class does not overwrite this method

so again don't use:

item.getItem().equals(Items.WOODEN_PICKAXE) || item.getItem().equals(Items.GOLDEN_PICKAXE)

use instead:

item.getItem() == Items.WOODEN_PICKAXE || item.getItem() == Items.GOLDEN_PICKAXE

 

7 minutes ago, diesieben07 said:

The two do exactly the same thing here.

but why? vanilla not overwirte the equals methode

 

29 minutes ago, peefTube said:

Well, now I've made progress thanks to the help of the Slimeknights server
But I have these two files and the latter is not running when called:

I think there is still a better way.

check whether the item is an instance of AxeItem / PickaxeItem / ShovelItem

then your vanillaToolTier sets to: ItemInstance#getTier#getHarvestLevel so like this:

you then have to set the ToolType

		Item item = player.getHeldItemMainhand().getItem();
		int vanillaToolTier = 0;
		
		if (item instanceof PickaxeItem) {
			
			vanillaToolTier = ((PickaxeItem) item).getTier().getHarvestLevel();
			
		} else if (item instanceof AxeItem) {
			
			vanillaToolTier = ((AxeItem) item).getTier().getHarvestLevel();
			
		} else if (item instanceof ShovelItem) {
			
			vanillaToolTier = ((ShovelItem) item).getTier().getHarvestLevel();
			
		}

 

  • Author
1 minute ago, Luis_ST said:

I think there is still a better way.

check whether the item is an instance of AxeItem / PickaxeItem / ShovelItem

then your vanillaToolTier sets to: ItemInstance#getTier#getHarvestLevel so like this:

you then have to set the ToolType


		Item item = player.getHeldItemMainhand().getItem();
		int vanillaToolTier = 0;
		
		if (item instanceof PickaxeItem) {
			
			vanillaToolTier = ((PickaxeItem) item).getTier().getHarvestLevel();
			
		} else if (item instanceof AxeItem) {
			
			vanillaToolTier = ((AxeItem) item).getTier().getHarvestLevel();
			
		} else if (item instanceof ShovelItem) {
			
			vanillaToolTier = ((ShovelItem) item).getTier().getHarvestLevel();
			
		}

 

This is completely ignoring the issue I'm running into. The method being called to my reflection file is not actually being called. It's simply not running.

3 minutes ago, peefTube said:

This is completely ignoring the issue I'm running into. The method being called to my reflection file is not actually being called. It's simply not running.

I'm trying to understand your code and why it doesn't work

37 minutes ago, peefTube said:

This is completely ignoring the issue I'm running into. The method being called to my reflection file is not actually being called. It's simply not running

sorry but i have to ask that. what do you want to change with the posted code?
if I understand correctly you check whether the tool is a gold pickaxe in the player's hand then you set the block harvest level to 1 so that the player can destroy the block

Am I right?

Edited by Luis_ST

  • Author
Just now, Luis_ST said:

sorry but i have to ask that. what do you want to change with the posted code?
if I understand correctly you check whether the tool is a gold pickaxe in the player's hand then you set the block harvest level to 1 so that the player can destroy the block

Am I right?

I don't want to change anything unless it fixes the error of the setToolHL() call not actually doing anything, which it absolutely should be doing something

6 minutes ago, peefTube said:

I don't want to change anything unless it fixes the error of the setToolHL() call not actually doing anything, which it absolutely should be doing something

then i try to understand the setToolHL method and to fix the error

  • Author
1 minute ago, Luis_ST said:

then i try to understand the setToolHL method and to fix the error

No need, it just started working and I have zero clue why because I changed none of the functionality

UPDATE: Just removed something I'd added (a console printline) and for whatever stupid reason, that broke it again. Absolutely no clue why this is behaving this way but I'm certainly getting a laugh out of it.

Edited by peefTube
learned something

7 minutes ago, peefTube said:

No need, it just started working and I have zero clue why because I changed none of the functionality

But you should use ObfuscationReflectionHelper to get the fields and use the SRG names

 

Edit: You should definitely use SRG names otherwise your code won't work outside of the IDE

Edited by Luis_ST

  • Author
15 minutes ago, Luis_ST said:

But you should use ObfuscationReflectionHelper to get the fields and use the SRG names

 

Edit: You should definitely use SRG names otherwise your code won't work outside of the IDE

Well, I may look into that later. For now, I have finally determined the cause as one specific oversight:

        if(vanillaToolTier >= vanillaBlockTier)
        {

This single line was keeping my code from running with a gold tool on iron ore, thus rendering the code useless. I have since removed it.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.