Posted February 20, 20214 yr 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?
February 20, 20214 yr 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?
February 20, 20214 yr 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!
February 20, 20214 yr 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
February 20, 20214 yr 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) { }
February 20, 20214 yr Author These things don't give me access to the tools' harvest level or efficiency or any of those values. They're protected somehow.
February 20, 20214 yr https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java#L93 https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java#L135
February 21, 20214 yr 8 hours ago, peefTube said: I don't think that will do what I need it to. what do you want to do exactly?
February 21, 20214 yr Author 1 hour ago, Luis_ST said: what do you want to do exactly? 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: https://www.codepile.net/pile/oADOj7Jn https://www.codepile.net/pile/mE99pxEN
February 21, 20214 yr 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 February 21, 20214 yr by Luis_ST
February 21, 20214 yr Author That NOT including the OR statement, yea? Regardless, that wouldn't change anything. It acknowledges things this way just fine. Edited February 21, 20214 yr by peefTube
February 21, 20214 yr 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
February 21, 20214 yr 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(); }
February 21, 20214 yr 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.
February 21, 20214 yr 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
February 21, 20214 yr 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 February 21, 20214 yr by Luis_ST
February 21, 20214 yr 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
February 21, 20214 yr 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
February 21, 20214 yr 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 February 21, 20214 yr by peefTube learned something
February 21, 20214 yr 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 February 21, 20214 yr by Luis_ST
February 21, 20214 yr 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.