Skip to content

Datapacks Info (OLD)

1whohears edited this page Aug 3, 2024 · 1 revision

If anything is unclear please let me know in the discord so I can update this page!

Modify Presets with Datapacks

Basic Concepts

Vehicles, weapons, and radars use Minecraft's data system to load their stats. I'd recommend at least getting familiar with how modifying/creating custom recipes works with Datapacks in Vanilla Minecraft before going any further. Similar to how every recipe has a JSON file: every vehicle, weapon, and radar have their own JSON files that can be modified. I call these JSON files presets. I highly recommend looking at the presets that come with the mod! Additionally, you can create your own presets by creating new JSON files.

Here is a rough map of the folder structure your Datapack should be:
ExamplePackRoot
/data
  /dscombat
    /vehicle
      +alexis_plane.json (modify default preset)
    /radars
      +ar1k.json (modify default preset)
    /weapons
      +20mm.json  (modify default preset)
  /examplepackid
    /vehicle
      +alexis_plane_custom.json
    /radars
      +custom_radar.json
    /weapons
      +custom_weapon.json

Whether you are modifying or creating a custom preset I recommend copying and pasting an example preset from the mod into your Datapack and modify that data. This is too ensure all the needed data is in the preset. The preset may not work if values are missing.

The following will be specific details on how each preset type works. I may not explain every setting inside a preset as many of them are self explanatory. Please check a default preset of the same type to make sure you have everything.

Settings in the JSON files will be explained via this format: setting_name: Description

presetId: This is required in every preset. Every JSON file must have a unique presetId, otherwise things will break. I recommend making the JSON file name the same as the presetId.

Aircraft

Aircraft/Vehicle presets are applied to brand new vehicles. You can tell a vehicle item is new if it doesn't have the enchanted effect. New vehicles will copy the preset data associated with it's preset name. A vehicle will normally only do this once in its lifetime. Even if the world reloads. This means that even if a preset gets changed, all vehicles that spawned with the old version of the preset will NOT change.

aircraft_type: This integer shows what kind of entity the preset is meant to be used on. The actual entity type is determined by the item used to spawn the vehicle.
0 = Plane
1 = Helicopter
2 = Ground Vehicle
3 = Boat
4 = Submarine

item: The item the vehicle should give the player when the Get Item button is pressed in the vehicle inventory menu.

textures: A Json Object that defines which texture to use based on a vanilla Dye Color id. When the player right clicks a vehicle with a Dye Item it checks if there is a texture with that color id defined here.

Example:
"textures": {
    "0": "dscombat:textures/entities/alexis_plane/white.png",
    "1": "dscombat:textures/entities/alexis_plane/orange.png",
    "10": "dscombat:textures/entities/alexis_plane/purple.png"
}

Color Codes: 0 = white 1 = orange 2 = magenta 3 = light_blue 4 = yellow 5 = lime 6 = pink 7 = gray 8 = light_gray 9 = cyan 10 = purple 11 = blue 12 = brown 13 = green 14 = red 15 = black

dyecolor: An integer for the default color id. Make sure this value has a texture defined in the "textures" Json Object.

is_craftable: True/False value. Determines if this preset appears in the Aircraft Workbench.

ingredients: Json Array. A list of items and their amounts needed to craft this preset in the Aircraft Workbench.

Example:
"ingredients": [
    {
      "item": "dscombat:fuselage",
      "num": 1
    },
    {
      "item": "dscombat:wing",
      "num": 2
    },
    {
      "item": "minecraft:redstone",
      "num": 32
    }
]

