{
	code: "fish-reef",
	class: "EntityFish",
	"__comment": "reef json is intended for fish that will only spawn around reefs, and will stay close to them.",
	variantgroups: [
		{ "code": "type", "states": [ "angel", "butterfly", "clown", "puffer", "tang", "trigger", "wrasse" ] },
		{ "code": "species", "states": ["common", "banded", "bicolor", "black", "blackwedged", "copperband", "creole", "longspine", "powderblue", "titan", "yellowstripe"] },
		{ "code": "age", "states": ["adult"] }
	],
	allowedVariants: [
		"fish-reef-angel-bicolor-*",
		"fish-reef-butterfly-copperband-*",
		"fish-reef-butterfly-blackwedged-*",
		"fish-reef-clown-black-*",
		"fish-reef-clown-common-*",
		"fish-reef-clown-yellowstripe-*",
		"fish-reef-puffer-longspine-*",
		"fish-reef-tang-banded-*",
		"fish-reef-tang-powderblue-*",
		"fish-reef-trigger-titan-*",
		"fish-reef-wrasse-creole-*",
	],
	hitboxSize: { x: 0.375, y: 0.25 },
	eyeHeight: 0.125,
	drops: [ { type: "item", code: "fishraw-reef-{type}-{species}-{age}" } ],
	attributes: {
		handbook: {
			"groupcode": "creaturegroup-fish-reef"
		},
		baitTags: ["nobait", "bait-worm", "bait-stink", "bait-meat"]
	},
	habitat: "Underwater",
	client: {
		renderer: "Shape",
		size: 1,
		shape: { "base": "entity/animal/fish/reef/{type}-{age}" },
		texture: { base: "entity/animal/fish/reef/{type}-{species}-{age}*" },
		behaviors: [
			{ code: "repulseagents" }, 
			{ code: "controlledphysics", stepHeight: 0 }, 
			{ code: "interpolateposition" },
			{ code: "floatupwhenstuck", onlyWhenDead: true },
			{ code: "harvestable" },
			{ code: "despawn", minPlayerDistance: 8, belowLightLevel: 8, minSeconds: 300 },
			{ code: "despawn", minPlayerDistance: 64, minSeconds: 210 },
		],
		animations: [
			{
				code: "hurt",
				animation: "hurt", 
				animationSpeed: 1,
				weight: 10,
				blendMode: "AddAverage" 
			},
			{
				code: "swim",
				animation: "swim"
			},
			{
				code: "swimfast",
				animation: "run"
			},
			{
				code: "die",
				animation: "dead",
			},
			{
				code: "idle-land",
				animation: "idle-land"
			},
			{
				code: "flop",
				animation: "flopping"
			},
			{
				code: "flop2",
				animation: "flopping2"
			},
			{
				code: "eat",
				animation: "eat"
			},
			{
				code: "eat2",
				animation: "rising-eat"
			},
			{ 
				code: "idle", 
				animation: "idle",
				blendMode: "AddAverage",
				easeOutSpeed: 4,
				triggeredBy: { defaultAnim: true },
			}
		]
	},
	server: {
		behaviors: [
			{ code: "repulseagents" }, 
			{ code: "controlledphysics", stepHeight: 1.1251 }, 
			{ code: "despawn", minPlayerDistance: 12, belowLightLevel: 8, minSeconds: 200 },
			{ code: "health", currenthealth: 2, maxhealth: 2, },
			{ code: "floatupwhenstuck", onlyWhenDead: true },
			{ 
				code: "emotionstates",
				states: [
					{ code: "fleeondamage", duration: 10, chance: 1, slot: 0, priority: 1, accumType: "max" }
				]
			},
			{ 
				code: "taskai",
				aitasks: [
					{
						code: "fishoutofwater", 
						priority: 2.5, 
						priorityForCancel: 2.6,
						movespeed: 0.005,
						animation: "flopping",
						animationSpeed: 1.5
					},
					{
						code: "fishoutofwater", 
						priority: 2.5, 
						priorityForCancel: 2.6,
						movespeed: 0.005,
						animation: "flopping2",
						animationSpeed: 1.5
					},
					{
						code: "fishoutofwater", 
						priority: 2.5, 
						animation: "idle-land"
					},
					{
						code: "fleeentity",
						id: "fleecreature",
						entityCodes: ["player", "wolf-*", "fox-*", "hyena-*"],
						priority: 2,
						whenSwimming: true,
						fleeDurationMs: 10000,
						fleeingDistance: 23,
						movespeed: 0.06,
						seekingRange: 5,
						animation: "swimfast",
						animationSpeed: 2.3
					},
					{
						code: "seekbobber",
						id: "seekbobber",
						entityCodes: ["bobber-*"],
						searchType: "Inanimate",
						targetOnlyInteractableEntities: false,
						priority: 1.8,
						whenSwimming: true,
						seekingRange: 20,
						movespeed: 0.01,
						animation: "swim",
						animationSpeed: 2
					},
					{
						// This task is started through code in EntityBobber
						code: "fleeentity",
						id: "fleebobber",
						entityCodes: ["bobber-*"],
						priority: -1,
						priorityForCancel: 2,
						whenSwimming: true,
						fleeDurationMs: 10000,
						fleeingDistance: 30,
						movespeed: 0.06,
						seekingRange: 14,
						animation: "swimfast",
						animationSpeed: 2.3
					},
					{
						code: "wander", 
						priority: 1.2, 
						priorityForCancel: 1.35,
						movespeed: 0.005,
						animation: "swim",
						minduration: 10000,
						maxduration: 30000,
						maxDistanceToSpawnByType: {
							"fish-reef-clown-common-*": 3,
							"*": 8
						}
					},
					{
						code: "fishmovefast", 
						priority: 1.0, 
						animation: "swimfast",
						priorityForCancel: 1.5,
						movespeed: 0.045,
						minduration: 1000,
						maxduration: 6000,
						mincooldown: 15000,
						maxcooldown: 30000
					},
					{
						code: "idle",
						priority: 0.9,
						animation: "idle",
						priorityForCancel: 1.5,
						minduration: 1000,
						maxduration: 6000,
						mincooldown: 2000,
						maxcooldown: 20000
					},
					{
						code: "idle",
						priority: 0.9,
						animation: "idle",
						minduration: 500,
						maxduration: 1000,
						mincooldown: 2000,
						maxcooldown: 30000
					}
				]
			}
		],
		spawnconditions: {
			worldgen: {
				TriesPerChunk: { avg: 1.5, var: 0 },
				tryOnlySurface: true,
				minLightLevel: 3,
				groupSize: { dist: "verynarrowgaussian", avg: 1, var: 0 },
				insideBlockCodesByType: {
					"fish-reef-clown-common-*": ["coral-anemone-*"],
					"*": ["coral-*"],
				},
				randomMapCodePool: ["fish1", "fish2", "fish3", "fish4", "fish5", "fish6", "fish7", "fish8", "fish9"]
			},
			runtime: {
				group: "passive",
				maxQuantityByGroup: { "code": "fish-reef-{type}-*", "maxQuantity": 16 },
				chance: .0001,
				tryOnlySurface: true,
				minLightLevel: 3,
				groupSize: { dist: "verynarrowgaussian", avg: 2, var: 1 },
				insideBlockCodesByType: {
					"fish-reef-clown-common-*": ["coral-anemone-*"],
					"*": ["coral-*"],
				}
			},
			climate: {
				habitatSize: 0,
				minTempByType: {
					"fish-reef-butterfly-*": 15,
					"fish-reef-tang-*": 8,
					"fish-reef-trigger-titan-*": 8,
					"fish-reef-wrasse-creole-*": 20,
					"fish-reef-puffer-longspine-*": 0,
					"*": 5
				},
				maxTemp: 40,
				minY: 0.8,
				maxY: 1.0,
				randomMapCodePool: ["fish1", "fish2", "fish3", "fish4", "fish5", "fish6", "fish7", "fish8", "fish9"]
			}
		}
	}
}
