Brian-Wuest / MC-Prefab

A minecraft mod designed to provide ways of creating Pre-Fabricated(designed) buildings.
Other
26 stars 20 forks source link

[Enhancement]: Allowing for custom structures #257

Closed Brian-Wuest closed 2 years ago

Brian-Wuest commented 2 years ago

Minecraft Version

1.18.1

Forge Version

latest

Mod Version

latest

Details

This is probably our most requested feature that we haven't done yet. This is still not guaranteed but we want to make an honest effort towards fulfilling this request.

Below are some notes we have about various blocks, items, and functionality we would need to create.

    Need to keep structures on server, send client information only important for client.
    Need a common location to store scans made by players.
    Need block to make the blueprints (drafter)

    Custom structures are designed and maintained by mod-pack developer. Not Prefab Team.
    Custom structures must be on both the Client AND Server side. This makes sure that the "Preview" functionality works properly on the client-side. However, the actual building of a structure will occur on Server side.
    If there is a structure which doesn't exist Client side but DOES Server side; we will still allow the item to be generated; however, the preview button will not work

    Sent Client Data:
        1. Name of structure.
            a. Can be non-translated value, but we will try to translate it.
        2. Items (Block Items) needed and count for each item
        3. Sent on player join just like mod configuration data
    Stored Server Data:
        custom_structures.json
            1. Name of Structure
            2. Items (Block Items) needed and count for each item
            3. Single file
        structure_name.structure.zip
            1. This is the scanned structure

    Custom Structure Location:
        Create folder under mods folder for custom structures during mod load. Name it "Prefab"
            Same way that "From The Depths" works.

    Structure Scanner Block:
        Update buttons to have proper images for directions. Cannot use text because it looks bad.
        Update logic to write to custom_structures.json file when scanning area in production mode. 
            Keep current processing for development mode.
        Zip file location should also go to new Prefab folder when in Production mode.
            Keep current processing for development mode.

    Drafter Block
        Make it look good (Custom Model)
        Know about surrounding container blocks for structure resources.
            Doesn't hold resources itself
            Think the old drafter in 1.12 could do this.
        GUI
            Should show list of every available structure with its name.
            When clicked an area on the right will show the blocks/items needed and their count.
                Note: Think the old drafter in 1.12 could do this.
            Has slot to take out blueprint when all items are available

        **Notes**: May move current structures to this model in the future.

    Custom Blueprint Item
        Should have new texture but same texture used for all custom blueprints
        GUI will be very generic.
            Only show structure name + 3 buttons.
                Build!
                Preview
                Cancel
Brian-Wuest commented 2 years ago

Due to the complexities involved with allowing custom prefabs, especially when it comes to custom blocks. This is simply not feasible with the development team we have right now.

There was great progress made on this subject for this project but the realization that we could not properly support this effort means that we cannot continue it.

Brian-Wuest commented 1 year ago

Note: Most of the progress for this is stored in the following branch on the Fabric repository: 1-18-1-custom-structures

Brian-Wuest commented 1 year ago

Notes on what was completed for posterity (and so it's not just on my machine).

Custom Structure Work Done
    1. Created class to hold custom structure information.
    2. Created class to hold custom recipe information.
        a. All recipes are shapeless; they just need the items.
    3. Created messages and registrations to transfer structure information from server to client.
    4. Added validation between client and server interations.
    5. Added item recipe validation to ensure that items exist when a server starts.
    6. Added logic to send packet to player when they join a server to send all server-side custom structures.
        a. Note: Actual structure design data is not sent as those would be too big. It is expected that the client-side has them.
            i. This information is verified on client-side.
            ii. If data cannot be verified the structure is not available.
    7. Added blueprint item, model and recipe
    8. Added drafting table block, item block, models, and recipe
    9. Added pencil item, model, and recipe
    10. Created logic to create custom structure folders if they don't exist during loading.
    11. Created logic to load custom structure data during loading.
    12. Create Block Entity for Drafting Table block
    13. Create GUI for Drafting Table Block
        a. Will only look at player's inventory for items/blocks.
        b. Don't bother looking at other inventories when in creative mode.
    1. Update Preview and Build Structure functionality to handle custom structures.
    2. Update Structure Scanner saving to save to custom folder location when not in development.
        a. Development will still place structure in current location.
    3. Update Structure Scanner so it will be registered outside of development environments.

Custom Structure Work To Do:

    1. Update Structure Scanner GUI so it can look the same between Fabric and Forge
        a. Update Structure Scanner GUI to support Narrator and make it look better in general
    4. Update Structure Scanner model so it doesn't look like crap
    5. Fix bugs and add stuff not thought of
    6. TEST!!!!!!!!!!!
    7. Remove need for client to have matching files. Add shape and size of the structure to saved custom structure info class.
        a. Do not put these dimensions into the file as people could mis-represent the shape and size of the building.