MrMarnic
Members-
Posts
39 -
Joined
-
Last visited
Everything posted by MrMarnic
-
Firstly you forgot the semicolon at the end of this line public static final RegistryObject<Item> TESTITEM = ITEMS.register("testitem", () -> new TestItem(new Item.Properties())) The second thing: In this line here: private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); You are using the variable MODID but you have never created it. You need to create it like this: public static final String MODID = "<your modid>"; Then it should work
-
@LexManos and @diesieben07 I have found the real reason for the error message. It was the formatting of drive. Steps to reproduce (on Windows): Use a working drive/flash drive. Format it with NTFS => put the project folder on it => everything works fine Format it with ExFAT or FAT32 => put the project folder on it => I get the error message I have tested it out with a working usb stick. On NTFS => everything is working ON FAT32/ExFat =>I get the error I don't know why this is happening, but this seems to be the reason.
-
This could be, but in this post for example https://mcreator.net/forum/75274/build-and-launch-errors-need-help they say that they have the project on a flash drive and get same error. And when it is really failing, why does it work for any other version? Could it have something to do with the partitioning of the drive?
-
Not even that did fix it. But it seems like I am not the only one with this problem. Here is the same error https://mcreator.net/forum/73623/116-upgrade-not-working . And here: https://mcreator.net/forum/75274/build-and-launch-errors-need-help I really have no idea anymore. I just hope I won't get the error in 1.17 .
-
Hello, when I try to run the runClient task to start Minecraft, I get this error: A problem was found with the configuration of task ':createSrgToMcp' (type 'GenerateSRG'). > File 'E:\MinecraftMods\SchulMod\build\extractSrg\output.srg' specified for property 'srg' does not exist. I hope you can help me. I am using Forge 1.16.5 - 36.1.25
-
[Solved] ItemStack Capabilities reset when moved in creative inventory
MrMarnic replied to MrMarnic's topic in Modder Support
Thank you very much. It is working now with getShareTag and readShareTag. -
[Solved] ItemStack Capabilities reset when moved in creative inventory
MrMarnic replied to MrMarnic's topic in Modder Support
Ok I undestand that. But can I maybe send the capability trough getShareTag() ? Or is this not possible at all and I can not create a Backpack item with capabilites? -
I have attached an inventory to an item with the slot size of one (At the beggining the slot is empty). When you right click with this item a gold ingot will be set in the slot. If you sneak and right click the Display name of the inserted item will be printed. (At first "Air" because not item is set) The issue was already adressed here, but there was never as solution. Old issue public class InventoryTestItem extends Item { public InventoryTestItem(Properties properties) { super(properties); setRegistryName("inv_test"); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { if(playerIn.isSneaking()) { playerIn.getHeldItem(handIn).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,null).ifPresent((h)-> { ItemStackHandler handler = (ItemStackHandler) h; handler.setStackInSlot(0,new ItemStack(Items.GOLD_INGOT)); }); }else { playerIn.getHeldItem(handIn).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,null).ifPresent((h)-> { ItemStackHandler handler = (ItemStackHandler) h; System.out.println(handler.getStackInSlot(0).getDisplayName()); }); } return super.onItemRightClick(worldIn, playerIn, handIn); } @Nullable @Override public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { return new InventoryTestProvider(); } public class InventoryTestProvider implements ICapabilityProvider, ICapabilitySerializable<CompoundNBT> { public ItemStackHandler handler; public InventoryTestProvider() { this.handler = new ItemStackHandler(1); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction side) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return LazyOptional.of(()->(T)handler); } return LazyOptional.empty(); } @Override public CompoundNBT serializeNBT() { CompoundNBT tag = new CompoundNBT(); tag.put("itemHandler",handler.serializeNBT()); return tag; } @Override public void deserializeNBT(CompoundNBT nbt) { handler.deserializeNBT(nbt.getCompound("itemHandler")); } } } The ItemStack will always keep the Gold Ingot (if set), even when moved in inventories (like chests). But when I move the Item in the Creative Inventory (for example from slot 1 to 2) the capability is reset and the "Air" is printed as Displayname.
-
Sorry. I was stupid and did override getNBTShareTag in a class that extends BasicBow.
-
Can be marked as solved
-
Hello, I have a custom Item which needs to be synced with the client. To do that I have looked up several threads and they suggested to override getNBTShareTag. But when I try to use it in the addInformation method the stack never has the values which are in getNBTShareTag. Item class: public class BasicBow extends Item { @Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { if(stack.hasTagCompound()) { System.out.println(stack.getTagCompound().hasKey("test")); } System.out.println(getNBTShareTag(stack).hasKey("test")); } @Override public boolean getShareTag() { return true; } @Nullable @Override public NBTTagCompound getNBTShareTag(ItemStack stack) { NBTTagCompound tag = super.getNBTShareTag(stack); if(tag == null) { tag = new NBTTagCompound(); } tag.setString("test","Hello world"); return tag; } } But the "test" key specified in getNBTShareTag is always empty in addInformation. I hope you can help me.