I am expecting this to have different ItemStacks for each version of the crop. I'm trying to limit it to maybe 3 tiers so it doesn't bloat too much. We'll see how that goes!
Of course, I'm definitely not looking for any design or modding, I just wasn't sure on the best path forward with creating this cropblock or crop item to have that tier data. Mostly between making my own custom item and adding NBT or using capabilities and attaching that to existing items. Thanks, I'll read through all of this and try things out!
I understand fairly well the process of creating my own crop or item or block, the hard part I'm running into is how to add features to existing crops, or any item for that matter, with the least impact possible. I want this to work with other mods and be highly configurable with datapacks. The resulting crop item that comes from the block will also need a tier value based on the crop it came from. And the resulting food as well. One thing at a time though..
Hello! I am newish to modding and I want to make a small mod. Basically all it would do is add a tier to a crop. The higher the tier the better the crop which has effects on the food it makes and hunger/saturation values. I'm just not sure on the best way to do this. I want this to be able to apply to vanilla minecraft crops, but also be configurable by datapack to add modded crops to it as well. Do I need to create a custom TieredCropBlock that has it's own NBT? Should I use a capability? Any tips or if you know of any examples similar to this would be appreciated!!
Thank you!!
Hmm okay, I gave that a read and it's still not super clear. Unfortunate that that is still an open PR and hasn't been changed yet. I guess I'll try to get this working now then go back and fix it later.
It seems like its something to do with the ItemStack implementation. When I attach this capability to a player instead
@SubscribeEvent
public static void onAttachCapabilitiesItemStack(AttachCapabilitiesEvent<Entity> event) {
if(event.getObject() instanceof Player){
Player player = (Player) event.getObject();
if(!player.getCapability(ItemOwner.INSTANCE).isPresent()) {
LOGGER.info("Trying to attach capabilites to: " + player.getStringUUID());
ItemOwnerAttacher.attach(event);
}
}
}
It works just fine.
Yeah it's weird! I just refactored it using an example someone posted and I'm getting the same thing. Here is the repo:
https://github.com/Silvertide7/Artifactory
Awesome, thanks!
I am noticing that when I run the code
@SubscribeEvent
public static void handle(AttachCapabilitiesEvent<ItemStack> event) {
LOGGER.info("ItemStack: ", event.getObject().getDisplayName());
}
It does successfully print out all of the item stacks in the area. I am running into issues in actually attaching the capabilities to this ItemStack though.
Okay awesome, I'll give that a read!
For the second part, are you saying something like this wouldn't work and I should use the second code?
// What I have now
@SubscribeEvent
public static void handle(AttachCapabilitiesEvent<ItemStack> event) {
// Code here
}
// instanceof cast
public static void handle(AttachCapabilitiesEvent<Entity> event) {
if(event.getObject() instanceof ItemStack){
ItemStack stack = (ItemStack) event.getObject();
}
}
Here is some extra info:
debug.log - https://pastebin.com/3pEDWLqu
server crash report - https://pastebin.com/yFPWZtKv
client crash report - https://pastebin.com/yaK2cd4T
build.gradle - https://pastebin.com/JKrcG9t4
Hopefully something here helps! I'll keep researching it too.
I am working on a very simple mod but I am fairly new to modding. I am learning a lot quickly but I'm running into some fundamental design problems that I'm not ready for, as well as a bug I can't fix, and I'm not sure how to troubleshoot it. I would be willing to pay someone who is experienced to do a screen share call with me and try to help me debug the issue as well as pick their brain on some implementation details. The mod is fairly small and deals around adding functionality to existing items in the game. I'd prefer someone who has made mods they can show on curseforge or something just for verification. Let me know if this isn't the right place for that! Thanks!
Do you have any advice for troubleshooting this? I have 2 identical projects with as far as I can tell all the same settings and packages and dependencies. One of them the Player capabilities using almost this same implementation works fine. In the other it errors out.