-
Posts
42 -
Joined
-
Last visited
Everything posted by Oen44
-
[1.12.2]Problems with changing Player Health and Healthbar
Oen44 replied to _Cruelar_'s topic in Modder Support
Yeah, recently learned about Capabilities. Followed few tutorials (unfortunately not updated) and with some tweaks got it to work. Here is my code for reference - https://github.com/Oen44/RPG-Mod-MC And here you have something about how to make one - http://jabelarminecraft.blogspot.com/p/minecraft-17x.html -
[1.12.2]Problems with changing Player Health and Healthbar
Oen44 replied to _Cruelar_'s topic in Modder Support
That didn't change position at all? Add that at the beginning of event (try random number) or add event.setCanceled(true) to see if icons will disappear. -
[1.12.2]Problems with changing Player Health and Healthbar
Oen44 replied to _Cruelar_'s topic in Modder Support
What didn't work? Maybe you didn't use it properly. Be more specific please. That code is working without doubt, so there must be something else. -
[1.12.2]Problems with changing Player Health and Healthbar
Oen44 replied to _Cruelar_'s topic in Modder Support
if (event.getType() == ElementType.ARMOR) { //event.setCanceled(true); // disable armor GUI or //GuiIngameForge.left_height = X; // change position } Inside RenderGameOverlayEvent.Pre -
It works now and I get how to deal with networking, thank you. But before that I wanted to print data on player login and what I have encountered is that EventPlayer class wasn't registering @SubscribeEvent so I had to add @Mod.EventBusSubscriber and now it works Do I understand this correctly? If I send packet that adds XP points to server and there add that to EntityPlayerMP capabilities, then if someone hack client code and add to EntityPlayer capabilies some XP then server will have different values because EntityPlayerMP is a different instance and that's where I should check if play has XYZ amount of XP if needed? Updated code if you want to check and see if there is something wrong anyway.
-
Made changes (hopefully good) but still nothing. Code updated.
-
Forgot to delete that. That's from tutorial or something but didn't work anyway. How do I handle button press on server-side then? I need to use that somehow, what do you suggest?
-
Hi, I've tried to implement Capabilities to save player data (XP points etc.). Everything is working except saving data. After leaving game (not closing client) and reentering, data is not preserved. What I did notice is that writeNBT instance is always returning 0 when getting XP points. Code: https://github.com/Oen44/RPG-Mod-MC
-
Thanks for the help but I'll stay with deltaTime. Can be closed
-
Of course there is TickEvent... I should have think about that before, ohh my. float prevValue; float currentValue; @SubscribeEvent public void onClientTick(ClientTickEvent event) { if(event.phase == Phase.END) { prevValue = currentValue; currentValue = (currentValue + 1) % 100; } } float actual = prevValue + (currentValue - prevValue) * event.getPartialTicks(); // in RenderGameOverlayEvent.Text Well... It's not working well. It's starting slow and then goes very fast and then slow again and so on (because of modulo i guess).
-
All I did was this.alpha[i] -= (int) (0.4f * event.getPartialTicks()); this.height[i] += 0.1f * event.getPartialTicks(); And it's very slow on low FPS and getting faster with more FPS. Yeah, no idea where to put prevValue and currentValue. Should I make thread like this? ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); exec.scheduleAtFixedRate(new Runnable() { @Override public void run() { prevValue = currentValue; currentValue = (currentValue + 1) % 100; } }, 0, 20, TimeUnit.SECONDS); I just want to check how is that going to look like with what you wrote. The thing is that RenderGameOverlayEvent is executed more times based on FPS so deltaTime is doing something to balance and it's easy to accomplish.
-
That doesn't change anything. Ticks are not helpful here, it's just looking bad.
-
Hi, There should be method that returns deltaTime for client. As I was saying here about that. That helped me a lot to create own deltaTime. Why not make it build-in?
-
So how ticks work compared to deltaTime? Lower FPS (30): Ticks - text is adapting to FPS and moves slow - not cool Delta - text is smooth as for such low FPS and stays the same time as with high FPS - what I want Higher FPS (around 600): Ticks - text is smooth and very fast, again, adapting to FPS - not cool Delta - text is smooth, perfect pace - what I want Conclusion? Ticks are not good for that kind of animations.
-
long oldTime = newTime; long newTime = Minecraft.getMinecraft().getSystemTime(); long deltaTime = newTime - oldTime; deltaTime ready. this.alpha[i] -= 0.3 * deltaTime; this.height[i] += 0.06f * deltaTime; Calculations ready. Working perfectly
-
Hi, I've made fading and floating text effect like this: It's cool, I like how it ended up but... There is framerate issue. When making this, I was at 75FPS cap (VSync) and after unlocking to unlimited FPS, text started moving way too fast. Here is the code @SubscribeEvent public void onRenderOverlayText(RenderGameOverlayEvent.Text event) { ScaledResolution sr = event.getResolution(); EntityPlayer player = Minecraft.getMinecraft().player; GL11.glPushMatrix(); GL11.glScalef(1.0F, 1.0F, 1.0F); for (int i = 0; i < 12; i++) { if (!this.isVisible(i)) continue; this.alpha[i] -= 3; this.height[i] += 0.6f; if (this.height[i] > 50.0f) { this.hide(i); continue; } Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("+" + this.xp[i] + " XP", sr.getScaledWidth() / 2 + 50, sr.getScaledHeight() / 2 - this.height[i], 0xFFFFFF | (this.alpha[i] << 24)); GL11.glScalef(0.5f, 0.5f, 0.5f); Minecraft.getMinecraft().renderEngine.bindTexture(icon); this.drawTexturedModalRect((sr.getScaledWidth() / 2 + 32) * 2, ((sr.getScaledHeight() / 2) - 5 - this.height[i]) * 2, i * 32, (i > 7 ? 1 : 0) * 32, 32, 32); } GL11.glPopMatrix(); } Is there any way to make this run at same pace? Like deltaTime?
-
Hi, What's the best way to open custom GUI when player opens inventory? I don't want to replace inventory GUI but add some text on left side. Tried player.openGui on GuiOpenEvent but nothing is displayed. @SubscribeEvent public void OnGuiOpen(GuiOpenEvent event) { if(event.getGui() != null && event.getGui() instanceof GuiInventory) { EntityPlayer player = Minecraft.getMinecraft().player; if(!player.capabilities.isCreativeMode) { player.openGui(Main.instance, GuiHandler.INV_GUI, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); } } } GuiHandler public class GuiHandler implements IGuiHandler { public static final int TEST_GUI = 0; public static final int INV_GUI = 1; @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch (id) { case TEST_GUI: return new TestGUI(); case INV_GUI: return new InvGUI(); } return null; } } InvGUI @SideOnly(Side.CLIENT) public class InvGUI extends Gui { public InvGUI() { super(); } @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent.Pre event) { } @SubscribeEvent public void onRenderOverlayText(RenderGameOverlayEvent.Text event) { ScaledResolution sr = event.getResolution(); EntityPlayer player = Minecraft.getMinecraft().player; if (!player.capabilities.isCreativeMode) { String health = (int) player.getHealth() + " / " + (int) player.getMaxHealth(); GL11.glPushMatrix(); GL11.glScalef(1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().fontRenderer.drawStringWithShadow( health, 0, 0, 0xFFFFFF); GL11.glPopMatrix(); } } } GUI works if displayed on button press or when player joins game. So there is nothing wrong.