GUI slot that charges items

Started by cezar404 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
GUI slot that charges items

I have 1 singular slot inside a battery and I want it to charge the item inside.

How does one do that?

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
let's see... so what items…
Tue, 02/18/2025 - 21:42

let's see... so what items can be charged? how fast?

 

 

 

Joined Feb 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I want to charge items that…
Wed, 02/19/2025 - 00:24

I want to charge items that use RF/FE.

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay, just had a look and I…
Wed, 02/19/2025 - 01:10

Okay, just had a look and I think this is the best way to solve your problem:

1) Use "While this GUI is open tick" to trigger your charge event normally 
 

2) Use "When this GUI is closed" to store "Get current world time" as a NBT tag in your block entity

3) Use "When this GUI is opened" to subtract the stored world time from the current world time, this gives you the amount of ticks that have passed and you can then charge your item by how many have passed

4) Make sure you have an event that does the same thing as step 3 when the block is broken so people don't try to mine the block to get their item out and find it uncharged

Joined Feb 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't really understand…
Wed, 02/19/2025 - 02:52

I don't really understand the NBT part, could you explain more about this. Cuz i understand what I have to do but I can't replicate 

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use the "Set NBT number tag"…
Wed, 02/19/2025 - 02:57

Use the "Set NBT number tag" and "Get NBT number tag" code blocks to store a variable in the block. The only requirement is that your block is a block entity but it should be one already.

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The problem is "Get damage…
Wed, 02/19/2025 - 16:50

The problem is "Get damage of Provided itemstack" as the procedure doesn't provide an itemstack, you want to replace the "Provided itemstack" part with the "Get item from slot 0..." block.

Joined Feb 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So, i'll have to have these…
Wed, 02/19/2025 - 17:27

So, i'll have to have these blocks to take the  stored world time by the actual world time but how I implement the logic because i only have this and nothing else. Do I have to use a condition ?
https://imgur.com/a/zrZOjHe

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Switch them around so it's …
Wed, 02/19/2025 - 17:30

Switch them around so it's "Current world time - stored world time" and then charge your item by multiplying your tick charge amount by the result of that sum.

I will say that you probably want to change it so it charges every 4 ticks or so as charging ti every tick will probably charge it faster than you intend.

Joined Feb 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://imgur.com/a…
Wed, 02/19/2025 - 17:53

https://imgur.com/a/0rNN4et
The first image is "When this GUI is open" procedure and the second one "When this GUI is  closed" procedure. So if you could say if i did wrong or not?

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm breaking my "don't write…
Wed, 02/19/2025 - 18:21

I'm breaking my "don't write peoples code for them" rule again but here's an example of a script that will charge the item for every 4 ticks that have passed since the block was closed. the TIME_WHEN_CLOSED NBT tag is literally just "get current world time" that was triggered the last time the block was closed.

https://imgur.com/a/gopeLv3