slots: Json Array. List of all slots and their data within a vehicle. Slots allow players to customize the weapons, engines, radars, and other parts of their vehicle with items. Slot Data definitions:

  • name: Required! String. A translatable name or id for this slot. Every slot name with a preset must be unique.
  • slot_type: Required! Integer. The type of slot and also controls what kinds of parts/items are compatible.
    0 = Seat
    1 = Wing
    2 = Frame
    3 = Internal
    4 = Advanced Internal
    5 = Turret
    6 = Heavy Turret
    7 = Car Engine
    8 = Jet Engine
    9 = Heavy Frame
    10 = Radial Engine
  • slot_posx: Required unless Internal! Decimal. Assuming vehicle points directly south (positive Z), X position of part relative to vehicle center.
  • slot_posy: Required unless Internal! Decimal. Assuming vehicle points directly south (positive Z), Y position of part relative to vehicle center.
  • slot_posz: Required unless Internal! Decimal. Assuming vehicle points directly south (positive Z), Z position of part relative to vehicle center.
  • zRot: Required unless Internal! Degrees. Used to rotate external parts to match the surface they connect to. 0 is if the slot is under a wing. 90 for a left wall, -90 for a right wall, 180 for a top.
  • uix: Required! Integer. The x position of slot in vehicle inventory relative to left. 48 is a good left start point.
  • uiy: Required! Integer. The y position of slot in vehicle inventory relative to top. 20 is a good top start point.
  • data: Json Object. Define the part item you want in this slot. If the slot is empty by default then leave this out. These are the properties to define in here:
    • itemid: Required! String. The item id of the part wanted in this slot be default.
    • filled: Optional! True/False. If the part should be filled by default. Used in fuel tanks and weapon racks for example.
    • param: Optional! String. Special setting for certain parts. Used to define the default weapon in missile racks for example.
Example:
"slots": [
    {
      "data": {
        "itemid": "dscombat:seat"
      },
      "name": "slotname.dscombat.pilot_seat",
      "slot_posx": 0.4,
      "slot_posy": -0.65,
      "slot_posz": 1.5,
      "slot_type": 0,
      "uix": 48,
      "uiy": 20
    },
    {
      "data": {
        "itemid": "dscombat:minigun_turret"
      },
      "name": "slotname.dscombat.seat2",
      "slot_posx": -0.4,
      "slot_posy": -0.65,
      "slot_posz": 1.5,
      "slot_type": 5,
      "uix": 68,
      "uiy": 20
    },
    {
      "data": {
        "filled": true,
        "itemid": "dscombat:heavy_missile_rack",
        "param": "rifel1"
      },
      "name": "slotname.dscombat.frame_1",
      "slot_posx": 0.0,
      "slot_posy": -0.67,
      "slot_posz": 1.9,
      "slot_type": 2,
      "uix": 48,
      "uiy": 80,
      "zRot": 0.0
    },
    {
      "data": {
        "filled": true,
        "itemid": "dscombat:heavy_missile_rack",
        "param": "aim120b"
      },
      "name": "slotname.dscombat.left_wing_1",
      "slot_posx": 0.75,
      "slot_posy": -0.5,
      "slot_posz": 1.8,
      "slot_type": 1,
      "uix": 48,
      "uiy": 40,
      "zRot": 90.0
    },
    {
      "data": {
        "filled": true,
        "itemid": "dscombat:heavy_missile_rack",
        "param": "agm65l"
      },
      "name": "slotname.dscombat.right_wing_1",
      "slot_posx": -0.75,
      "slot_posy": -0.5,
      "slot_posz": 1.8,
      "slot_type": 1,
      "uix": 48,
      "uiy": 60,
      "zRot": -90.0
    },
    {
      "data": {
        "filled": true,
        "itemid": "dscombat:heavy_fuel_tank"
      },
      "name": "slotname.dscombat.internal_3",
      "slot_type": 3,
      "uix": 88,
      "uiy": 100
    },
    {
      "data": {
        "itemid": "dscombat:gr400"
      },
      "name": "slotname.dscombat.internal_6",
      "slot_type": 4,
      "uix": 148,
      "uiy": 100
    }
]

stealth: Decimal. Whether a radar can see a vehicle is dependent on the distance, and the vehicle size. This value is multiplied to the vehicle's size to make it harder or easier for a radar to see. So values smaller than 1 are "more stealthy" than values larger than 1. 0 makes the vehicle invisible to radar. Do not make it negative!

idleheat: Decimal. The heat the vehicle gives of at rest. More heat makes it more attractive to IR missiles and harder to distract with flares.

