
Silvertide
Members-
Posts
24 -
Joined
-
Last visited
Everything posted by Silvertide
-
Suggestion for best way to handle crop tiers
Silvertide replied to Silvertide's topic in Modder Support
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! -
Suggestion for best way to handle crop tiers
Silvertide replied to Silvertide's topic in Modder Support
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! -
Suggestion for best way to handle crop tiers
Silvertide replied to Silvertide's topic in Modder Support
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!!
-
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
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. -
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
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. -
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
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(); } }
-
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
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. -
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
Awesome thanks, I will get everything I can find that might help! -
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!
-
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
What does compiled over a different version mean? A different version of forge or of that specific library? -
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
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. -
LinkageError when trying to add capability to ItemStack
Silvertide replied to Silvertide's topic in Modder Support
Even more specifically, this line of code in the if statement causes that error: !stack.getCapability(ItemOwnerProvider.ITEM_OWNER).isPresent() For reference here is my ItemOwnerProvider: public class ItemOwnerProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> { public static Capability<ItemOwner> ITEM_OWNER = CapabilityManager.get(new CapabilityToken<ItemOwner>() { }); private ItemOwner owner = null; private final LazyOptional<ItemOwner> optional = LazyOptional.of(this::getOrCreateItemOwner); private ItemOwner getOrCreateItemOwner() { if(this.owner == null){ this.owner = new ItemOwner(); } return this.owner; } @Override public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { if(cap == ITEM_OWNER) { return optional.cast(); } return LazyOptional.empty(); } @Override public CompoundTag serializeNBT() { CompoundTag nbt = new CompoundTag(); getOrCreateItemOwner().saveNBTData(nbt); return nbt; } @Override public void deserializeNBT(CompoundTag nbt) { getOrCreateItemOwner().loadNBTData(nbt); } } and here is my ItemOwner: public class ItemOwner { private String owner; public String getOwner() { return this.owner; } public void setOwner(String owner) { this.owner = owner; } public void copyFrom(ItemOwner source) { this.owner = source.getOwner(); } public void saveNBTData(CompoundTag nbt) { nbt.putString("mymod_owner", this.owner); } public void loadNBTData(CompoundTag nbt) { this.owner = nbt.getString("mymod_owner"); } -
I've been struggling with this error for a while now. I am trying to add a simple capability to an ItemStack, a String owner field. I tracked down the error message to this function: @SubscribeEvent public static void onAttachCapabilitiesItemStack(AttachCapabilitiesEvent<ItemStack> event) { ItemStack stack = event.getObject(); if(!stack.getCapability(ItemOwnerProvider.ITEM_OWNER).isPresent()) { LOGGER.info("Trying to attach capabilites to: " + stack.getDisplayName()); event.addCapability(new ResourceLocation(Artifactory.MOD_ID, "properties"), new ItemOwnerProvider()); } } Specifically the line: event.addCapability(new ResourceLocation(MyMod.MOD_ID, "properties"), new ItemOwnerProvider()); I am getting the error: Caused by: java.lang.LinkageError: loader constraint violation: loader 'MC-BOOTSTRAP' @1ebd319f wants to load interface org.apache.logging.log4j.util.MessageSupplier. (org.apache.logging.log4j.util.MessageSupplier is in module org.apache.logging.log4j@2.17.1 of loader 'MC-BOOTSTRAP' @1ebd319f, parent loader 'bootstrap') In a different mod I am doing exactly the same code in almost every way except to a player and it works just fine when subclassing <Entity> and attaching a capability to the player. Any help would be greatly appreciated! An example of a mod repo that has ItemStack capabilities is a huge bonus! Thanks!
-
I'm trying to find a good example of adding a capability to an item using the AttachCapabilityEvent. Does anyone know of any examples or repos or tutorials for creating and adding a basic capability to an ItemEntity? I'm wandering around right now trying to find what specifically I need to do and why. Thank you!
-
Add NBT data to an item just picked up in the ItemPickupEvent
Silvertide replied to Silvertide's topic in Modder Support
Ah okay, interesting. I see the hook there for the forge event, yeah it just passes the ItemEntity and Player to the event to check. Do you know of a way to get this functionality? I haven't done a ton with NBT data. I'm not sure where the best place to set this would be. I also noticed there is a Owner attribute already on the ItemEntity. I wonder if that could be used. -
Awesome thank you for the help! I haven't done anything with capabilities yet, I'll look into it.
-
Copy item into custom item based on tag (1.19.2)
Silvertide replied to Silvertide's topic in Modder Support
I want to allow that original item to exist in the game, but I want to create another upgraded version of it with extra functionality. -
Is there a way to add data to an item just picked up by a player using the ItemPickupEvent? I'm currently doing this and it's not working: ItemStack stack = event.getStack(); Player player = event.getEntity(); CompoundTag nbtData = stack.getOrCreateTag(); if(nbtData.getString("myMod:myTag") == player.getStringUUID()){ // Do something } else { nbtData.putString("myMod:myTag", player.getStringUUID()); stack.setTag(nbtData); } Every time I pick up the item it doesn't find the tag and tries to set it again. I'm thinking maybe the item either can't be modified or I'm modifying the wrong item and it's already in the players inventory?
-
I want to give certain items an owner. When the item is picked up/looted I want the person who took it to be bound to the item. Then I can make it so only that person can pick up or loot the item from an inventory. Should I do this with NBT data? Say add a new NBT CompoundTag of "my_mod:owner" and set it to the UUID of the player? Then in forge events or the item events I can check if it has an owner and then make sure it is the owner trying to interact with it? Will that work or is there a cleaner way? Thanks for any help!!
-
I am adding an item to a new tag group I created and I wanted to see if there was a way I could loop through all of the items in that tag group and modify them or create a new version of them. For instance, I add "minecraft:diamond_sword" to the tag group. My mod will scan all items with that tag and create a new custom item that is a copy of that item. That way both the vanilla diamond sword and the custom diamond sword with additional features will exist in the game. I am not sure on the best way to do this. I was looking at RegisterEvent and possibly registering it there. Does anyone have any suggestions on the cleanest way to do this? I would also need to make sure this mod loads after other mods so that it could access items from the other mods and create copies of them as well. Any help is appreciated!