Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content Count

  • Joined

  • Last visited

Everything posted by LK1905

  1. What exactly do I put in the Button.ITooltip parameter? How do I "give it an Implementation"? I can't find any examples of it actually being used, neither in Vanilla or in other mods.
  2. If I don't have that there, the buttons don't update. Besides, thats not the issue I was asking, the issue is that only the last button hovered over does whats in that statement.
  3. Sorry for the late response, but I found how to make the buttons update. All I had to do was to clear existing buttons and re-run the init, whenever the buttons are hovered over, like this: if(styleButton[i].isHovered()) { this.renderTooltip(stack, new StringTextComponent(styleCap.getStyleDescription(i)), mouseX, mouseY); buttons.clear(); this.init(); } However I still have a problem with that statement, in that it still only works on the last non-null button, and not on any of the previous buttons. Anyone know why the statement would do so? Full class here.
  4. For the "listen to the change" part, there's a mouseClicked method in the Widget class (which the Button class extends from) that I think would do the job, but I'm not sure what the int button parameter does, do you know?
  5. I ended up finding a solution elsewhere for my buttons to display the updated texture on the correct button: package lk1905.gielinorcraft.client.gui.widget; import lk1905.gielinorcraft.Gielinorcraft; import lk1905.gielinorcraft.capability.attackstyle.AttackStyleCapability; import lk1905.gielinorcraft.capability.attackstyle.IAttackStyle; import lk1905.gielinorcraft.network.PacketHandler; import lk1905.gielinorcraft.network.attackstyle.AttackStyleClientPacket; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.ImageButton; import net.minecraft.entity.player
  6. Okay, I removed the static from the player and styleCap variables, are you able to help me with the other problems I mentioned?
  7. The screen has 3 buttons, all with a "style id", which, when pressed, sends a packet to set an "active attack style", which is decided by the style id of the button pressed. The buttons are all grey, except for the button with the active style id, which is supposed to turn red, and also make the previously active button grey. The button colours do update, but only if i close/reopen the screen. I would like it to be able to update the colours while the screen is still open. Screen class package lk1905.gielinorcraft.client.gui.screen; import com.mojang.blaze3d.matrix.MatrixStack;
  8. Hi, I have 2 questions: 1. How do i get a gui screen to update instantly? My screens only update when I open/close them, or change the size of the Minecraft window. My in game gui updates instantly, which is what I want my screens to do aswell. 2. I have buttons on this gui that I want to, when hovered over, to display a string/tooltip. There is an ITooltip parameter in the constructor of the Button class, but I'm not sure what to put in there if I just want to display a string. How would I do that? Thanks.
  9. I solved the problem. The problem as that I didn't have the getMaxHealth() method saved within my serializeNBT() method, so the game still thought the value was zero. Saving that value fixed the problem.
  10. I'm trying to modify an entity's max health based on a stat, but either its not working or my client isn't acknowledging the change. The method for the change. Full class here. @Override public void modifyMaxHealth(LivingEntity entity) { if(entity == null) { return; } entity = getEntity(); final float newAmount = getMaxHealth(); final float oldAmount; final UUID MODIFIER_ID = UUID.fromString("d5d0d878-b3c2-469b-ba89-ac01c0635a9c"); final ModifiableAttributeInstance health = entity.getAttribute(Attributes.MAX_HEALTH); final AttributeModifier mod = new Att
  11. I've changed the serializeNBT and deserialize methods so the value of i is in the key: @Override public CompoundNBT serializeNBT() { CompoundNBT data = new CompoundNBT(); for(int i = 0; i < 26; i++) { data.putInt("xp_" + i, (int) xp[i]); data.putInt("dynamic_" + i, dynamicLevels[i]); data.putInt("static_" + i, staticLevels[i]); } return data; } @Override public void deserializeNBT(CompoundNBT data) { for(int i = 0; i < 26; i++) { xp[i] = data.getInt("xp_" + i); dynamicLevels[i] = data.getInt("dynamic_" + i); staticLevels[i] = data.getInt("stat
  12. Okay, I believe I've done what you have told me, and my gui does update me gaining xp. However, theres something wrong with my sync method, as whenever it is called, it resets all xp values to zero. So the values in my gui are lost when reloading the world. Heres the sync method in my Skills class: @Override public void sync(ServerPlayerEntity player) { if(entity instanceof ServerPlayerEntity) { PacketHandler.sendTo(new SkillsPacket(serializeNBT()), player); } } Heres my attempt at syncing on login, in my player event handler: @SubscribeEven
  13. Did you mean replace EntityLiving in the Object instanceof part with PlayerEntity? Because I just tried that and it made no difference.
  14. Sorry for the late response. Another stupid question, but how do I set the the entity so that it's not null?
  15. Is that this part? public static void register() { CapabilityManager.INSTANCE.register(ISkills.class, new SkillStorage(), () -> new Skills(null)); } If so, isn't that part supposed to be null? Every other capability I've seen from other people that had an entity/player there had it set to null.
  16. But as far as I know, my packet and event handler are already supposed to sync it. Which is why I made this thread, to ask why they aren't.
  17. My GUI doesn't update the xp values. This is how I reference the player in my GUI: private PlayerEntity player = Minecraft.getInstance().player; private LazyOptional<ISkills> cap = player.getCapability(SkillCapability.SKILL_CAP); private ISkills skills = cap.orElse(null); Do I need to reference the Server Player instead? If so, how? Or Is the client player already supposed to know my server player data from my events/packets? If so, why aren't they working? They're in the OP.
  18. I changed that part to this: PlayerEntity player = (PlayerEntity) event.getSource().getTrueSource(); LazyOptional<ISkills> cap = player.getCapability(SkillCapability.SKILL_CAP); ISkills skills = cap.orElse(null); But now I can't gain xp at all. Is that the correct way of doing it?
  19. I added it into the AddXP method like this: if(entity instanceof PlayerEntity) { sync((ServerPlayerEntity) entity); } That didn't make any difference. Is that what you meant?
  20. This is probably a stupid question, but how would I do that? I tried adding it to SkillStorage the same way I have the getXP, getLevel and getStaticLevel methods, but that made no difference. Is that what you meant, or something different?
  21. I don't think there's anything wrong with the SkillStorage, as I can gain xp just fine, in the correct skills, the data is just reset to zero when i close and reopen the world. I also have the "Hitpoints" skill set to level 10 and 1154 xp by default. If I comment out my PlayerLoggedInEvent, the skill is correctly set to those values in game, and is reset to those values when I leave the world. But with the event enabled, both the level and xp values are set to 1 and 0.
  22. Hi, I'm having problems syncing my mod's capability data. There's no errors/crashes or anything, but my code doesn't appear to be doing anything, as reloading the world resets all data values to zero. so I was wondering if someone could look at my code to see if I'm doing anything wrong, or am missing anything. My event handler: package lk1905.gielinorcraft; import lk1905.gielinorcraft.api.skill.ISkills; import lk1905.gielinorcraft.capability.skill.SkillCapability; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraftforge.common.util.LazyOptional; import
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.