Jump to content

Draco18s

Members
  • Posts

    16559
  • Joined

  • Last visited

  • Days Won

    156

Posts posted by Draco18s

  1. Just to clarify, if this code is running on the client in the client thread, that's fine.
    If this code were to run on a dedicated server, the server will crash (my prior post I thought I saw something about getting the client info from the server).
    If this code were to run in the integrated server, you would be reaching across sides and the game might crash randomly and unexpectedly.

  2. 35 minutes ago, LexManos said:

    Because configs can have a lot of config value types that dont exist in vanilla.

    Case in point, my work project. Which is Unity/C#, but the idea is the same.

    The Unity inspector is pretty good at finding public/serializable values and showing them in a list in the Inspector gui, but it's layout or labels aren't always the best, and there's only so much you can do with annotations (of which there are several). So for more flexibility, Unity offers both a CustomInspector feature and a CustomPropertyDrawer feature (the former is for Unity-objects that appear in the inspector, the latter for miscellaneous objects that are contained within the former).

    However even this is limited to only the things Unity knows how to serialize. Generics? Lists of Interface objects? Abstracts? Not supported.

    But my project needed support for generic objects because of how our interaction system (ECS components encapsulating simple finite state objects) and our grading system (did the user perform the following steps in the prescribed order?) had to integrate with each other.

    I had a hard requirement to be able to display any object Foo in the inspector, regardless of what Foo's type was. So I had to dig into Unity's inspector code and extract out how it handled all of the types it did handle and rewrite it to accept arbitrary values, that if it didn't match the available types, would use reflection to find all of the object's public/serializable fields and then try to draw all of those, recursing down again and again until a primative type was able to be drawn.

    And even with caching to avoid duplicate reflection lookups, it still isn't fast. There's a soft limit of about 20-50 of these inspector drawers that Unity can draw at one time before the lag becomes disruptive. And when you're dealing with complex custom types, the layout isn't pretty. Thus I had to go reimplement Unity's custom editor and custom property drawer system as well.

    Which is to say...if it's more than a handful of very simple objects (ints, strings, booleans...) you're going to have to do the work yourself.

    • Thanks 1
  3. 7 minutes ago, 1Mangomaster1 said:

    Wdym validate it? You mean checking if the types match? I do

    Verify that it is a valid location for the player to access. Think about a hacked client that sends whatever location data it wants.

    Remember, the first rule of net code is:
    The client is a lying, cheating, bastard.

    The only thing you should send to the server is what user input was given.

    • user clicked this button
    • user entered this text
    • user pressed this key

    The server already knows what container the user is interacting with, where the user is, what tile entity they've accessed, and its location. You don't need to send that info. All the server does is go "ok, they clicked a button, let me compute the result of that action."

    The client can mimic that result, in order to hide the latency, but the server's return update packet will override anything the client did.

  4. https://github.com/Crescentine/Trajans-Tanks-1.18/blob/main/src/main/java/com/crescentine/trajanstanks/block/steelmanufacturer/SteelManufacturerBlockEntity.java#L180
    ItemStack merging would be better (inventory.Insert(...)). What if there's a stack in the output that doesn't match the output of the current recipe?

    Also, having separate item stack handlers for input(s) and output(s) would simplify things massively. Rather than having to remember that the output slot is slot 10 everywhere you can just say "output."

    Old 1.14 (MCP names) code, but same idea

    https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/entity/PackagerTileEntity.java#L191

     

    {edit, scratch that, one mo'...}
    Nope don't see what the issue is. The entity calls resetProgress from craftItem and that should prevent it from ending up back in that method next tick. You might have to use the debugger to figure it out.

  5. 5 hours ago, harryhrb123 said:

    so im just trying to find a mod a SPECIFIC one i have a pic of it here  file:///C:/Users/admin/OneDrive/Pictures/Screenshots/2022-04-19.png but idk what it is

    That address is a file location on your computer, my computer does not have an admin folder (this is like telling someone over the phone that you put something in the upper right drawer of your desk, they should check the upper right drawer of their desk for it).

    The OneDrive link does work, because that's an internet address.

    Still not enough information to identify what you're even asking about, you just have a picture of some minecraft hud elements, but haven't specified which one you're interested in, and most of them look vanilla to me.

×
×
  • Create New...

Important Information

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