Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hannos

Members
  • Joined

  • Last visited

  1. Thanks man @MFMods, the others didn't really understand my question... I think I get it now. I'ma watch some java tutorials and study informatics. thanks for the help anyway and have a nice day!
  2. Ok, but if I look at the code, it literally says: public Inventory getInventory() { return this.inventory; } It is currently unclear to me, why there is a getter for it when all it does is returning the inventory field itself.
  3. Yeah, I expected that I would get into trouble if I did... Well, thank you! No, I cannot (without lying) Can you tell me?
  4. Yes, I suspected that... I am currently working with eclipse, is that a good choice? And how can I do it there? Yes, exactly what I meant.
  5. I am aware of how public and private works, however, I don't know where I can see/change it. I believe it is in that class System, in already set up code by forge, right? I am familiar with other languages and Java has some interesting new mechanics...
  6. @diesieben07Like I said, I am currently trying to learn java. Do you have any good websites or tutorials to do so? And is that correct, the player class is private, so I can't overwrite any values, but have to use GET?
  7. Well, thank you, @Azarsra, that's a much nicer way of helping people. Also for anybody having the same problem, you'll have to use player.getInventory().add(new ItemStack(Items.ITEM, QUANTITY)); Instead of addItemStackToInventory(...).
  8. Yeah I'm kinda trying to pick that up on my way... Can't you just tell me real quick if it's that obvious? Or do you have a tip for optaining said basic knowledge?
  9. Oh yeah, sure sorry so there is an error on the .inventory part that says "The field Player.inventory is not visible" I really don't know what that means and I have seen so many people says that it worked for them...
  10. So i'm pretty new to modding, but i want to add a feature to an item, that gives the player another item into the inventory whenever he uses it on a specific block. I already have a mecanism that detects the block and stuff but the player.inventory.addItemStackToInventory(new ItemStack(Items.ITEM)); function is not working. Is it because of 1.18? Or am I using it wrong? This is the code I use, partially copied from the internet XD @Override public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) { if (!world.isClientSide()) { System.out.println(player.getName().getString() + " used Item lul."); boolean isFluid = false; HitResult block = player.pick(20.0D, 0.0F, isFluid); if(block.getType() == HitResult.Type.BLOCK) { BlockPos blockpos = ((BlockHitResult)block).getBlockPos(); BlockState blockstate = player.level.getBlockState(blockpos); System.out.println("Looking at: "+blockstate.getBlock()+"\nIs Fluid: "+isFluid+"\nPosition= "+ blockpos.getX() + ", " + blockpos.getY() + ", " + blockpos.getZ()); if (blockstate.getBlock() == Blocks.OBSIDIAN) { player.inventory.addItemStackToInventory(new ItemStack(Items.BOWL)); } } } return super.use(world, player, hand); }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.