Jump to content

hugo_the_dwarf

Members
  • Posts

    334
  • Joined

  • Last visited

Everything posted by hugo_the_dwarf

  1. Sounds to me you need to have your tileEntity "look" for the cable block creating a list as it goes. IE public void lookForPowerSource() { in here it will start around itself xCoord - 1 and xCoord + 1, same with zCoord If it finds a cable, save it in a list and look around that cable for other cables, and if it finds one make sure it checks that new cable against the list to make sure it hasn't found it before so you don't have a unlimited loop (like if you had 4 cables in a square and one is attached to the machine) keep going until a cable is connected to a source of power. you should now have a list, of hopefully all connected power sources. Now you can make the lists better (smaller) so getting power is less time consuming by doing some sort of weighted equation for each power source. Kindof how network routing works, it creates a map of the fastest route to the source (by less amount of hops) } then you toss some catches in to make sure that the stored source in the list is still there "someone removed it" and if all the stored lists are missing try looking for more sources again. There are so many ways to do this, some better some just the worst and everything in between.
  2. Well I guess that is a problem, that could cause server lag if it does that? I do have it on a timer to load the chunk every 3 seconds (60 ticks) and I guess that explains why the tileEntity can still do its functions since it loads the chunk then does its methods. Where can I look at the ForgeChunkManager? Which package? I am having no luck finding out how ChickenBones does it, or at least don't understand it well enough. If I can't figure out how the ForgeChunkManager does it then I'll leave it be.
  3. Well Looking in there didn't enlighten me, not saying I don't appreciate your suggestion it got me on the right track, and that is that chunk coords are not the same as entity/block coords (Which I suspect is why my original attempt crashed the game) so I decided to try my own way of doing it, and it works thus far. Posting code so others that search for this can see how I did it, and go from there in their adventure. Chunk ch = getWorldObj().getChunkFromBlockCoords(xCoord, yCoord); getWorldObj().getChunkProvider().loadChunk(ch.xPosition, ch.zPosition); Is this the best way? Probably not, but it works.
  4. BaseNodeRequest oops I just copied one of my packets, that would be your WaterTempRequestPacket you can have a look at how the baseNode packet is made here https://github.com/Hugo-the-Dwarf/Rise-of-Tristram/tree/master/src/main/java/ee/rot/comms You can look at how I register them in my main mod file. EDIT: also you can call them whatever you want, I just use Request for Client to Server messages and Response for Server to Client messages. It's just what I name them as you could name your packets "WaterTempServer, and WaterTempClient" if you wanted to.
  5. main.NetworkHandler.sendToServer(new WaterSteamRequestPacket(tileEntityX,tileEntityY,tileEntityZ,waterAmount,tempAmount)); WaterSteamRequestHandlerPacket implements IMessageHandler<BaseNodeRequestPacket, IMessage> { @Override public IMessage onMessage(BaseNodeRequestPacket message, MessageContext ctx) { TileEntitySteamPump te = (TileEntitySteamPump)ctx.getServerHandler().playerEntity.getEntityWorld().getTileEntity(message.x, message.y, message.z); te.setWaterLevel(message.waterLevel); te.setTemp(message.Temp); return new WaterSteamResponsePacket(tileEntityX,tileEntityY,tileEntityZ,waterAmount,tempAmount); } } the return sends another packet which is registered clientside to do the same thing. I'm assuming your GUI takes the tileEntity so you should be able to use the GUI to display te.getWaterLevel(). This is using the ISimpleMessageWrapper tutorial.
  6. I'm making a Mod where a player can place a "Base Node" block that will let them create a base layout, and have the block build them their creation for them, as long as they have chests filled with the building materials. I have plans for "add-on" blocks that will allow it to perform extra functions with a cost of mana stored inside vessels, mainly crystals. One of these add-on blocks will let it load a 3x3 chunk area, at the cost of mana per update. This will allow for other blocks with different functions to run at the base even when the player is away from home. I searched for a bit and found someone mentioning using the worlds chunk provider and loading the chunk (duh) but when I tried that, the game will crash on world load. Thanks, Hugo.
  7. well you can use "player.getEntityWorld().rand" the world the player is in has its own Random();
  8. player.interactWith(par1Entity);?
  9. Not how it really works around here, would be nice, but if that was the case not many would learn. You can post the class in [code] {/code] Seems like you have a rough idea on how to do this, just some error troubles.
  10. A summary: Create a TickHandler (which in this case would be a custom event for OnLivingEvent) Create an IExtendedProperties Class and register it/add it to a player on constructing (these two tutorials should help you get an understanding of this Events and IExtendedProperties) Use the TickHandler to add up a counter inside the ExtendedProperties, use NBT to save the information between saves and loads. Once the counter reaches your desired value, give item, reset counter. Hopefully this helps get across what everyone was saying, also reread their posts as many times as you need, the answer will come.
  11. Well with some searching I think a few others have asked this question and no response to each one, guess this is impossible or no one knows how? How do I make a suggestion for the forge guys to add something like this in? And if it is How do I go about this path of armor with overlays.
  12. Ok so I figured I'd ask this here since it is directly related to this topic, at least using the request and response. Alright So I made the request packet (works, sets the players class) and the response (works as well, updates the players HUD and client effects) However when I save and load, the player sees that their class is back to no class, and their stamina and mana are at the defaults, however their chosen class effects still work. As the server knows what the class is, but the client doesn't. Now I'm using two data watchers for mana and stamina (current) but not for my class. Should I have the server constantly send class packets to the player? Or is there a way to just do a one time check so I'm not spamming packets back and forth needlessly EDIT: ok so I looked at some events, and I decided to with EntityJoinWorldEvent, and the PlayerEvent.Clone event to send a "whatAmI" request and it's working as I want it to, but is there a better way? or did I just figure out the correct way?
  13. My guess is that it's your GUIs constructor public GuiMagicBase(TileEntityMagicBase tileEntity, EntityPlayer player) { super(new ContainerNull()); now ContainerNull() is my own container that I use for a placeholder because Idk how to null that field correctly so made my own empty container to use for GUIs that don't need an inventory.
  14. Wish I could double thank that post. Problem solved thank you very much. Had no idea about playerCapabilities
  15. Ok so doing so makes it do it once, however the speed boost doesn't stay. How can I make it set the players movespeed and be done with it untill the next stat change? Nvm was setting the speed in the wrong place, aka client side. EDIT 2: ok so to have the speed effect applied one has to leave and reload the world, and changing the stat resets it back to default walk speed.. if (props.getAgility() != (agiMod - props.getClassModifers()[1])) { props.setAgility(agiMod); player.getEntityAttribute(SharedMonsterAttributes.movementSpeed) .setBaseValue(MathHelper.clamp_double(SharedMonsterAttributes.movementSpeed.getDefaultValue() + props.getAgility() / 125, 0.45d, 0.7d)); System.out.println(player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); } Do I have to use a command to refresh the player?
  16. that makes a bit more sense, can probably put something to check "is the collected modifiers == current modifiers, else set modifiers" or something with that logic
  17. Ah so I'd make a ClassRequestPacket(registered server), which is what code I posted. And a ClassResponsePacket(registered client) which will be the return of ClassRequestPacketHandler? like: return new ClassResponsePacket(message,className); or would it be: Rot.net.sendTo(new ClassResponcePacket("Good",className), ctx.getServerHandler().playerEntity); return null;
  18. Hey so I want to make a GUI for players to change their class, so I need to send a packet to the server to make the change (easy I understand this) However when the change is done, I'm guessing the player won't get the update (but will still have the effects of the class, just won't know it because the server instance of them was changed) Now I notice that the "onMessage" method returns an IMessage and I'm used to just saying Null which I assume is no response. However I want to respond so the client can be updated the same as the server (can see current class, and or get a message of not enough credits to make the change, etc etc) From the tutorials in the sub Board they explain how to make and setup the packets, send them, and receive them but saddly I have no idea how to send a response back to a player/client or better yet to a client/player in general. the process I'm trying to do is "Player -> GUI -> Packet to Server -> Changes are done Message and status changed -> player updated on message, change, and status(this includes updating the GUI)" Here is my "send To Server" packet that I made: public class ClassPacket implements IMessage { public String className; public ClassPacket() { } public ClassPacket(String className) { this.className = className; } @Override public void fromBytes(ByteBuf buf) { className = ByteBufUtils.readUTF8String(buf); // this class is very useful in general for writing more complex objects } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, className); } public static class ClassPackettHandler implements IMessageHandler<ClassPacket, IMessage> { @Override public IMessage onMessage(ClassPacket message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; if (ExtendPlayerRot.get(player).getCurrentClassName() == ExtendPlayerRot.classNames[0]) { ExtendPlayerRot.get(player).setCurrentClass(message.className); } else { if (RotItems.checkForItemAndAmount(new ItemStack(Items.gold_ingot), 3, player.inventory)) { for (int i = 0; i < 3; i++) { player.inventory.consumeInventoryItem(Items.gold_ingot); } ExtendPlayerRot.get(player).setCurrentClass(message.className); } else if (RotItems.checkForItemAndAmount(new ItemStack(Items.gold_nugget), 27, player.inventory)) { for (int i = 0; i < 27; i++) { player.inventory.consumeInventoryItem(Items.gold_nugget); } ExtendPlayerRot.get(player).setCurrentClass(message.className); } } return null; } } } Explanation and guidance in this matter is very appreciated, thanks in advance.
  19. @Override protected void actionPerformed(GuiButton button) { I then check to see if the button ID is my send list button, if so. Send a packet to the server Rot.net.sendToServer(new BaseBuilderPacket("0;"+te.xCoord+","+te.yCoord+","+te.zCoord+";"+list[listIndex++])); now of course you don't need all of what I sent and how I did it, you can use ints for the tile entity coords I kinda derped when making the packet (used to web based stuff and turning everything into a string and decomplining it at the other end.) but the idea of GUI to server to tileEntity is there
  20. need to use packets to set it for you, you can look at how I do it https://github.com/Hugo-the-Dwarf/Rise-of-Tristram/blob/master/src/main/java/ee/rot/gui/GuiMagicBase.java
  21. Hey so im adding stats that players can have based on items they are wearing and a class that they choose, and one stat is Agility and I want it to increase movement speed. Now looking at the villager mob I see they have a line called: getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5d); which I think makes them slower, as tests with the player show higher numbers mean moving faster, however putting this into my "setAgility" method just makes the screen seizure as the base value is being set every tick, and my attempts to counter act this fail. So how do I passively increase a players movement speed based on their agility stat, and do so properly? here is my current code snippet in my extended player class: public void setAgility(int value) { this.agility = MathHelper.clamp_int(value + currentClass.getAgi(), -20, 20); if (player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue() != 2) { player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(2); System.out.println("set speed"); } //System.out.println(player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); } Now this method is called in the LivingUpdateEvent event so I'm hoping that this effects server and client side, as effects of my other events work when I alter this. Am I just changing the player stat in the wrong place? PS the move speed does work even if the screen is warping in and out I did a test MP and the players zoom around (of course once I fix this the insane test numbers will be handled in a mathHelper.clamp)
  22. since it's client only, can't he just have some sort of "old hp" variable that updates all the time, and when the update happens just do a check of "is new hp != old hp ? setHealthWithMessage(hp,"Health Changed") : setHealth(hp);" or would a simple alteration of one variable clog up the client's processing?
  23. Whats not working? stack.stackTagCompound.setInteger("y", event.x); stack.stackTagCompound.setInteger("z", event.x); is it your coords? because your copy pasta shows, considering the x, y, and z nbt keys are all event.x I'd also use the NBT key tags with something like " myMod.Id+'customCoordX' "
  24. I would use the normal item damage for the damage and the state of on and off with NBT
  25. LivingHurtEvent you can change the amount of damage in the event. just need to add your logic like "is the event.entity a player and is holding a bone, -1 to damage (reduction)"
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.