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.

cinsiian

Members
  • Joined

  • Last visited

Everything posted by cinsiian

  1. So the packet will be(Server-ToClient): public class ManaPacket { public int mana; public ManaPacket() {} public ManaPacket(int mana) { this.mana = mana; } public static void writeIn(ManaPacket packet, PacketBuffer buffer) { buffer.writeInt(packet.mana); } public static ManaPacket readIn(PacketBuffer buffer) { return new ManaPacket(buffer.readInt()); } public static class PacketHandler { public static void run(final ManaPacket packet, Supplier<NetworkEvent.Context> context) { context.get().enqueueWork(() -> { int i = context.get().getSender().getCapability(ManaProvider.MANA, null).orElseThrow(null).get(); packet.mana = i; }); } } }
  2. What handler? The handler of the actual packet or the handler of the network?
  3. ok but how do i actually set the client mana? In the packet's Handler? https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/network/ToClientMessageOreParticles.java#L54 Like here? And how can I get the serverplayer? Do I have to save it in the packet as well?
  4. Can someone explain how to use the network system? I tried to get it work with the documentation as a reference without success.
  5. Basically if its the same player, it will take the data from the server(ManaUtils methods) and update them to the client player(Minecraft.getInstance().player). I tried to do that...
  6. So basically what I did is this and seems that its working. public static void updateMana(PlayerEntity player) { IMana oldMana = ManaUtils.getMana(Minecraft.getInstance().player); IMana newMana = ManaUtils.getMana(player); if(oldMana != null && newMana != null) { oldMana.set(newMana.get()); } }
  7. Ok, it did work but i have few issues setting up the capability adding/setting the value. https://github.com/cinsiian/mod/blob/master/java/cinsiian/urtima/util/ManaUtils.java The hud displays the correct amount of mana but when I try consuming it for some reason it return that the player does not have the correct mana amount
  8. there is Player.isSwimming but I also need if the player is underwater even without swimming
  9. Thank you guys, now textures work perfectly but I have few last things to ask. 1) How can I see if the air bubble bar is rendered(so i can move the mana bar up so it does not contrast)? 2) What is the correct way to get/set the capability?, I used: player.getCapability(ManaProvider.MANA, null).orElseThrow(null).get() player.getCapability(ManaProvider.MANA, null).orElseThrow(null).set() It's really buggy, sometimes it doesnt even do anything
  10. Is that event executed every tick?
  11. What are the RenderGameOverlayEvent.Pre and RenderGameOverlayEvent.Post ?
  12. Ok so I managed to get the event work but the texture is not rendering correctly: public final ResourceLocation TEXTURE = new ResourceLocation(Reference.MODID, "textures/gui/mana_hud.png"); @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent event) { if(event.getType() == ElementType.AIR) { Minecraft mc = Minecraft.getInstance(); int x = event.getWindow().getScaledWidth() / 2 + 10; int y = event.getWindow().getScaledHeight() - 48; if(!(mc.player.isSpectator() || mc.player.isCreative())) { mc.getTextureManager().bindTexture(TEXTURE); drawBackground(x, y); } } } private void drawBackground(int x, int y) { drawTexturedModalRect(x, y, 0, 0, 89, 9); } private void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { Minecraft mc = Minecraft.getInstance(); mc.ingameGUI.blit(x, y, textureX, textureY, width, height); } The texture: https://ibb.co/ct9XNRy In-game: https://ibb.co/PzyTqkP
  13. Oh ok ill' do it but whats the difference?
  14. I dont have another instance of it
  15. Ok, I dont get the crash anymore when I join. Everything seems working right now, I returned LazyOptional.of(() -> INSTANCE).cast(); https://github.com/cinsiian/mod/tree/master/java/cinsiian/urtima/common/capability/mana Thats the full package related to mana, everything should be ok. Now I will start working on the Bar in the RenderGameOverlayEvent. Is RenderGameOverlayEvent executed every tick? I will check every tick: if the mana is 20 I render a thing, if its 19 render another thing ecc...
  16. @CapabilityInject(IMana.class) public static final Capability<IMana> MANA = null; public IMana INSTANCE = MANA.getDefaultInstance(); @SuppressWarnings("unchecked") public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { return (LazyOptional<T>) INSTANCE; } How can I return an actual instance of LazyOptional?
  17. It calls the IMana not the LazyOptional.
  18. There arent any constructors for it...
  19. So what I should return then?
  20. to return in the getCapability() can i just make a new LazyOptional?
  21. What LazyOptional ?? like the default one this.getCompatibility() ?
  22. You can't do this either don't know if I'm looking at outdated code or not. Isn't that the thing I should return?
  23. It's the ManaProvider class: https://github.com/cinsiian/mod

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.