Started by
cezar404
on
Topic category: Help with Minecraft modding (Java Edition)
I have 1 singular slot inside a battery and I want it to charge the item inside.
How does one do that?
Topic category: Help with Minecraft modding (Java Edition)
I have 1 singular slot inside a battery and I want it to charge the item inside.
How does one do that?
let's see... so what items can be charged? how fast?
I want to charge items that use RF/FE.
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
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
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.
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
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.
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
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.
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?
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