GUI slot that charges items

Started by cezar404 on

Topic category: Help with Minecraft modding (Java Edition)

Active 2 months ago
Joined Feb 2025
Points:
19

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1
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?

Active 4 hours ago
Joined Sep 2024
Points:
119

User statistics:

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

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

 

 

 

Active 2 months ago
Joined Feb 2025
Points:
19

User statistics:

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

I want to charge items that use RF/FE.

Active 1 month ago
Joined May 2021
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 66
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

Active 1 month ago
Joined Feb 2025
Points:
37

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
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 

Active 1 month ago
Joined May 2021
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 66
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.

Active 1 month ago
Joined Feb 2025
Points:
37

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
Yeah, so I tried making the…
Wed, 02/19/2025 - 16:34

Yeah, so I tried making the trigger "While this GUI is open tick" for my charging system but MCreator says it's missing dependencies: 
https://imgur.com/a/lUQrW5J

Active 1 month ago
Joined May 2021
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 66
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.

Active 1 month ago
Joined Feb 2025
Points:
37

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
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

Active 1 month ago
Joined May 2021
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 66
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.

Active 1 month ago
Joined Feb 2025
Points:
37

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
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?

Active 1 month ago
Joined May 2021
Points:
588

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 66
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