-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
[1.7.10] Best way to handle health changes (customHP)
Ernio replied to Ernio's topic in Modder Support
Aww... it's probably me being stupid, sry. So normally player HP is defined by: public final float getMaxHealth() { return (float)this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue(); } And from what I know "maxHealth" is a const. I don't want it to be const. I want maxHP to be value dependent on my player stats. And "I want" means "I want it to be x on this tick, but on next tick it will be y" So since I alredy have huge player handler I though why not making customHealth just some next value like mana, but just track hurt event to instead hurt normal HP, make it hurt customHP and if it's == 0 set player dead. -
[1.7.10] Best way to handle health changes (customHP)
Ernio replied to Ernio's topic in Modder Support
Let's just put it this way: How the hell can I set players max HP based on my "I want", but in a way that it won't be a const value. (MaxHP = Str*5 + premiumHP + something + whatever) -
Currently everything I have is handled by PlayerExtended which is wrapped EntityPlayer and contains player stats, levelHistory, quests, everything. Most is synced by packets on-request (e.g if you want to see stats you send request to server when opening GUI, but in combat, client itself never have values like dodge %, it's all on server). Only stuff send onTick are basic values (used by ClientGuis, like mana). Now I've been thinking - why not adding health value to this (like mana) and just intercept HURT event like: PSEUDO LivingHurtEvent event; if (player) PlayerExtended.wrap(player).hurtPlayer(event.amount, event.source) And rest of it handle on my own (ofc. when CustomHealth <= 0 player.setDead) Question is: How un-/safe is this? Is there ANY way that player can get damage without calling this event? What about knockback? What would be a better way - I guess SharedMonsterAttributes, but I have no idea how they are synced, how saved and how to edit/add them?
-
[1.7.10] Tooltip text with "hold" shift like TiC tooltip
Ernio replied to zedblade's topic in Modder Support
https://github.com/squeek502/TiC-Tooltips/releases/tag/v1.1.11b Bottom right - src code. THe answer is still basically same as from guy above. -
1. ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); 2. You will have to use reflection to set this field to public or access it other way. 3. Now there are not only usernames but UUIDs and InGame Nick. If you are doing something regardig visuals (displaying player name, etc.) player.getDisplayName(); Otherwise you should use UUID (gettin and setting NBT, operating on actually any internal data). player.getUniqueID();
-
I am finishing API and core of my mod, now it would be good to make nice GUI. Heard that in 1.8 there are A LOT of changes in renderers. Is it even worth coding (mostly GuiScreen) before updating to 1.8 (I prefere to wait for more deobf version). If not, what other parts I shouldn't get my hands onto?
-
Your approach to this is kinda bad and not very well planned. Inside packets (in this case) you shouldn't check anything, no IFs, nothing like that. Packets are used for one purpose - synchronize client with server. By that I mean - you just send one tiny bit of info that will be later used by any side said above and maybe "answered". Let's rethink this: 1. Everything should happen server-side. 2. You have your ExtendedPlayerWater, from what I read in code - this is your ExtendedPlayer class that is holding some value ("watersealing"). 3. You want it, so the player has 200 ticks of "extra" "something", BUT ONLY IF he's holding a key down, ay? (detail - 20 ticks = 1 sec, you wrote "200" and then "5 Seconds left"). How would I approach this: 1. In your ExtendedPlayerWater create one BOOLEAN value "isUsing". 2. Look at KeyBinding.class - you can call for action on both press and "unpress". 3. Create KeyBinding that will call for packet "ChangeUseState" on either press or unpress (doesn't matter, if it's 0 then it will change to 1, otherwise from 1 to 0). 4. Now create a "ChangeUseState" packet that will send send notification from client to server when the binding from 3. is pressed. In this case you don't even need input, only thing required is ofc. sender (player). 5. On server-receiver you get sender of this packed get his "isUsing" and if(isUsing==0) isUsing = 1 else(otherwise). 6. WHOLE rest of this mess will be handled by server itself, so: In your "LivingUpdateEvent event": - I would use PlayerTickEvent instead. - You make all the checks like you did before but instead of checking the binding, just look into your ExtendedPlayerWater.isUsing. Regarding pressing and "unpressing": You can send packed on press, on stop pressing, on re-press (double-press), anything you want rly. Regarding packets: His tutorial is probably best you can find. Until you understand how it works I am not planning on providing done code. Give me something to work with.
-
[1.7.10] Entities "unload", entityID and "uniqueness", lifespan and all?
Ernio replied to Ernio's topic in Modder Support
@diesieben07 Always can count on you. Thanks pal. @JavaMatrix And yup, I'll use that. No need to use my own mob-effect mapping. I don't think there is anything more here, so let's say it's resolved. -
For a while now I've been making some huge changes when it comes to combat in MC. It's time to apply those onto mobs (till now they are all running on Players only). While with players it's pretty simple: player loads, gets effects (like buffs or e.g burn effect) and in case of logout it can all be saved to HDD (I'm using json - better than NBT, because u can edit it like txt), I can't get around working on implementation of whole system for normal entities. What I need are answers. Situation: World is created, spawn "manager" spawns entities (mobs), now: * Let's have zombie - after player loads some chunk, then leaves it and chunk is unloaded - what happens to the zombie? I belive it is saved somehow (in world ofc.) BUT: - The "unique" entityID is for loaded entities only (am i right here?), that means there is no injective situation (one-to-one), so how can I track this zombie being loaded again? (you give this zombie effect, shut down MC, start it back and I want to know which zombie it was). * Is it just my delusion or once the mob is spawned it is sometimes not saved? (or never?) - I never ever wondered about this until now, but - when mob is spawned, and you leave that "loaded" area and later come back - it isn't there. When the mob is saved and when not? Maybe never? * Following question before, assuming that they are not always saved - if something like that happens (mob spawns, I go back far away, and then come back to location where that mob was) what is the maximum range when the entity is not unloaded? Let's say you back 100 away and come back - it is, but if you go 500 and go back it won't be there. * How is night affecting night mobs - are they all just destroyed? What about data saved for them? It all must be somehow being processed, what are key points in entities lifespan (creation, life, death, saving to HDD, nbt)? Where to find those? Hope I can get as much as possible from you guys, any help regarding entity handling is appreciated, links and stuff. Thanks.
-
"I want it to send a packet when I press a button and the packet opens a gui" Packets are NOT used to open GUIs. All client-rendering stuff is being done on Client-side, you don't need ANY packets unless you are: - using containers (you have to retrieve container-slot itemstacks) - synchronizing data (some RPG player stats for example) - doing anything that requires you to contact with other clients / server. "I cant open a gui from with the actionPerformed() method because it doesn't have the right perameters" In actionPerformed you can literally do ANYTHING. to open GUI client-side use (as saind before) Minecraft.getMinecraft().displayGuiScreen(new YourGUI()); Please tell us what EXACLY you want to do, because to this point I don't see anything that requires you to use packets.
-
And what exacly you want to do? Send packet on GUI open? With button? On closed? on tick? Packet to who? All players or just server? You have to be more specific.
-
Well, if we are talking about e.g. Health Bars above player/mob, then yes. Example (partial) code: @SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { Minecraft mc = Minecraft.getMinecraft(); EntityLivingBase cameraEntity = mc.renderViewEntity; Frustrum frustrum = new Frustrum(); double viewX = cameraEntity.lastTickPosX + (cameraEntity.posX - cameraEntity.lastTickPosX) * event.partialTicks; double viewY = cameraEntity.lastTickPosY + (cameraEntity.posY - cameraEntity.lastTickPosY) * event.partialTicks; double viewZ = cameraEntity.lastTickPosZ + (cameraEntity.posZ - cameraEntity.lastTickPosZ) * event.partialTicks; frustrum.setPosition(viewX, viewY, viewZ); //Here my code that gets entities in world and draws health bar over them. //It's important for you to check some stuff, if you won't the game will crash/gui will be buggy. //entity.isInRangeToRender3d //frustrum.isBoundingBoxInFrustum //entity.isEntityAlive() //Rest of code is just a normal OpenGL, drawing figures/images like in GUIScreen (almost). Note: I have no idea if this is your "special" way, it seems simple so i guess it's good.
-
I recommend debugging. 1. Add System.out.println() in beggining of each method that is in any way associated with your addMessage. 2. Are we talking about ingame, the line of chat is appearing twice or maybe in log (terminal). 3. Make sure you are using Side properly. 4. Post more code for more help ;p
-
Dude, do whatever you want, just know consequences: If you create an ItemStack with Tag containing current player name: 1. After updating: - Ingame nicks WILL be changeable, if you assign ingame name to item and someone changes it (nick), the item will be corrupted (in a way) - e.g if you make "Soulbound" items the owner will no longer be applicable. - Converting ("I will update the code") ItemStacks with ingame nick in Tag will not be just easily updateable - you will have to make converter that would remove old tags and assign new ones. If only this would be this easy - it's not. Not all ItemStacks are loaded from HDD when you load your world. All this will lead to total break between versions (not compatible worlds -> all old items dissappearing or something and ofc. a lot of corrupted data). Use the way I wrote in post before and then just read those least and most significant bits convert them to player (getPlayerByUUID or something similar) and get his ingame name.
-
"And how do I get the UUID" "I got it, I should have just done .getDisplayName()" Big nope. .getDisplayName() is the name ingame, it's not UUID. To save UUID in NBT use this: itemStack.stackTagCompound.setLong("muuid", player.getUniqueID().getMostSignificantBits()); itemStack.stackTagCompound.setLong("luuid", player.getUniqueID().getLeastSignificantBits());
-
Is this how it looks like? If yes and you still have bad buildpath error, then you have some other more inside problem. Problems like that are hard to resolve via posts on forum, on Skype maybe. You can always download new forge and install it from very beginning and then move your src. (I recommend this option in order to save time).
-
This is strictly buildpath problem, no eclipse command needed. WARNING - Before you do ANYTHING, make backup of your workspace/src file. Launch eclipse, right-click on project, go to properties. Click on Java Build Path (probably 4th on left), choose "Source" bookmark. "Build path duplicate entry." Is when you have 2 src folders in "Source" bookmark. Remove one (old one). In case you removed wrong one you will have to rebuild, or just retry with your backup.
-
[1.7.10] [SOLVED]Packet onMessage not firing
Ernio replied to freethought78's topic in Modder Support
Oh right! Gosh I was just doing stuff with those last week. PlayerEvent.PlayerLoggedInEvent Is a server-side event. It's NEVER launched on Client. Now let's take a look what packet are you sending: EpicScavengerQuest.network.sendToServer(new GetQuest(1)); As you probably know: When you join your SP world, a virtual server is created which acts similar to dedicated one. This server is handling packets, synchronization and stuff. So in this situation when you login on SP world, you are making your SERVER-side event, launch a packet that sends data to SERVER (.sendToServer()). Same goes for dedicated one. Proper way of doing this stuff is: If you want to send from server to players: .sendToAll() (or just to particulat player ofc). And in other direction .sendToServer(). Hope that will fix your problem. -
[1.7.10] [SOLVED]Packet onMessage not firing
Ernio replied to freethought78's topic in Modder Support
I took a glympse and, well - try this: Packet: public class GetQuest implements IMessage, IMessageHandler<GetQuest, IMessage> { private int value; public GetQuest() {} public GetQuest(int quest) {this.value = quest; System.out.println("BAM");} @Override public void toBytes(ByteBuf buffer) {buffer.writeInt(this.value); System.out.println("WRITE");} @Override public void fromBytes(ByteBuf buffer) {this.value = buffer.readInt(); System.out.println("READ");} @Override public IMessage onMessage(GetQuest message, MessageContext ctx) { System.out.println("PACKET"); SendQuest completed = null; ctx.getServerHandler().playerEntity.addChatMessage(new ChatComponentText("testing GetQuest")); System.out.println("testin"); /* try { completed = new SendQuest(ctx.getServerHandler().playerEntity.getDisplayName(), message.value); } catch (ClassNotFoundException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return completed; */ return null; } } In Main: //replace network.registerMessage(GetQuest.Handler.class, GetQuest.class, 0, Side.SERVER); //with network.registerMessage(GetQuest.class, GetQuest.class, 0, Side.SERVER); Also - check if you "network" is not null when you use "network.registerMessage()" (just a thought, you know "safe-side" stuff) -
Your method calling GUI has been removed. Care to refresh? Also have you registered GUI?
-
From ItemSword.class public boolean hitEntity(ItemStack p_77644_1_, EntityLivingBase p_77644_2_, EntityLivingBase p_77644_3_) { p_77644_1_.damageItem(1, p_77644_3_); return true; } You sword extended it and you havend added "damageItem(1, p_77644_3_)" at end of your override. The damageItem has to be called by hitEntity (or other if you want, e.g making a wand) to actually damage item.
-
How do I detect when a player no longer has an item?
Ernio replied to AmethystAir's topic in Modder Support
You just got me confused here: "mod that adds rings" + "removed from the player's inventory" (You know, there are no rings in normal inventory, so I thought you are asking for Baubles one). Believing the question is: How to know when item get's removed from player's inventory (4x9 one)? Toss and onDropped are called when you actually toss item, so moving item to chest won't call it. Answer: Well, without custom inventory, you can never know when item is removed, you can only know when it exist inside of Inv (Item.onUpdate()). Ofc. that is doable, but not simply. 1. You either hold 2 player inventories (that would also require new mapping, many check events, loading on startup, proably saving on unload) and compare using PlayerEvent.LivingUpdateEvent - invFromLastTick to invThisTick. 2. You extend player inventory and override normal one with yours where you ofc. only override choosen parts (to not break compatibility). So in the end - there is no system that would allow you to: onItemAppearedInInventory -> addEffectToPlayer -> onItemRemovedFromInventory -> removeEffectFromPlayer You can only track if it exist in this tick. And in this case using PlayerTickEvent is not wrong, but not best. you should use item.onUpdate(), it will save you one loop through eq. Edit: As to this "1" i proposed - better way would be to add ExtendedProperty to player and go from there. -
I read last two captions (not counting on with link) few times and maybe it's just me (it's late here) but I got totally confused with your damage and durability stuff. 1. Please check your mistakes and/or maybe retype 3rd caption - it's about 100 words in ONE sentence bro. 2. State your question (there is none) - I belive you want explanation? 3. You know if you are using KeyBinding and want server-side to know that your weapon is "active" you have to send packet right?