BURN447 Posted May 19, 2018 Posted May 19, 2018 I'm creating a modifier system to tools, which I've mentioned a few times here, and I'm trying to edit some of these values. However, due to passing in an ItemStack, I cannot figure out how to cast it into the type of Item that I can modify. How would I go about modifying these values in my capability. One theory I've had is declaring those variables in the capability and then setting the defaults in the ItemClass, but I'm not 100% sure how to do that. Quote
BURN447 Posted May 19, 2018 Author Posted May 19, 2018 If I was trying to change the efficiency of a tool, there is a base value in the Item class. for an individual ItemStack, what is the accepted way to edit the speed of a tool. I haven't been able to find any resources online Quote
BURN447 Posted May 19, 2018 Author Posted May 19, 2018 I hadn't seen that comment, but where would I override those methods? Would I be declaring a new Instance of the item in the Capabilities class and then passing in the stack? Quote
BURN447 Posted May 19, 2018 Author Posted May 19, 2018 https://github.com/BURN447/DartcraftReloaded/blob/master/src/main/java/burn447/dartcraftReloaded/Items/Tools/ItemForcePickaxe.java This is my Current tool class. I am overriding the methods, but when there is a specific tag, probably NBT, I'm trying to change the efficiency value. I'm also getting a stack using getStackInSlot, which gives me an itemstack, and if it belongs to my mod, it's supposed to add a modifier Quote
loordgek Posted May 19, 2018 Posted May 19, 2018 override in your ItemForcePickaxe initCapabilities here is how caps work http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ Quote
loordgek Posted May 19, 2018 Posted May 19, 2018 (edited) https://github.com/BURN447/DartcraftReloaded/blob/master/src/main/java/burn447/dartcraftReloaded/Items/Tools/ItemToolBase.java remove: implements Capability.IStorage<IToolModifier> and move the fields inside your capability and use @Override if you Override a method Edited May 19, 2018 by loordgek Quote
BURN447 Posted May 19, 2018 Author Posted May 19, 2018 On 5/19/2018 at 2:27 PM, loordgek said: override in your ItemForcePickaxe initCapabilities here is how caps work http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ How would I go about overriding something in initCapabilities? Quote
loordgek Posted May 20, 2018 Posted May 20, 2018 you are doing it here https://github.com/BURN447/DartcraftReloaded/blob/master/src/main/java/burn447/dartcraftReloaded/Items/Tools/ItemToolBase.java#L139 Quote
loordgek Posted May 20, 2018 Posted May 20, 2018 https://github.com/loordgek/DartcraftReloaded/commit/0eefbaa3794546c05cdce4bd56d779b03d3ccdf9 do you get the idea now?? Quote
BURN447 Posted May 21, 2018 Author Posted May 21, 2018 Thanks for the help. I believe I have an understanding of what's happening Quote
Recommended Posts
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.