Skip to content
SoraZodia edited this page Jun 20, 2019 · 11 revisions

As of v1.1.0, Cannibalism now allows users to add or edit the drops and damage brought upon the usage of its knifes via JSON files. The files are placed in the cannibalism folder found inside Minecraft's config folder. Using the development item called item.knifeOfTesting.name aka dev knife is recommend as it will help creating those JSONs. This knife is found as a creative-only item in the mod's creative tab. Shift-Right clicking in the air with the knife will clear and reload the data parsed from the JSONs, if an JSON is written incorrectly then it will tell you about it in chat and load the default values.

Creating the JSON

If you're familiar with JSON then you can skip ahead to JSON Options. Open up a .txt file and write in two square brackets. These are the beginning and end of your JSON's body

[
]

Next you will want add a entry, this is done so like this (note that all these fields are required, failing to add them will result in a crash due to a NullPointerException)

[
{
"entityID":"Cow",
"modID":"minecraft",
"drops":"minecraft:leather,minecraft:beef",
"minDamage":"2.5",
"maxDamage":"3.0"
}
]

The curly brackets ({}) signal the start and end of an entry.

The words inside the quotation marks ("") are objects, the object to your left is the label for the object to your right and they are linked together by a colon (:). You can only have two objects together, after that a comma will need to be used.

The commas (,) marks the start of a new object. As above example had shown, a comma is used to separate the different objects from each other. If that object is the last object of an entry then a comma is not needed, as seen in the case of the maxDamage object.

Commas is also what allows you to have multiple entities in one file, as seen here:

[
{
"entityID":"Cow*",
"modID":"minecraft",
"drops":"minecraft:leather,minecraft:beef",
"minDamage":"2.5",
"maxDamage":"3.0"
},
{
"entityID":"Chicken",
"modID":"minecraft",
"drops":"",
"minDamage":"10.0",
"maxDamage":"10.0"
},
{
"entityID":"Pig",
"modID":"minecraft",
"drops":"minecraft:porkchop",
"minDamage":"2.5",
"maxDamage":"3.0"
},
{
"entityID":"Villager*",
"modID":"minecraft",
"drops":"cannibalism:villagerFlesh",
"minDamage":"5.0",
"maxDamage":"6.0"
},
{
"entityID":"Zombie*",
"modID":"minecraft",
"drops":"minecraft:rotten_flesh",
"minDamage":"2.5",
"maxDamage":"3.0"
}
]

As with the comma, the last entry don't need a comma.

The file can be saved as both a .txt or a .json, the parser will be able to read both format.

JSON Options

At startup Cannibalism will parse these objects to get the data it needs. They are required for every mobs that will be affected by the knifes. The game will crash if all the entries in the JSON file don't contain these objects - the missing object will cause the parser to become confused.

  • "entityID": This is the unlocalized name of the mob you wish to target, at times the mob in question will have a Minecraft name that's different from what you'll refer them as. Example being the Zombie Pigman, its unlocalized name is "PigZombie" rather then "Zombie Pigman". Right clicking on the entity with the dev knife will reveal its Minecraft name on the chat. Adding a star (*) next to the name (PigZombie*) will cause the parser to treat this as a wildcard entity, all entities that extends from the wildcard entity will share the its JSON values. Ex: Zombie Pigman extends from Zombie, if I set Zombie as a wildcard entity with drops being steak and damage being 5-7 hearts then the Zombie Pigman will also drop steak when it gets cut and receive 5-7 hearts of damage. For players, their IDs would be "player".
  • "modID": This is the ID of the mod which the entity belongs to. The ID will not always be the name of the mod in question (I'm looking at you Way O_O). Righting clicking on the entity with the dev knife will reveal the modID in question. For players, it would be "minecraft".
  • "drops": This determinate what will fall off the entity when it's cut. It uses the same item format as Minecraft's /give command (modID:unlocalizedName). You can have multiple items by using commas to separate them such as "minecraft:leather,minecraft:beef". In addiction, if you are using v1.1.2 or higher (excluding the versions for Minecraft 1.8), you can add # next to the name to signal that the next string is a metadata value. So "minecraft:fish#1" will yield salmon instead of the regular raw fish. Unfortunately, the dev knife won't be able to tell you a item's unlocalized name but one workaround would be to take advantage of /give's tab completion. This is not required for players, and will not affect their drops if present.
  • "minDamage": The lowest amount of hearts that should be taken away from the entity.
  • "maxDamage": The highest amount of hearts that should be taken away from the entity.

Overwriting Default Entity Mappings

As of v1.3.0 and v2.3.0, the default JSON will no longer be generated at startup and an "overwrite" file (.txt/.json format, case-sensitive) is required to change or removed entries from the default entity mappings.

Changing the values for a entity is relatively easy, creating a new JSON entry in the overwrite with the new values is all that is needed.

Something like this will change the drops of Sheeps from mutton and wool to diamond:

{
     "entityID":"Sheep",
     "modID":"minecraft",
     "drops":"minecraft:diamond",
     "minDamage":"2.5",
     "maxDamage":"3.0"
}

Not including an entity will cause it to be removed from the default entity mappings.

Something like this will cause everything but the entry for Villagers to be removed - resulting in the knife only being able to slice flesh from Villagers, and nothing else:

[
   {
     "entityID":"Villager*",
     "modID":"minecraft",
     "drops":"cannibalism:villagerFlesh",
     "minDamage":"5.0",
     "maxDamage":"6.0"
   }
]

To ease the process of removing and changing the default mappings, a sample JSON is provided that contains all the current entities mappings.

Something important to note: This will not effect the entries added by the JSONs in the cannibalism folder. The overwrite is only meant for entries automatically added by the mod.

Links

If you want to read further about JSON formatting (I only explained what was required to have the config running) or extension (The wildcard is based off of Java inheritance) then check these links below

The dev knife will tell you when a JSON is misformatted, but you can also use these resources
Web page: http://jsonformatter.curiousconcept.com/
For Notepad++: http://sourceforge.net/projects/nppjsonviewer/

Google is your friend if you want to use other resources that checks JSONs.