mass: Decimal. Multiplied by the gravity constant to get the weight force of this vehicle. MUST BE POSITIVE AND NOT ZERO!

Weapons

Weapon presets are applied to all new entity weapons. Unlike Aircraft presets, modifying a weapon preset will update all instances of that weapon. Weapon ammo items and weapon rack items just have a weapon id saved in their NBT. Not every weapon preset will have the same kinds of stats listed in their JSON files. There are several different kinds of weapons, each needs their own different kinds of stats that will be explained below. If you want to make a new weapon, I recommend copying and editing a weapon of the same type from this mod.

type: Integer. The type of weapon.
0 = Bullet
1 = Bomb
2 = Position Missile
3 = Entity Track Missile
4 = IR Missile
5 = Anti Radar Missile
6 = Torpedo

ingredients: Json Array. A list of items and their amounts needed to craft this preset in the Aircraft Workbench.

Example:
"ingredients": [
    {
      "item": "minecraft:copper_ingot",
      "num": 8
    },
    {
      "item": "minecraft:gunpowder",
      "num": 2
    }
]

craftNum: Integer. The number of ammo items received per craft at ammo workbench.

entityTypeKey: String. Entity Id. The entity that this weapon spawns when you shoot it. Only use entities that are the same weapon type!
Examples: "dscombat:bullet" "dscombat:bomb" "dscombat:track_missile_1"

itemKey: String. Item Id. The ammo item from the weapons workbench. Must be an ammo item. The weapon type doesn't matter.
Examples: "dscombat:20mm" "dscombat:bomb" "dscombat:aim120b"

compatibleWeaponPart: String. Item Id. The weapon rack/dispenser item part that this weapon shoots out of.
Examples: "dscombat:xm12" "dscombat:bomb_rack" "dscombat:light_missile_rack" "dscombat:heavy_missile_rack"

rackTypeKey: String. Entity Id. The entity used to visually show the weapon in a vehicle.
Examples: "dscombat:xm12" "dscombat:bomb_rack" "dscombat:light_missile_rack" "dscombat:heavy_missile_rack"

shootSoundKey: String. Sound Id. The sound that plays when a weapon shoots.
Examples: "dscombat:bullet_shoot_1" "dscombat:bomb_shoot_1" "dscombat:rocket_launch_1"

fov: Degrees. All Missiles. The missile's Field Of View. -1 is effectively equivalent to a 180 degree FOV (missile can see all around it).

targetType: Integer. Entity Track Missiles. The type of entities the missile can track.
0 = Aerial Entities
1 = Grounded Entities
2 = Swimming Entities

flareResistance: Decimal greater than 0. IR Missiles. The missile's bias towards flares. Values greater than 1 makes the missile more likely to go after a flare. Values less than 1 makes the missile less likely to go after a flare. 0 makes the missile immune to flares.

Radar

All radars will use the stats defined in their JSON files. There isn't anything stupid complicated going on here.

fov: Degrees. The radar's Field Of View. -1 is effectively equivalent to a 180 degree FOV (radar can see all around it).

sensitivity: Decimal. The minimum cross sectional area of an entity at the radar's max range to be detected.

throGroundRange: Decimal. Number of blocks the radar can "see through"

throWaterRange: Decimal. Number of water sources the radar can "see through"

Modify NBT With Commands

Aircraft, weapon, and radar items use NBT data to determine what preset they are associated with. You can customize this with commands! Here are some examples because explanations are for nerds.

Aircraft:

/give @s dscombat:alexis_plane{preset:alexis_plane_unarmed}

/give @s dscombat:alexis_plane{preset:custom_alexis_plane}

/give @s dscombat:noah_chopper{preset:noah_chopper_empty}

Weapons/Ammo:

/give @s dscombat:bullet{weapon:20mm}

/give @s dscombat:track_air_missile{weapon:custom_missile}

Radar:

Unfortunately, there currently isn't an easy way to do this. Just get a radar item in your hand and do /data get entity @s SelectedItem your smart enough to figure it out.