Jump to content

Recommended Posts

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?

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

 

  • Thanks 1
Posted
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!

Posted
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 :/

Posted
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) {
		
	}

 

Posted (edited)
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
Posted (edited)

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

Edited by peefTube
Posted
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

 

Posted
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();
			
		}

 

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

Posted
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

Posted (edited)
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
Posted
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

Posted
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

Posted (edited)
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
Posted (edited)
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
Posted
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...

×   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



×
×
  • Create New...

Important Information

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