diff --git a/BP/entities/fishing_hook.json b/BP/entities/fishing_hook.json index d29cdc3..8ec0866 100644 --- a/BP/entities/fishing_hook.json +++ b/BP/entities/fishing_hook.json @@ -12,6 +12,12 @@ "client_sync": true, "range": [0, 16], "default": 0 + }, + "yn:current_weather_bit": { + "type": "int", + "client_sync": true, + "range": [0, 2], + "default": 0 } } }, @@ -53,6 +59,33 @@ "events": { "minecraft:entity_spawned": { "sequence": [ + { + "filters": { + "test": "weather_at_position", + "value": "clear" + }, + "set_property": { + "yn:current_weather_bit": 0 + } + }, + { + "filters": { + "test": "weather_at_position", + "value": "rain" + }, + "set_property": { + "yn:current_weather_bit": 1 + } + }, + { + "filters": { + "test": "weather_at_position", + "value": "thunderstorm" + }, + "set_property": { + "yn:current_weather_bit": 2 + } + }, { "filters": { "test": "is_biome", diff --git a/BP/functions/AnglersDesire/reload.mcfunction b/BP/functions/AnglersDesire/reload.mcfunction index 24e63cd..5993f27 100644 --- a/BP/functions/AnglersDesire/reload.mcfunction +++ b/BP/functions/AnglersDesire/reload.mcfunction @@ -1 +1 @@ -execute as @s[hasitem={item=minecraft:fishing_rod}] run function AnglersDesire/reload \ No newline at end of file +execute as @s[hasitem={item=minecraft:fishing_rod}] run scriptevent yn:anglers dev_helper reload \ No newline at end of file diff --git a/BP/functions/AnglersDesire/update.mcfunction b/BP/functions/AnglersDesire/update.mcfunction new file mode 100644 index 0000000..3ca2ae9 --- /dev/null +++ b/BP/functions/AnglersDesire/update.mcfunction @@ -0,0 +1 @@ +scriptevent yn:anglers dev_helper update \ No newline at end of file diff --git a/BP/manifest.json b/BP/manifest.json index 9e95a70..8a12500 100644 --- a/BP/manifest.json +++ b/BP/manifest.json @@ -1,13 +1,13 @@ { "format_version": 2, "header": { - "name": "Angler's Desire BP §8(1.0.1)", + "name": "Angler's Desire BP §8(1.1.0) [DEBUG]", "description": "Adding immersion to vanilla fishing mechanics in Minecraft \n @Made By: https://twitter.com/h_YanG_0A", "uuid": "f36713ae-a50d-4eae-ab09-14bef4e580ec", "version": [ 1, - 0, - 1 + 1, + 0 ], "min_engine_version": [ 1, @@ -33,8 +33,8 @@ "uuid": "02a44d23-5962-4bb5-8a78-ef87d1eb0726", "version": [ 1, - 0, - 1 + 1, + 0 ], "entry": "scripts/main.js" } @@ -55,8 +55,8 @@ "uuid": "54ee84f3-7b81-421c-8602-2d399940fd59", "version": [ 1, - 0, - 1 + 1, + 0 ] } ], diff --git a/BP/scripts/commands/dev_helper.js b/BP/scripts/commands/dev_helper.js index c7f6c23..c34a9f3 100644 --- a/BP/scripts/commands/dev_helper.js +++ b/BP/scripts/commands/dev_helper.js @@ -1,21 +1,25 @@ -import { BlockTypes, EnchantmentTypes, EntityComponentTypes, EquipmentSlot, ItemComponentTypes, ItemEnchantableComponent, ItemStack, MolangVariableMap, system } from "@minecraft/server"; +import { BlockTypes, EnchantmentTypes, EntityComponentTypes, EquipmentSlot, ItemComponentTypes, ItemEnchantableComponent, ItemStack, MolangVariableMap, system, world } from "@minecraft/server"; import { CommandHandler } from "commands/command_handler"; import { SendMessageTo, sleep } from "utils/utilities"; import { overrideEverything } from "overrides/index"; import { MinecraftBlockTypes, MinecraftEnchantmentTypes, MinecraftItemTypes } from "vanilla-types/index"; -import { FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; import { AStarOptions } from "utils/NoxUtils/Pathfinder/AStarOptions"; import { BidirectionalAStar } from "utils/NoxUtils/Pathfinder/BidirectionalAStar"; +import { FishingCustomEnchantmentType } from "custom_enchantment/available_custom_enchantments"; +import { TacosFishEntityTypes } from "fishing_system/entities/compatibility/tacos_fish_mobs"; +import { db } from "constant"; overrideEverything(); var REQUIRED_PARAMETER; (function (REQUIRED_PARAMETER) { REQUIRED_PARAMETER["GET"] = "get"; - REQUIRED_PARAMETER["TEST"] = "test"; - REQUIRED_PARAMETER["RELOAD_INVENTORY"] = "reload"; REQUIRED_PARAMETER["LOAD_OLD"] = "load_old"; + REQUIRED_PARAMETER["RELOAD_INVENTORY"] = "reload"; + REQUIRED_PARAMETER["UPDATE_ADDON"] = "update"; + REQUIRED_PARAMETER["TEST"] = "test"; REQUIRED_PARAMETER["PATHFIND_TEST"] = "pathfind"; REQUIRED_PARAMETER["DAMAGE_TEST"] = "damage"; REQUIRED_PARAMETER["PARTICLE_TEST"] = "particle"; + REQUIRED_PARAMETER["TACO_FISH_TEST"] = "test_tacofish"; })(REQUIRED_PARAMETER || (REQUIRED_PARAMETER = {})); const command = { name: 'dev_helper', @@ -28,8 +32,8 @@ const command = { Usage: > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.GET} = GETS an enchanted fishing rod for development. > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.RELOAD_INVENTORY} = Reload the fishing rod's hook bug. - > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.DAMAGE_TEST} = Damages fishing rod hook usage. - > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.PARTICLE_TEST} = TEST a Working-in-progress particle. + > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.LOAD_OLD} = Loads the old custom dynamic property for fishing rod. For bug fixing purposes. It's chained with reload command after. + > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.UPDATE_ADDON} = Updates the addon to the latest, after deleting the old addon, and installing the new one. `).replaceAll(" ", ""); }, execute(player, args) { @@ -63,6 +67,32 @@ const command = { break; case REQUIRED_PARAMETER.TEST: break; + case REQUIRED_PARAMETER.UPDATE_ADDON: + if (db.has("WorldIsRaining")) + db.delete("WorldIsRaining"); + world.sendMessage("§a§lAngler's Desire Addon's Scripts§r §ahas been updated successfully."); + break; + case REQUIRED_PARAMETER.TACO_FISH_TEST: + let successCount = 0; + system.run(async () => { + for (const tacoFishType of Object.values(TacosFishEntityTypes)) { + try { + const t = player.dimension.spawnEntity(tacoFishType, player.location); + await system.waitTicks(3); + t.kill(); + successCount++; + } + catch (e) { + continue; + } + } + SendMessageTo(player, { + rawtext: [ + { text: `Success: ${successCount}\nTotal: ${(Object.values(TacosFishEntityTypes).length)}` } + ] + }); + }); + break; case REQUIRED_PARAMETER.DAMAGE_TEST: if (!args[1].length) return; @@ -92,6 +122,13 @@ const command = { } inventory.setItem(slot, fishingRod); } + SendMessageTo(player, { + rawtext: [ + { + text: "§a§lAngler's Desire§r §afishing hook enhancement bug located in your current inventory has been fully reloaded." + } + ] + }); break; case REQUIRED_PARAMETER.LOAD_OLD: fishingRod = player.equippedTool(EquipmentSlot.Mainhand); diff --git a/BP/scripts/constant.js b/BP/scripts/constant.js index c40357c..55790ee 100644 --- a/BP/scripts/constant.js +++ b/BP/scripts/constant.js @@ -5,7 +5,7 @@ export const ADDON_NAME = "Anglers_Desire"; export const ADDON_IDENTIFIER = `${ADDON_NAMESPACE}:anglers`; export const db = new JsonDatabase(ADDON_NAME); export const localFishersCache = new Map(); -export const spawnedLogMap = new Map(); +export const onSpawnHookLogMap = new Map(); export const onCaughtParticleLogMap = new Map(); export const onLostParticleLogMap = new Map(); export const onHookLandedCallingLogMap = new Map(); diff --git a/BP/scripts/custom_enchantment/available_custom_enchantments.js b/BP/scripts/custom_enchantment/available_custom_enchantments.js new file mode 100644 index 0000000..e898768 --- /dev/null +++ b/BP/scripts/custom_enchantment/available_custom_enchantments.js @@ -0,0 +1,67 @@ +import { MyCustomItemTypes } from "fishing_system/items/custom_items"; +import { CustomEnchantment } from "./custom_enchantment"; +export class FishingCustomEnchantmentType { + static get Nautilus() { + return new CustomEnchantment({ + icon: "textures/items/nautilus_hook", + id: "Nautilus", + itemID: MyCustomItemTypes.NautilusHook, + name: "Nautilus Hook", + description: "yn:fishing_got_reel.enchantments.nautilus.description", + lore: "yn:fishing_got_reel.enchantments.nautilus.lore", + level: 1, + maxUsage: 75, + conflicts: ["Pyroclasm Hook", "Fermented Hook"], + }); + } + static get Luminous() { + return new CustomEnchantment({ + icon: "textures/items/luminous_siren_hook", + id: "Luminous", + itemID: MyCustomItemTypes.LuminousHook, + name: "Luminous Hook", + description: "yn:fishing_got_reel.enchantments.luminous.description", + lore: "yn:fishing_got_reel.enchantments.luminous.lore", + level: 1, + maxUsage: 54, + }); + } + static get Pyroclasm() { + return new CustomEnchantment({ + icon: "textures/items/pyroclasm_hook", + id: "Pyroclasm", + itemID: MyCustomItemTypes.PyroclasmHook, + name: "Pyroclasm Hook", + description: "yn:fishing_got_reel.enchantments.pyroclasm.description", + lore: "yn:fishing_got_reel.enchantments.pyroclasm.lore", + level: 1, + maxUsage: 45, + conflicts: ["Nautilus Hook"], + }); + } + static get Tempus() { + return new CustomEnchantment({ + icon: "textures/items/tempus_hook", + id: "Tempus", + itemID: MyCustomItemTypes.TempusHook, + name: "Tempus Hook", + description: "yn:fishing_got_reel.enchantments.tempus.description", + lore: "yn:fishing_got_reel.enchantments.tempus.lore", + level: 1, + maxUsage: 92, + }); + } + static get FermentedEye() { + return new CustomEnchantment({ + icon: "textures/items/fermented_spider_eye_hook", + id: "FermentedEye", + itemID: MyCustomItemTypes.FermentedSpiderEyeHook, + name: "Fermented Hook", + description: "yn:fishing_got_reel.enchantments.fermentedeye.description", + lore: "yn:fishing_got_reel.enchantments.fermentedeye.lore", + level: 1, + maxUsage: 60, + conflicts: ["Nautilus Hook"], + }); + } +} diff --git a/BP/scripts/custom_enchantment/custom_enchantment_types.js b/BP/scripts/custom_enchantment/custom_enchantment_types.js index bc2dd7e..148323e 100644 --- a/BP/scripts/custom_enchantment/custom_enchantment_types.js +++ b/BP/scripts/custom_enchantment/custom_enchantment_types.js @@ -1,70 +1,4 @@ -import { MyCustomItemTypes } from "fishing_system/items/custom_items"; -import { CustomEnchantment } from "./custom_enchantment"; -export class FishingCustomEnchantmentType { - static get Nautilus() { - return new CustomEnchantment({ - icon: "textures/items/nautilus_hook", - id: "Nautilus", - itemID: MyCustomItemTypes.NautilusHook, - name: "Nautilus Hook", - description: "yn:fishing_got_reel.enchantments.nautilus.description", - lore: "yn:fishing_got_reel.enchantments.nautilus.lore", - level: 1, - maxUsage: 75, - conflicts: ["Pyroclasm Hook", "Fermented Hook"], - }); - } - static get Luminous() { - return new CustomEnchantment({ - icon: "textures/items/luminous_siren_hook", - id: "Luminous", - itemID: MyCustomItemTypes.LuminousHook, - name: "Luminous Hook", - description: "yn:fishing_got_reel.enchantments.luminous.description", - lore: "yn:fishing_got_reel.enchantments.luminous.lore", - level: 1, - maxUsage: 54, - }); - } - static get Pyroclasm() { - return new CustomEnchantment({ - icon: "textures/items/pyroclasm_hook", - id: "Pyroclasm", - itemID: MyCustomItemTypes.PyroclasmHook, - name: "Pyroclasm Hook", - description: "yn:fishing_got_reel.enchantments.pyroclasm.description", - lore: "yn:fishing_got_reel.enchantments.pyroclasm.lore", - level: 1, - maxUsage: 45, - conflicts: ["Nautilus Hook"], - }); - } - static get Tempus() { - return new CustomEnchantment({ - icon: "textures/items/tempus_hook", - id: "Tempus", - itemID: MyCustomItemTypes.TempusHook, - name: "Tempus Hook", - description: "yn:fishing_got_reel.enchantments.tempus.description", - lore: "yn:fishing_got_reel.enchantments.tempus.lore", - level: 1, - maxUsage: 92, - }); - } - static get FermentedEye() { - return new CustomEnchantment({ - icon: "textures/items/fermented_spider_eye_hook", - id: "FermentedEye", - itemID: MyCustomItemTypes.FermentedSpiderEyeHook, - name: "Fermented Hook", - description: "yn:fishing_got_reel.enchantments.fermentedeye.description", - lore: "yn:fishing_got_reel.enchantments.fermentedeye.lore", - level: 1, - maxUsage: 60, - conflicts: ["Nautilus Hook"], - }); - } -} +import { FishingCustomEnchantmentType } from "./available_custom_enchantments"; export class CustomEnchantmentTypes { static get(customEnchantmentType) { const allAvailableCustomEnchantments = this.CachedAvailableEnchantments.length ? this.CachedAvailableEnchantments : this.getAll(); diff --git a/BP/scripts/fishing_system/configuration/configuration_screen.js b/BP/scripts/fishing_system/configuration/configuration_screen.js index 3d27e97..e757de7 100644 --- a/BP/scripts/fishing_system/configuration/configuration_screen.js +++ b/BP/scripts/fishing_system/configuration/configuration_screen.js @@ -6,10 +6,11 @@ import { clientConfiguration } from "./client_configuration"; import { FishingOutputBuilder } from "fishing_system/outputs/output_builder"; import { SendMessageTo } from "utils/index"; import { resetServerConfiguration, serverConfigurationCopy, setServerConfiguration } from "./server_configuration"; -import { CustomEnchantmentTypes, FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; +import { CustomEnchantmentTypes } from "custom_enchantment/custom_enchantment_types"; import { CustomEnchantment } from "custom_enchantment/custom_enchantment"; import { MinecraftItemTypes } from "vanilla-types/index"; import { MyCustomItemTypes } from "fishing_system/items/custom_items"; +import { FishingCustomEnchantmentType } from "custom_enchantment/available_custom_enchantments"; export class Configuration { constructor(player) { this.player = player; diff --git a/BP/scripts/fishing_system/configuration/server_configuration.js b/BP/scripts/fishing_system/configuration/server_configuration.js index 392d41f..e01851a 100644 --- a/BP/scripts/fishing_system/configuration/server_configuration.js +++ b/BP/scripts/fishing_system/configuration/server_configuration.js @@ -25,7 +25,7 @@ export const serverConfiguration = { /** * Enables debug messages to content logs. */ - debug: new FormBuilder("Debug Mode").createToggle(false), + debug: new FormBuilder("Debug Mode").createToggle(true), }; export let serverConfigurationCopy = cloneConfiguration(serverConfiguration); @@ -33,4 +33,4 @@ export let setServerConfiguration = (newServerConfig) => serverConfigurationCopy export let resetServerConfiguration = () => serverConfigurationCopy = cloneConfiguration(serverConfiguration); // version (do not change) -export const VERSION = "1.0.1"; \ No newline at end of file +export const VERSION = "1.1.0"; \ No newline at end of file diff --git a/BP/scripts/fishing_system/entities/compatibility/tacos_fish_mobs.js b/BP/scripts/fishing_system/entities/compatibility/tacos_fish_mobs.js new file mode 100644 index 0000000..91b0b0a --- /dev/null +++ b/BP/scripts/fishing_system/entities/compatibility/tacos_fish_mobs.js @@ -0,0 +1,103 @@ +export var TacosFishEntityTypes; +(function (TacosFishEntityTypes) { + TacosFishEntityTypes["Anchovy"] = "taco:anchovy"; + TacosFishEntityTypes["Sardine"] = "taco:sardine"; + TacosFishEntityTypes["Mackerel"] = "taco:mackerel"; + TacosFishEntityTypes["Herring"] = "taco:herring"; + TacosFishEntityTypes["Mullet"] = "taco:mullet"; + TacosFishEntityTypes["Porgy"] = "taco:porgy"; + TacosFishEntityTypes["Croaker"] = "taco:croaker"; + TacosFishEntityTypes["Grunt"] = "taco:grunt"; + TacosFishEntityTypes["Tarpon"] = "taco:tarpon"; + TacosFishEntityTypes["Bluefish"] = "taco:bluefish"; + TacosFishEntityTypes["Crevalle"] = "taco:crevalle"; + TacosFishEntityTypes["Snook"] = "taco:snook"; + TacosFishEntityTypes["Bumper"] = "taco:bumper"; + TacosFishEntityTypes["Lookdown"] = "taco:lookdown"; + TacosFishEntityTypes["Kahawai"] = "taco:kahawai"; + TacosFishEntityTypes["Yellowtail"] = "taco:yellowtail"; + TacosFishEntityTypes["Permit"] = "taco:permit"; + TacosFishEntityTypes["Minnow"] = "taco:minnow"; + TacosFishEntityTypes["Perch"] = "taco:perch"; + TacosFishEntityTypes["Bluegill"] = "taco:bluegill"; + TacosFishEntityTypes["Sunfish"] = "taco:sunfish"; + TacosFishEntityTypes["Mooneye"] = "taco:mooneye"; + TacosFishEntityTypes["Bass"] = "taco:bass"; + TacosFishEntityTypes["Smelt"] = "taco:smelt"; + TacosFishEntityTypes["Carp"] = "taco:carp"; + TacosFishEntityTypes["Ide"] = "taco:ide"; + TacosFishEntityTypes["Shad"] = "taco:shad"; + TacosFishEntityTypes["Asp"] = "taco:asp"; + TacosFishEntityTypes["Tilapia"] = "taco:tilapia"; + TacosFishEntityTypes["Buffalo"] = "taco:buffalo"; + TacosFishEntityTypes["Yellowfish"] = "taco:yellowfish"; + TacosFishEntityTypes["Mojarra"] = "taco:mojarra"; + TacosFishEntityTypes["Moggel"] = "taco:moggel"; + TacosFishEntityTypes["Barramundi"] = "taco:barramundi"; + TacosFishEntityTypes["Bonefish"] = "taco:bonefish"; + TacosFishEntityTypes["Drum"] = "taco:drum"; + TacosFishEntityTypes["Amberjack"] = "taco:amberjack"; + TacosFishEntityTypes["Oilfish"] = "taco:oilfish"; + TacosFishEntityTypes["Barracuda"] = "taco:barracuda"; + TacosFishEntityTypes["Flounder"] = "taco:flounder"; + TacosFishEntityTypes["Pomfret"] = "taco:pomfret"; + TacosFishEntityTypes["Queenfish"] = "taco:queenfish"; + TacosFishEntityTypes["Grouper"] = "taco:grouper"; + TacosFishEntityTypes["Tuna"] = "taco:tuna"; + TacosFishEntityTypes["Tripletail"] = "taco:tripletail"; + TacosFishEntityTypes["Bonito"] = "taco:bonito"; + TacosFishEntityTypes["MahiMahi"] = "taco:mahi_mahi"; + TacosFishEntityTypes["Snapper"] = "taco:snapper"; + TacosFishEntityTypes["Crappie"] = "taco:crappie"; + TacosFishEntityTypes["Pumpkinseed"] = "taco:pumpkinseed"; + TacosFishEntityTypes["Yellowbelly"] = "taco:yellowbelly"; + TacosFishEntityTypes["Sauger"] = "taco:sauger"; + TacosFishEntityTypes["Walleye"] = "taco:walleye"; + TacosFishEntityTypes["Bowfin"] = "taco:bowfin"; + TacosFishEntityTypes["Bream"] = "taco:bream"; + TacosFishEntityTypes["Tench"] = "taco:tench"; + TacosFishEntityTypes["Grayling"] = "taco:grayling"; + TacosFishEntityTypes["Trout"] = "taco:trout"; + TacosFishEntityTypes["Pike"] = "taco:pike"; + TacosFishEntityTypes["Nelma"] = "taco:nelma"; + TacosFishEntityTypes["Piranha"] = "taco:piranha"; + TacosFishEntityTypes["Guapote"] = "taco:guapote"; + TacosFishEntityTypes["Gar"] = "taco:gar"; + TacosFishEntityTypes["Pavon"] = "taco:pavon"; + TacosFishEntityTypes["Blackfish"] = "taco:blackfish"; + TacosFishEntityTypes["Tambaqui"] = "taco:tambaqui"; + TacosFishEntityTypes["Ladyfish"] = "taco:ladyfish"; + TacosFishEntityTypes["Roosterfish"] = "taco:roosterfish"; + TacosFishEntityTypes["Opah"] = "taco:opah"; + TacosFishEntityTypes["Wahoo"] = "taco:wahoo"; + TacosFishEntityTypes["Needlefish"] = "taco:needlefish"; + TacosFishEntityTypes["Trevally"] = "taco:trevally"; + TacosFishEntityTypes["Cobia"] = "taco:cobia"; + TacosFishEntityTypes["Leerfish"] = "taco:leerfish"; + TacosFishEntityTypes["Threadfin"] = "taco:threadfin"; + TacosFishEntityTypes["Stonefish"] = "taco:stonefish"; + TacosFishEntityTypes["Hogfish"] = "taco:hogfish"; + TacosFishEntityTypes["Mola"] = "taco:mola"; + TacosFishEntityTypes["Papermouth"] = "taco:papermouth"; + TacosFishEntityTypes["Catfish"] = "taco:catfish"; + TacosFishEntityTypes["Pickerel"] = "taco:pickerel"; + TacosFishEntityTypes["Barbel"] = "taco:barbel"; + TacosFishEntityTypes["Sturgeon"] = "taco:sturgeon"; + TacosFishEntityTypes["Stringfish"] = "taco:stringfish"; + TacosFishEntityTypes["Knifefish"] = "taco:knifefish"; + TacosFishEntityTypes["Arowana"] = "taco:arowana"; + TacosFishEntityTypes["Mahseer"] = "taco:mahseer"; + TacosFishEntityTypes["Paddlefish"] = "taco:paddlefish"; + TacosFishEntityTypes["Anglerfish"] = "taco:anglerfish"; + TacosFishEntityTypes["Coelacanth"] = "taco:coelacanth"; + TacosFishEntityTypes["Pompano"] = "taco:pompano"; + TacosFishEntityTypes["Marlin"] = "taco:marlin"; + TacosFishEntityTypes["Lionfish"] = "taco:lionfish"; + TacosFishEntityTypes["Oarfish"] = "taco:oarfish"; + TacosFishEntityTypes["Warmouth"] = "taco:warmouth"; + TacosFishEntityTypes["Muskie"] = "taco:muskie"; + TacosFishEntityTypes["Burbot"] = "taco:burbot"; + TacosFishEntityTypes["Mandarin"] = "taco:mandarin"; + TacosFishEntityTypes["DollyVarden"] = "taco:dolly_varden"; + TacosFishEntityTypes["Arapaima"] = "taco:arapaima"; +})(TacosFishEntityTypes || (TacosFishEntityTypes = {})); diff --git a/BP/scripts/fishing_system/entities/fisher.js b/BP/scripts/fishing_system/entities/fisher.js index a222c98..2478878 100644 --- a/BP/scripts/fishing_system/entities/fisher.js +++ b/BP/scripts/fishing_system/entities/fisher.js @@ -25,6 +25,7 @@ class Fisher { this.caughtByHook = null; this.currentBiomeLootTable = Object.getOwnPropertyNames(LootTable).filter(prop => !['name', 'prototype', 'length', 'fishingModifier'].includes(prop)); this.currentBiome = 0; + this.currentWeather = 0; this.canBeReeled = false; this._source = player; this._particleSplashMolang = new MolangVariableMap(); diff --git a/BP/scripts/fishing_system/events/on_hook_created.js b/BP/scripts/fishing_system/events/on_hook_created.js index 063b513..5ddffba 100644 --- a/BP/scripts/fishing_system/events/on_hook_created.js +++ b/BP/scripts/fishing_system/events/on_hook_created.js @@ -1,16 +1,17 @@ -import { spawnedLogMap, localFishersCache } from "constant"; +import { onSpawnHookLogMap, localFishersCache } from "constant"; import { onHookLanded } from "./on_wait_hook_stablized"; export function onFishingHookCreated(entitySpawned, fisher) { if (entitySpawned.typeId !== "minecraft:fishing_hook") return; const player = fisher.source; - const oldLog = spawnedLogMap.get(player.id); - spawnedLogMap.set(player.id, Date.now()); + const oldLog = onSpawnHookLogMap.get(player.id); + onSpawnHookLogMap.set(player.id, Date.now()); if ((oldLog + 150) >= Date.now()) return; localFishersCache.set(player.id, fisher.reset()); fisher.setFishingHook(entitySpawned); fisher.currentBiome = fisher.fishingHook.getProperty("yn:current_biome_bit"); + fisher.currentWeather = fisher.fishingHook.getProperty("yn:current_weather_bit"); localFishersCache.set(player.id, fisher); onHookLanded(player); } diff --git a/BP/scripts/fishing_system/loot_tables/ParentCatch.js b/BP/scripts/fishing_system/loot_tables/biome_catch_helper.js similarity index 82% rename from BP/scripts/fishing_system/loot_tables/ParentCatch.js rename to BP/scripts/fishing_system/loot_tables/biome_catch_helper.js index 8b02e5b..f01218d 100644 --- a/BP/scripts/fishing_system/loot_tables/ParentCatch.js +++ b/BP/scripts/fishing_system/loot_tables/biome_catch_helper.js @@ -1,11 +1,10 @@ -import { world } from "@minecraft/server"; export class ParentCatchLoot { static FilteredEntityEntry() { const rainChanceModifier = this.RAIN_INCREASED_CHANCE / 100; - const isRaining = world.IsRaining; + const isRaining = this.fisher.currentWeather > 0; const totalGeneralWeight = this.GeneralLoots.reduce((sum, loot) => sum + loot.weight, 0); const additionalLoots = [ - ...(this.upgrade.has("Luminous") ? this.LuminousLoots : []), + ...(this.fisher.fishingRod.upgrade.has("Luminous") ? this.LuminousLoots : []), ...(isRaining ? this.SpecialRainLoots : []) ]; const additionalWeight = additionalLoots.reduce((sum, loot) => sum + loot.weight, 0); @@ -26,12 +25,12 @@ export class ParentCatchLoot { } return BlendedLoots; } - static initializeAttributes(upgrade, RAIN_INCREASE, entityLoots) { + static initializeAttributes(fisher, RAIN_INCREASE, entityLoots) { this.GeneralLoots = entityLoots.GeneralLoots; this.SpecialRainLoots = entityLoots.SpecialRainLoots; this.LuminousLoots = entityLoots.LuminousLoots; this.RAIN_INCREASED_CHANCE = RAIN_INCREASE; - this.upgrade = upgrade; + this.fisher = fisher; } } ParentCatchLoot.RAIN_INCREASED_CHANCE = 150; diff --git a/BP/scripts/fishing_system/loot_tables/biomes/DefaultCatch.js b/BP/scripts/fishing_system/loot_tables/biomes/DefaultCatch.js index 258269e..2c27890 100644 --- a/BP/scripts/fishing_system/loot_tables/biomes/DefaultCatch.js +++ b/BP/scripts/fishing_system/loot_tables/biomes/DefaultCatch.js @@ -1,9 +1,10 @@ import { MinecraftItemTypes } from "vanilla-types/index"; -import { ParentCatchLoot } from "../ParentCatch"; +import { ParentCatchLoot } from "../biome_catch_helper"; import { MyCustomItemTypes } from "fishing_system/items/custom_items"; export class DefaultCatch extends ParentCatchLoot { - static Loot(modifier, upgrade, entityLoots, RAIN_INCREASE = 150) { - this.initializeAttributes(upgrade, RAIN_INCREASE, entityLoots); + static Loot(modifier, fisher, entityLoots, RAIN_INCREASE = 150) { + const upgrade = fisher.fishingRod.upgrade; + this.initializeAttributes(fisher, RAIN_INCREASE, entityLoots); const fishWeight = ((85 - (modifier.LoTSModifier * 0.15)) - (modifier.deepnessModifier / 1.5)) * (upgrade.has("Nautilus") ? 0 : 1); const junkWeight = ((10 - (modifier.LoTSModifier * 1.95)) + (modifier.deepnessModifier / 2)) + (upgrade.has("Nautilus") ? 50 : 0); const treasureWeight = ((5 + (modifier.LoTSModifier * 2.1)) + modifier.deepnessModifier) + (upgrade.has("Nautilus") ? 15 : 0); diff --git a/BP/scripts/fishing_system/loot_tables/biomes/JungleCatch.js b/BP/scripts/fishing_system/loot_tables/biomes/JungleCatch.js index ca8ff8b..508964f 100644 --- a/BP/scripts/fishing_system/loot_tables/biomes/JungleCatch.js +++ b/BP/scripts/fishing_system/loot_tables/biomes/JungleCatch.js @@ -1,8 +1,9 @@ import { MinecraftItemTypes } from "vanilla-types/index"; -import { ParentCatchLoot } from "../ParentCatch"; +import { ParentCatchLoot } from "../biome_catch_helper"; export class JungleCatch extends ParentCatchLoot { - static Loot(modifier, upgrade, entityLoots, RAIN_INCREASE = 150) { - this.initializeAttributes(upgrade, RAIN_INCREASE, entityLoots); + static Loot(modifier, fisher, entityLoots, RAIN_INCREASE = 150) { + const upgrade = fisher.fishingRod.upgrade; + this.initializeAttributes(fisher, RAIN_INCREASE, entityLoots); const fishWeight = ((85 - (modifier.LoTSModifier * 0.15)) - (modifier.deepnessModifier / 1.5)) * (upgrade.has("Nautilus") ? 0 : 1); const junkWeight = ((10 - (modifier.LoTSModifier * 1.95)) + (modifier.deepnessModifier / 2)) + (upgrade.has("Nautilus") ? 50 : 0); const treasureWeight = ((5 + (modifier.LoTSModifier * 2.1)) + modifier.deepnessModifier) + (upgrade.has("Nautilus") ? 15 : 0); diff --git a/BP/scripts/fishing_system/loot_tables/biomes/OceanCatch.js b/BP/scripts/fishing_system/loot_tables/biomes/OceanCatch.js index d2bb73a..3c22901 100644 --- a/BP/scripts/fishing_system/loot_tables/biomes/OceanCatch.js +++ b/BP/scripts/fishing_system/loot_tables/biomes/OceanCatch.js @@ -1,9 +1,10 @@ import { MinecraftItemTypes } from "vanilla-types/index"; -import { ParentCatchLoot } from "../ParentCatch"; +import { ParentCatchLoot } from "../biome_catch_helper"; import { MyCustomItemTypes } from "fishing_system/items/custom_items"; export class OceanCatch extends ParentCatchLoot { - static Loot(modifier, upgrade, entityLoots, RAIN_INCREASE = 150) { - this.initializeAttributes(upgrade, RAIN_INCREASE, entityLoots); + static Loot(modifier, fisher, entityLoots, RAIN_INCREASE = 150) { + const upgrade = fisher.fishingRod.upgrade; + this.initializeAttributes(fisher, RAIN_INCREASE, entityLoots); const fishWeight = ((85 - (modifier.LoTSModifier * 0.15)) - (modifier.deepnessModifier / 1.5)) * (upgrade.has("Nautilus") ? 0 : 1); const junkWeight = ((10 - (modifier.LoTSModifier * 1.95)) + (modifier.deepnessModifier / 2)) + (upgrade.has("Nautilus") ? 50 : 0); const treasureWeight = ((5 + (modifier.LoTSModifier * 2.1)) + modifier.deepnessModifier) + (upgrade.has("Nautilus") ? 15 : 0); diff --git a/BP/scripts/fishing_system/loot_tables/compatible_loot_manager.js b/BP/scripts/fishing_system/loot_tables/compatible_loot_manager.js new file mode 100644 index 0000000..48bcf4f --- /dev/null +++ b/BP/scripts/fishing_system/loot_tables/compatible_loot_manager.js @@ -0,0 +1,15 @@ +import { ItemTypes } from "@minecraft/server"; +class CompatibilityLootManager { + static get TacosFish() { + return ItemTypes.get('taco:catfish'); + } +} +export class CompatibleAddonHandler { + static getAll() { + const allAvailableCompatibleAddons = Object.getOwnPropertyNames(CompatibilityLootManager).filter((prop) => !(['length', 'name', 'prototype'].includes(prop))); + return allAvailableCompatibleAddons; + } + static isInstalled(addonCompatibilityName) { + return CompatibilityLootManager[addonCompatibilityName] !== undefined; + } +} diff --git a/BP/scripts/fishing_system/loot_tables/loot_tables.js b/BP/scripts/fishing_system/loot_tables/loot_tables.js index f4ce076..13b2997 100644 --- a/BP/scripts/fishing_system/loot_tables/loot_tables.js +++ b/BP/scripts/fishing_system/loot_tables/loot_tables.js @@ -6,8 +6,8 @@ export class LootTable { const deepTreasureModifier = (isDeeplySubmerged ? 34.5 : 0); return { LoTSModifier: LoTSLevel, deepnessModifier: deepTreasureModifier }; } - static Anywhere(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Anywhere(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -41,8 +41,8 @@ export class LootTable { ] }); } - static Jungle(level, isDeeplySubmerged = false, upgrade) { - return JungleCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Jungle(level, isDeeplySubmerged = false, fisher) { + return JungleCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -76,8 +76,8 @@ export class LootTable { ] }); } - static Ocean(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Ocean(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -116,8 +116,8 @@ export class LootTable { ] }); } - static DeepOcean(level, isDeeplySubmerged = false, upgrade) { - return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepOcean(level, isDeeplySubmerged = false, fisher) { + return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -156,8 +156,8 @@ export class LootTable { ] }); } - static FrozenOcean(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static FrozenOcean(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -196,8 +196,8 @@ export class LootTable { ] }); } - static DeepFrozenOcean(level, isDeeplySubmerged = false, upgrade) { - return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepFrozenOcean(level, isDeeplySubmerged = false, fisher) { + return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -236,8 +236,8 @@ export class LootTable { ] }); } - static ColdOcean(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static ColdOcean(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -276,8 +276,8 @@ export class LootTable { ] }); } - static DeepColdOcean(level, isDeeplySubmerged = false, upgrade) { - return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepColdOcean(level, isDeeplySubmerged = false, fisher) { + return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -311,8 +311,8 @@ export class LootTable { ] }); } - static Lukewarm(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Lukewarm(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -356,8 +356,8 @@ export class LootTable { ] }); } - static DeepLukewarm(level, isDeeplySubmerged = false, upgrade) { - return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepLukewarm(level, isDeeplySubmerged = false, fisher) { + return OceanCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -406,8 +406,8 @@ export class LootTable { ] }); } - static WarmOcean(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static WarmOcean(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -451,8 +451,8 @@ export class LootTable { ] }); } - static MangroveSwamp(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static MangroveSwamp(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Air, @@ -486,8 +486,8 @@ export class LootTable { ] }); } - static LushCave(level, isDeeplySubmerged = false, upgrade) { - return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static LushCave(level, isDeeplySubmerged = false, fisher) { + return DefaultCatch.Loot(this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Air, diff --git a/BP/scripts/fishing_system/upgrades/upgrades.js b/BP/scripts/fishing_system/upgrades/upgrades.js index a089234..776824e 100644 --- a/BP/scripts/fishing_system/upgrades/upgrades.js +++ b/BP/scripts/fishing_system/upgrades/upgrades.js @@ -1,5 +1,5 @@ import { ItemEnchantableComponent } from "@minecraft/server"; -import { FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; +import { FishingCustomEnchantmentType } from "custom_enchantment/available_custom_enchantments"; import { overrideEverything } from "overrides/index"; overrideEverything(); export class HookUpgrades { diff --git a/BP/scripts/main.js b/BP/scripts/main.js index ee5f42f..de951d9 100644 --- a/BP/scripts/main.js +++ b/BP/scripts/main.js @@ -1,4 +1,4 @@ -import { world, system, Player, ScriptEventSource, WeatherType, EntityInventoryComponent, ItemTypes } from "@minecraft/server"; +import { world, system, Player, ScriptEventSource, EntityInventoryComponent, ItemTypes } from "@minecraft/server"; import { ADDON_IDENTIFIER, ADDON_NAME, db, fetchFisher, onCustomBlockInteractLogMap } from "./constant"; import { onFishingHookCreated } from "./fishing_system/events/on_hook_created"; import { overrideEverything } from "overrides/index"; @@ -27,6 +27,31 @@ world.beforeEvents.worldInitialize.subscribe((e) => { world.afterEvents.playerSpawn.subscribe((e) => { if (!e.initialSpawn) return; + if (!db.has(`playerFirstJoined-${e.player.id}`)) { + db.set(`playerFirstJoined-${e.player.id}`, false); + } + if (!db.get(`playerFirstJoined-${e.player.id}`)) { + db.set(`playerFirstJoined-${e.player.id}`, true); + const addonConfigItemType = ItemTypes.get(MyCustomItemTypes.AddonConfiguration); + e.player.runCommandAsync(`testfor @s[hasItem={item=${addonConfigItemType.id}}]`).then((result) => { + if (!result.successCount) { + const inventory = e.player.getComponent(EntityInventoryComponent.componentId).container.override(e.player); + inventory.giveItem(addonConfigItemType, 1, { + lore: [ + `§l${ADDON_NAME.toLowerCase().replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase())}` + ] + }); + } + else { + SendMessageTo(e.player, { rawtext: [ + { + translate: "yn:fishing_got_reel.already_has_item", + with: ["Angler's Desire Configuration"] + } + ] }); + } + }); + } if (!serverConfigurationCopy.ShowMessageUponJoin.defaultValue) return; SendMessageTo(e.player, { @@ -36,25 +61,6 @@ world.afterEvents.playerSpawn.subscribe((e) => { } ] }); - const addonConfigItemType = ItemTypes.get(MyCustomItemTypes.AddonConfiguration); - e.player.runCommandAsync(`testfor @s[hasItem={item=${addonConfigItemType.id}}]`).then((result) => { - if (!result.successCount) { - const inventory = e.player.getComponent(EntityInventoryComponent.componentId).container.override(e.player); - inventory.giveItem(addonConfigItemType, 1, { - lore: [ - `§l${ADDON_NAME.toLowerCase().replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase())}` - ] - }); - } - else { - SendMessageTo(e.player, { rawtext: [ - { - translate: "yn:fishing_got_reel.already_has_item", - with: ["Angler's Desire Configuration"] - } - ] }); - } - }); }); world.beforeEvents.itemUse.subscribe((event) => { const player = event.source; @@ -90,18 +96,6 @@ world.beforeEvents.itemUse.subscribe((event) => { }); }, 0); }); -world.afterEvents.weatherChange.subscribe((e) => { - if ([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather)) - db.set("WorldIsRaining", true); - else if (!([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather))) - db.set("WorldIsRaining", false); -}); -world.beforeEvents.weatherChange.subscribe((e) => { - if ([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather)) - db.set("WorldIsRaining", true); - else if (!([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather))) - db.set("WorldIsRaining", false); -}); system.afterEvents.scriptEventReceive.subscribe((event) => { if (event.sourceType !== ScriptEventSource.Entity) return; diff --git a/BP/scripts/overrides/dimension_override.js b/BP/scripts/overrides/dimension_override.js index e0c71d9..5232ac4 100644 --- a/BP/scripts/overrides/dimension_override.js +++ b/BP/scripts/overrides/dimension_override.js @@ -196,8 +196,11 @@ OverTakes(Dimension.prototype, { item.getComponent(ItemComponentTypes.Enchantable).addEnchantment(enchant); } } - if (entry?.toEntity && Boolean(EntityTypes.get(entry.toEntity) !== undefined)) { - item.asEntity = entry.toEntity; + if (entry?.toEntity) { + if (Boolean(EntityTypes.get(entry.toEntity) !== undefined)) + item.asEntity = entry.toEntity; + else + continue; } rollEntries.addEntry(item, entry.weight); } diff --git a/RP/manifest.json b/RP/manifest.json index 86bff8a..a6bbe50 100644 --- a/RP/manifest.json +++ b/RP/manifest.json @@ -1,13 +1,13 @@ { "format_version": 2, "header": { - "name": "Angler's Desire RP §8(1.0.1)", + "name": "Angler's Desire RP §8(1.1.0) [DEBUG]", "description": "Adding immersion to vanilla fishing mechanics in Minecraft \n @Made By: https://twitter.com/h_YanG_0A", "uuid": "54ee84f3-7b81-421c-8602-2d399940fd59", "version": [ 1, - 0, - 1 + 1, + 0 ], "min_engine_version": [ 1, @@ -21,8 +21,8 @@ "uuid": "a74c51a8-a015-4f9e-b55a-98aa2c38aff5", "version": [ 1, - 0, - 1 + 1, + 0 ] } ], diff --git a/setup/mc_manifest.json b/setup/mc_manifest.json index 0f65e71..9f99850 100644 --- a/setup/mc_manifest.json +++ b/setup/mc_manifest.json @@ -6,7 +6,7 @@ "description": "Adding immersion to vanilla fishing mechanics in Minecraft \n @Made By: https://twitter.com/h_YanG_0A", "bp_uuid": "f36713ae-a50d-4eae-ab09-14bef4e580ec", "rp_uuid": "54ee84f3-7b81-421c-8602-2d399940fd59", - "version": [1, 0, 1], + "version": [1, 1, 0], "min_engine_version": [ 1, 21, 0 ] }, "bp_modules": [ @@ -21,7 +21,7 @@ "type": "script", "language": "javascript", "uuid": "02a44d23-5962-4bb5-8a78-ef87d1eb0726", - "version": [ 1, 0, 1 ], + "version": [ 1, 1, 0 ], "entry": "scripts/main.js" } ], @@ -30,7 +30,7 @@ { "type": "resources", "uuid": "a74c51a8-a015-4f9e-b55a-98aa2c38aff5", - "version": [ 1, 0, 1 ] + "version": [ 1, 1, 0 ] } ], "bp_dependencies": [ diff --git a/src/.config_hashes b/src/.config_hashes index 184bd0a..ed4ec0e 100644 --- a/src/.config_hashes +++ b/src/.config_hashes @@ -1,3 +1,3 @@ 7f6594075fc8df6a8317b37e1e7ecf0f924be8e83e5c593f44e9e787133445db -0c97799487d342070965893349e0d16e2fd46970ff6f42efc006b6135e46e5db -0c97799487d342070965893349e0d16e2fd46970ff6f42efc006b6135e46e5db +b0bf929476f7d0385eed7acbec12f9050335f60e80ce4bd2e5bef22933ad34f2 +b0bf929476f7d0385eed7acbec12f9050335f60e80ce4bd2e5bef22933ad34f2 diff --git a/src/commands/dev_helper.ts b/src/commands/dev_helper.ts index b5f8e41..8bb6bf8 100644 --- a/src/commands/dev_helper.ts +++ b/src/commands/dev_helper.ts @@ -1,25 +1,28 @@ -import { Block, BlockTypes, EnchantmentTypes, EntityComponentTypes, EntityInventoryComponent, EquipmentSlot, ItemComponentTypes, ItemEnchantableComponent, ItemStack, MolangVariableMap, system } from "@minecraft/server"; +import { Block, BlockTypes, EnchantmentTypes, EntityComponentTypes, EntityInventoryComponent, EquipmentSlot, ItemComponentTypes, ItemEnchantableComponent, ItemStack, MolangVariableMap, system, world } from "@minecraft/server"; import { CommandHandler } from "commands/command_handler"; import { ICommandBase} from "./ICommandBase"; import { SendMessageTo, sleep} from "utils/utilities"; import { overrideEverything } from "overrides/index"; import { MinecraftBlockTypes, MinecraftEnchantmentTypes, MinecraftItemTypes } from "vanilla-types/index"; -import { CustomEnchantmentTypes, FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; import { AStarOptions } from "utils/NoxUtils/Pathfinder/AStarOptions"; import { BidirectionalAStar } from "utils/NoxUtils/Pathfinder/BidirectionalAStar"; import { AStar } from "utils/NoxUtils/Pathfinder/AStar"; -import { CustomEnchantment } from "custom_enchantment/custom_enchantment"; +import { FishingCustomEnchantmentType } from "custom_enchantment/available_custom_enchantments"; +import { TacosFishEntityTypes } from "fishing_system/entities/compatibility/tacos_fish_mobs"; +import { db, fetchFisher } from "constant"; overrideEverything(); // Automate this, the values should be the description. enum REQUIRED_PARAMETER { GET = "get", - TEST = "test", - RELOAD_INVENTORY = "reload", LOAD_OLD = "load_old", + RELOAD_INVENTORY = "reload", + UPDATE_ADDON = "update", + TEST = "test", PATHFIND_TEST = "pathfind", DAMAGE_TEST = "damage", PARTICLE_TEST = "particle", + TACO_FISH_TEST = "test_tacofish" } const command: ICommandBase = { @@ -34,8 +37,8 @@ const command: ICommandBase = { Usage: > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.GET} = GETS an enchanted fishing rod for development. > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.RELOAD_INVENTORY} = Reload the fishing rod's hook bug. - > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.DAMAGE_TEST} = Damages fishing rod hook usage. - > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.PARTICLE_TEST} = TEST a Working-in-progress particle. + > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.LOAD_OLD} = Loads the old custom dynamic property for fishing rod. For bug fixing purposes. It's chained with reload command after. + > ${CommandHandler.prefix}${this.name} ${REQUIRED_PARAMETER.UPDATE_ADDON} = Updates the addon to the latest, after deleting the old addon, and installing the new one. `).replaceAll(" ", ""); }, execute(player, args) { @@ -68,7 +71,31 @@ const command: ICommandBase = { (player.getComponent(EntityComponentTypes.Inventory) as EntityInventoryComponent).container.addItem(fishingRod); break; case REQUIRED_PARAMETER.TEST: - + break; + case REQUIRED_PARAMETER.UPDATE_ADDON: + if(db.has("WorldIsRaining")) db.delete("WorldIsRaining"); // Delete world dynamic property from v1.0.1 + world.sendMessage("§a§lAngler's Desire Addon's Scripts§r §ahas been updated successfully."); + break; + // Unit Test if all Taco's Fish is successfully implemented. + case REQUIRED_PARAMETER.TACO_FISH_TEST: + let successCount = 0; + system.run(async () => { + for(const tacoFishType of Object.values(TacosFishEntityTypes)) { + try { + const t = player.dimension.spawnEntity(tacoFishType, player.location); + await system.waitTicks(3); + t.kill(); + successCount++; + } catch (e) { + continue; + } + } + SendMessageTo(player, { + rawtext: [ + {text: `Success: ${successCount}\nTotal: ${(Object.values(TacosFishEntityTypes).length)}`} + ] + }); + }); break; case REQUIRED_PARAMETER.DAMAGE_TEST: if(!args[1].length) return; @@ -99,6 +126,13 @@ const command: ICommandBase = { } inventory.setItem(slot, fishingRod); } + SendMessageTo(player, { + rawtext: [ + { + text: "§a§lAngler's Desire§r §afishing hook enhancement bug located in your current inventory has been fully reloaded." + } + ] + }); break; case REQUIRED_PARAMETER.LOAD_OLD: fishingRod = player.equippedTool(EquipmentSlot.Mainhand); diff --git a/src/constant.ts b/src/constant.ts index fe20a3f..600716e 100644 --- a/src/constant.ts +++ b/src/constant.ts @@ -8,7 +8,7 @@ export const ADDON_IDENTIFIER: string = `${ADDON_NAMESPACE}:anglers`; export const db = new JsonDatabase(ADDON_NAME); export const localFishersCache: Map = new Map(); -export const spawnedLogMap: Map = new Map(); +export const onSpawnHookLogMap: Map = new Map(); export const onCaughtParticleLogMap: Map = new Map(); export const onLostParticleLogMap: Map = new Map(); diff --git a/src/custom_enchantment/available_custom_enchantments.ts b/src/custom_enchantment/available_custom_enchantments.ts new file mode 100644 index 0000000..a20f356 --- /dev/null +++ b/src/custom_enchantment/available_custom_enchantments.ts @@ -0,0 +1,65 @@ +import { MyCustomItemTypes } from "fishing_system/items/custom_items"; +import { CustomEnchantment } from "./custom_enchantment"; + +export class FishingCustomEnchantmentType { + // Please separate the constructor for custom enchantment used only for this class + // meanwhile 'from', is used to only get from this class, so constructors need to be completed + // while 'from' only need name, and level for maintainability purposes. + + // Also use localization for: Description + static get Nautilus(): CustomEnchantment { return new CustomEnchantment({ + icon: "textures/items/nautilus_hook", + id: "Nautilus", + itemID: MyCustomItemTypes.NautilusHook, + name: "Nautilus Hook", + description: "yn:fishing_got_reel.enchantments.nautilus.description", + lore: "yn:fishing_got_reel.enchantments.nautilus.lore", + level: 1, + maxUsage: 75, + conflicts: ["Pyroclasm Hook", "Fermented Hook"], + }); } + static get Luminous(): CustomEnchantment { return new CustomEnchantment({ + icon: "textures/items/luminous_siren_hook", + id: "Luminous", + itemID: MyCustomItemTypes.LuminousHook, + name: "Luminous Hook", + description: "yn:fishing_got_reel.enchantments.luminous.description", + lore: "yn:fishing_got_reel.enchantments.luminous.lore", + level: 1, + maxUsage: 54, + }); } + static get Pyroclasm(): CustomEnchantment { return new CustomEnchantment({ + icon: "textures/items/pyroclasm_hook", + id: "Pyroclasm", + itemID: MyCustomItemTypes.PyroclasmHook, + name: "Pyroclasm Hook", + description: "yn:fishing_got_reel.enchantments.pyroclasm.description", + lore: "yn:fishing_got_reel.enchantments.pyroclasm.lore", + level: 1, + maxUsage: 45, + conflicts: ["Nautilus Hook"], + }); } + static get Tempus(): CustomEnchantment { return new CustomEnchantment({ + icon: "textures/items/tempus_hook", + id: "Tempus", + itemID: MyCustomItemTypes.TempusHook, + name: "Tempus Hook", + description: "yn:fishing_got_reel.enchantments.tempus.description", + lore: "yn:fishing_got_reel.enchantments.tempus.lore", + level: 1, + maxUsage: 92, + }); } + static get FermentedEye(): CustomEnchantment { return new CustomEnchantment({ + icon: "textures/items/fermented_spider_eye_hook", + id: "FermentedEye", + itemID: MyCustomItemTypes.FermentedSpiderEyeHook, + name: "Fermented Hook", + description: "yn:fishing_got_reel.enchantments.fermentedeye.description", + lore: "yn:fishing_got_reel.enchantments.fermentedeye.lore", + level: 1, + maxUsage: 60, + conflicts: ["Nautilus Hook"], + }); } +} + +export type AvailableCustomEnchantments = Exclude; \ No newline at end of file diff --git a/src/custom_enchantment/custom_enchantment_types.ts b/src/custom_enchantment/custom_enchantment_types.ts index d90883c..bfa104e 100644 --- a/src/custom_enchantment/custom_enchantment_types.ts +++ b/src/custom_enchantment/custom_enchantment_types.ts @@ -1,67 +1,5 @@ -import { MyCustomItemTypes } from "fishing_system/items/custom_items"; +import { FishingCustomEnchantmentType } from "./available_custom_enchantments"; import { CustomEnchantment } from "./custom_enchantment"; -export class FishingCustomEnchantmentType { - // Please separate the constructor for custom enchantment used only for this class - // meanwhile 'from', is used to only get from this class, so constructors need to be completed - // while 'from' only need name, and level for maintainability purposes. - - // Also use localization for: Description - static get Nautilus(): CustomEnchantment { return new CustomEnchantment({ - icon: "textures/items/nautilus_hook", - id: "Nautilus", - itemID: MyCustomItemTypes.NautilusHook, - name: "Nautilus Hook", - description: "yn:fishing_got_reel.enchantments.nautilus.description", - lore: "yn:fishing_got_reel.enchantments.nautilus.lore", - level: 1, - maxUsage: 75, - conflicts: ["Pyroclasm Hook", "Fermented Hook"], - }); } - static get Luminous(): CustomEnchantment { return new CustomEnchantment({ - icon: "textures/items/luminous_siren_hook", - id: "Luminous", - itemID: MyCustomItemTypes.LuminousHook, - name: "Luminous Hook", - description: "yn:fishing_got_reel.enchantments.luminous.description", - lore: "yn:fishing_got_reel.enchantments.luminous.lore", - level: 1, - maxUsage: 54, - }); } - static get Pyroclasm(): CustomEnchantment { return new CustomEnchantment({ - icon: "textures/items/pyroclasm_hook", - id: "Pyroclasm", - itemID: MyCustomItemTypes.PyroclasmHook, - name: "Pyroclasm Hook", - description: "yn:fishing_got_reel.enchantments.pyroclasm.description", - lore: "yn:fishing_got_reel.enchantments.pyroclasm.lore", - level: 1, - maxUsage: 45, - conflicts: ["Nautilus Hook"], - }); } - static get Tempus(): CustomEnchantment { return new CustomEnchantment({ - icon: "textures/items/tempus_hook", - id: "Tempus", - itemID: MyCustomItemTypes.TempusHook, - name: "Tempus Hook", - description: "yn:fishing_got_reel.enchantments.tempus.description", - lore: "yn:fishing_got_reel.enchantments.tempus.lore", - level: 1, - maxUsage: 92, - }); } - static get FermentedEye(): CustomEnchantment { return new CustomEnchantment({ - icon: "textures/items/fermented_spider_eye_hook", - id: "FermentedEye", - itemID: MyCustomItemTypes.FermentedSpiderEyeHook, - name: "Fermented Hook", - description: "yn:fishing_got_reel.enchantments.fermentedeye.description", - lore: "yn:fishing_got_reel.enchantments.fermentedeye.lore", - level: 1, - maxUsage: 60, - conflicts: ["Nautilus Hook"], - }); } -} - - export class CustomEnchantmentTypes { private static CachedAvailableEnchantments: Array = []; private static CachedImplementedEnchantments: Set; @@ -93,6 +31,4 @@ export class CustomEnchantmentTypes { } return this.CachedImplementedEnchantments; } -} - -export type AvailableCustomEnchantments = Exclude; \ No newline at end of file +} \ No newline at end of file diff --git a/src/fishing_system/configuration/configuration_screen.ts b/src/fishing_system/configuration/configuration_screen.ts index a001631..6cb9d9e 100644 --- a/src/fishing_system/configuration/configuration_screen.ts +++ b/src/fishing_system/configuration/configuration_screen.ts @@ -8,11 +8,12 @@ import { Fisher } from "fishing_system/entities/fisher"; import { SendMessageTo } from "utils/index"; import { FormBuilder } from "utils/form_builder"; import { resetServerConfiguration, serverConfigurationCopy, setServerConfiguration } from "./server_configuration"; -import { CustomEnchantmentTypes, FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; +import { CustomEnchantmentTypes } from "custom_enchantment/custom_enchantment_types"; import { CustomEnchantment } from "custom_enchantment/custom_enchantment" import { MinecraftItemTypes } from "vanilla-types/index"; import { MyCustomItemTypes } from "fishing_system/items/custom_items"; import { ItemStackOptions } from "overrides/container_override"; +import { FishingCustomEnchantmentType } from "custom_enchantment/available_custom_enchantments"; type DisassembleFormContent = { key: string, diff --git a/src/fishing_system/configuration/server_configuration.ts b/src/fishing_system/configuration/server_configuration.ts index 392d41f..e01851a 100644 --- a/src/fishing_system/configuration/server_configuration.ts +++ b/src/fishing_system/configuration/server_configuration.ts @@ -25,7 +25,7 @@ export const serverConfiguration = { /** * Enables debug messages to content logs. */ - debug: new FormBuilder("Debug Mode").createToggle(false), + debug: new FormBuilder("Debug Mode").createToggle(true), }; export let serverConfigurationCopy = cloneConfiguration(serverConfiguration); @@ -33,4 +33,4 @@ export let setServerConfiguration = (newServerConfig) => serverConfigurationCopy export let resetServerConfiguration = () => serverConfigurationCopy = cloneConfiguration(serverConfiguration); // version (do not change) -export const VERSION = "1.0.1"; \ No newline at end of file +export const VERSION = "1.1.0"; \ No newline at end of file diff --git a/src/fishing_system/entities/compatibility/tacos_fish_mobs.ts b/src/fishing_system/entities/compatibility/tacos_fish_mobs.ts new file mode 100644 index 0000000..1ba2a63 --- /dev/null +++ b/src/fishing_system/entities/compatibility/tacos_fish_mobs.ts @@ -0,0 +1,109 @@ +export enum TacosFishEntityTypes { + // Common + Anchovy = "taco:anchovy", + Sardine = "taco:sardine", + Mackerel = "taco:mackerel", + Herring = "taco:herring", + Mullet = "taco:mullet", + Porgy = "taco:porgy", + Croaker = "taco:croaker", + Grunt = "taco:grunt", + Tarpon = "taco:tarpon", + Bluefish = "taco:bluefish", + Crevalle = "taco:crevalle", + Snook = "taco:snook", + Bumper = "taco:bumper", + Lookdown = "taco:lookdown", + Kahawai = "taco:kahawai", + Yellowtail = "taco:yellowtail", + Permit = "taco:permit", + Minnow = "taco:minnow", + Perch = "taco:perch", + Bluegill = "taco:bluegill", + Sunfish = "taco:sunfish", + Mooneye = "taco:mooneye", + Bass = "taco:bass", + Smelt = "taco:smelt", + Carp = "taco:carp", + Ide = "taco:ide", + Shad = "taco:shad", + Asp = "taco:asp", + Tilapia = "taco:tilapia", + Buffalo = "taco:buffalo", + Yellowfish = "taco:yellowfish", + Mojarra = "taco:mojarra", + Moggel = "taco:moggel", + Barramundi = "taco:barramundi", + + //Uncommon + Bonefish = "taco:bonefish", + Drum = "taco:drum", + Amberjack = "taco:amberjack", + Oilfish = "taco:oilfish", + Barracuda = "taco:barracuda", + Flounder = "taco:flounder", + Pomfret = "taco:pomfret", + Queenfish = "taco:queenfish", + Grouper = "taco:grouper", + Tuna = "taco:tuna", + Tripletail = "taco:tripletail", + Bonito = "taco:bonito", + MahiMahi = "taco:mahi_mahi", + Snapper = "taco:snapper", + Crappie = "taco:crappie", + Pumpkinseed = "taco:pumpkinseed", + Yellowbelly = "taco:yellowbelly", + Sauger = "taco:sauger", + Walleye = "taco:walleye", + Bowfin = "taco:bowfin", + Bream = "taco:bream", + Tench = "taco:tench", + Grayling = "taco:grayling", + Trout = "taco:trout", + Pike = "taco:pike", + Nelma = "taco:nelma", + Piranha = "taco:piranha", + Guapote = "taco:guapote", + Gar = "taco:gar", + Pavon = "taco:pavon", + Blackfish = "taco:blackfish", + Tambaqui = "taco:tambaqui", + + // Rare + Ladyfish = "taco:ladyfish", + Roosterfish = "taco:roosterfish", + Opah = "taco:opah", + Wahoo = "taco:wahoo", + Needlefish = "taco:needlefish", + Trevally = "taco:trevally", + Cobia = "taco:cobia", + Leerfish = "taco:leerfish", + Threadfin = "taco:threadfin", + Stonefish = "taco:stonefish", + Hogfish = "taco:hogfish", + Mola = "taco:mola", + Papermouth = "taco:papermouth", + Catfish = "taco:catfish", + Pickerel = "taco:pickerel", + Barbel = "taco:barbel", + Sturgeon = "taco:sturgeon", + Stringfish = "taco:stringfish", + Knifefish = "taco:knifefish", + Arowana = "taco:arowana", + Mahseer = "taco:mahseer", + Paddlefish = "taco:paddlefish", + + // Very Rare + Anglerfish = "taco:anglerfish", + Coelacanth = "taco:coelacanth", + Pompano = "taco:pompano", + Marlin = "taco:marlin", + Lionfish = "taco:lionfish", + Oarfish = "taco:oarfish", + Warmouth = "taco:warmouth", + Muskie = "taco:muskie", + Burbot = "taco:burbot", + Mandarin = "taco:mandarin", + DollyVarden = "taco:dolly_varden", + Arapaima = "taco:arapaima", +} \ No newline at end of file diff --git a/src/fishing_system/entities/fisher.ts b/src/fishing_system/entities/fisher.ts index 05b9a55..40e4d6b 100644 --- a/src/fishing_system/entities/fisher.ts +++ b/src/fishing_system/entities/fisher.ts @@ -57,6 +57,7 @@ class Fisher { currentBiomeLootTable: Array = Object.getOwnPropertyNames(LootTable).filter(prop => !['name', 'prototype', 'length', 'fishingModifier'].includes(prop)); currentBiome: number = 0; + currentWeather: number = 0; canBeReeled: boolean = false; diff --git a/src/fishing_system/events/on_hook_created.ts b/src/fishing_system/events/on_hook_created.ts index 7fa306d..248217b 100644 --- a/src/fishing_system/events/on_hook_created.ts +++ b/src/fishing_system/events/on_hook_created.ts @@ -1,17 +1,18 @@ import { Entity } from "@minecraft/server"; -import { spawnedLogMap, localFishersCache } from "constant"; +import { onSpawnHookLogMap, localFishersCache } from "constant"; import { Fisher } from "fishing_system/entities/fisher"; import { onHookLanded } from "./on_wait_hook_stablized"; export function onFishingHookCreated(entitySpawned: Entity, fisher: Fisher): void { if (entitySpawned.typeId !== "minecraft:fishing_hook") return; const player = fisher.source; - const oldLog = spawnedLogMap.get(player.id) as number; - spawnedLogMap.set(player.id, Date.now()); + const oldLog = onSpawnHookLogMap.get(player.id) as number; + onSpawnHookLogMap.set(player.id, Date.now()); if ((oldLog + 150) >= Date.now()) return; localFishersCache.set(player.id, fisher.reset()); fisher.setFishingHook(entitySpawned); fisher.currentBiome = fisher.fishingHook.getProperty("yn:current_biome_bit") as number; + fisher.currentWeather = fisher.fishingHook.getProperty("yn:current_weather_bit") as number; localFishersCache.set(player.id, fisher); onHookLanded(player); } \ No newline at end of file diff --git a/src/fishing_system/items/fishing_rod.ts b/src/fishing_system/items/fishing_rod.ts index c37a690..ca63809 100644 --- a/src/fishing_system/items/fishing_rod.ts +++ b/src/fishing_system/items/fishing_rod.ts @@ -3,7 +3,6 @@ import { EntityEquippableComponent, EquipmentSlot } from "@minecraft/server"; import { MinecraftEnchantmentTypes, MinecraftItemTypes} from "vanilla-types/index"; import { OverTakes } from "overrides/partial_overtakes"; import { HookUpgrades } from "fishing_system/upgrades/upgrades"; -import { FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; declare module "@minecraft/server" { interface EntityEquippableComponent { diff --git a/src/fishing_system/loot_tables/ParentCatch.ts b/src/fishing_system/loot_tables/biome_catch_helper.ts similarity index 82% rename from src/fishing_system/loot_tables/ParentCatch.ts rename to src/fishing_system/loot_tables/biome_catch_helper.ts index f604c8e..3e8828d 100644 --- a/src/fishing_system/loot_tables/ParentCatch.ts +++ b/src/fishing_system/loot_tables/biome_catch_helper.ts @@ -1,10 +1,10 @@ import { world } from "@minecraft/server"; -import { HookUpgrades } from "fishing_system/upgrades/upgrades"; import { EntryContent } from "types"; import { EntityLootResult } from "./biomes/types"; +import { Fisher } from "fishing_system/entities/fisher"; export class ParentCatchLoot { - protected static upgrade: HookUpgrades; + protected static fisher: Fisher; protected static RAIN_INCREASED_CHANCE: number = 150; protected static LuminousLoots: EntryContent[]; @@ -13,14 +13,14 @@ export class ParentCatchLoot { protected static FilteredEntityEntry(): EntryContent[] { const rainChanceModifier = this.RAIN_INCREASED_CHANCE / 100; - const isRaining = world.IsRaining; + const isRaining = this.fisher.currentWeather > 0; // Calculate the total weight of GeneralLoots const totalGeneralWeight = this.GeneralLoots.reduce((sum, loot) => sum + loot.weight, 0); // Determine the additional weight added by special loots const additionalLoots = [ - ...(this.upgrade.has("Luminous") ? this.LuminousLoots : []), + ...(this.fisher.fishingRod.upgrade.has("Luminous") ? this.LuminousLoots : []), ...(isRaining ? this.SpecialRainLoots : []) ]; @@ -51,11 +51,11 @@ export class ParentCatchLoot { return BlendedLoots; } - protected static initializeAttributes(upgrade: HookUpgrades, RAIN_INCREASE: number, entityLoots: EntityLootResult) { + protected static initializeAttributes(fisher: Fisher, RAIN_INCREASE: number, entityLoots: EntityLootResult) { this.GeneralLoots = entityLoots.GeneralLoots; this.SpecialRainLoots = entityLoots.SpecialRainLoots; this.LuminousLoots = entityLoots.LuminousLoots; this.RAIN_INCREASED_CHANCE = RAIN_INCREASE; - this.upgrade = upgrade; + this.fisher = fisher; } } \ No newline at end of file diff --git a/src/fishing_system/loot_tables/biomes/DefaultCatch.ts b/src/fishing_system/loot_tables/biomes/DefaultCatch.ts index 108e813..2e1e42b 100644 --- a/src/fishing_system/loot_tables/biomes/DefaultCatch.ts +++ b/src/fishing_system/loot_tables/biomes/DefaultCatch.ts @@ -2,12 +2,15 @@ import { LootTableContent } from "types/loot_table_type"; import { MinecraftItemTypes } from "vanilla-types/index"; import { EntityLootResult, ModifierResult } from "./types"; import { HookUpgrades } from "fishing_system/upgrades/upgrades"; -import { ParentCatchLoot } from "../ParentCatch"; +import { ParentCatchLoot } from "../biome_catch_helper"; import { MyCustomItemTypes } from "fishing_system/items/custom_items"; +import { Entity } from "@minecraft/server"; +import { Fisher } from "fishing_system/entities/fisher"; export class DefaultCatch extends ParentCatchLoot { - static Loot (modifier: ModifierResult, upgrade: HookUpgrades, entityLoots: EntityLootResult, RAIN_INCREASE: number = 150): LootTableContent { - this.initializeAttributes(upgrade, RAIN_INCREASE, entityLoots); + static Loot (modifier: ModifierResult, fisher: Fisher, entityLoots: EntityLootResult, RAIN_INCREASE: number = 150): LootTableContent { + const upgrade: HookUpgrades = fisher.fishingRod.upgrade; + this.initializeAttributes(fisher, RAIN_INCREASE, entityLoots); const fishWeight = ((85 - (modifier.LoTSModifier * 0.15)) - (modifier.deepnessModifier / 1.5)) * (upgrade.has("Nautilus") ? 0 : 1); const junkWeight = ((10 - (modifier.LoTSModifier * 1.95)) + (modifier.deepnessModifier / 2)) + (upgrade.has("Nautilus") ? 50 : 0); const treasureWeight = ((5 + (modifier.LoTSModifier * 2.1)) + modifier.deepnessModifier) + (upgrade.has("Nautilus") ? 15 : 0); diff --git a/src/fishing_system/loot_tables/biomes/JungleCatch.ts b/src/fishing_system/loot_tables/biomes/JungleCatch.ts index 5112029..0eda585 100644 --- a/src/fishing_system/loot_tables/biomes/JungleCatch.ts +++ b/src/fishing_system/loot_tables/biomes/JungleCatch.ts @@ -3,11 +3,13 @@ import { MinecraftEntityTypes, MinecraftItemTypes } from "vanilla-types/index"; import { EntityLootResult, ModifierResult } from "./types"; import { HookUpgrades } from "fishing_system/upgrades/upgrades"; import { world } from "@minecraft/server"; -import { ParentCatchLoot } from "../ParentCatch"; +import { ParentCatchLoot } from "../biome_catch_helper"; +import { Fisher } from "fishing_system/entities/fisher"; export class JungleCatch extends ParentCatchLoot{ - static Loot (modifier: ModifierResult, upgrade: HookUpgrades, entityLoots: EntityLootResult, RAIN_INCREASE: number = 150): LootTableContent { - this.initializeAttributes(upgrade, RAIN_INCREASE, entityLoots); + static Loot (modifier: ModifierResult, fisher: Fisher, entityLoots: EntityLootResult, RAIN_INCREASE: number = 150): LootTableContent { + const upgrade: HookUpgrades = fisher.fishingRod.upgrade; + this.initializeAttributes(fisher, RAIN_INCREASE, entityLoots); const fishWeight = ((85 - (modifier.LoTSModifier * 0.15)) - (modifier.deepnessModifier / 1.5)) * (upgrade.has("Nautilus") ? 0 : 1); const junkWeight = ((10 - (modifier.LoTSModifier * 1.95)) + (modifier.deepnessModifier / 2)) + (upgrade.has("Nautilus") ? 50 : 0); const treasureWeight = ((5 + (modifier.LoTSModifier * 2.1)) + modifier.deepnessModifier) + (upgrade.has("Nautilus") ? 15 : 0); diff --git a/src/fishing_system/loot_tables/biomes/OceanCatch.ts b/src/fishing_system/loot_tables/biomes/OceanCatch.ts index 1af66b0..2169e6c 100644 --- a/src/fishing_system/loot_tables/biomes/OceanCatch.ts +++ b/src/fishing_system/loot_tables/biomes/OceanCatch.ts @@ -2,12 +2,14 @@ import { LootTableContent } from "types/loot_table_type"; import { MinecraftItemTypes } from "vanilla-types/index"; import { EntityLootResult, ModifierResult } from "./types"; import { HookUpgrades } from "fishing_system/upgrades/upgrades"; -import { ParentCatchLoot } from "../ParentCatch"; +import { ParentCatchLoot } from "../biome_catch_helper"; import { MyCustomItemTypes } from "fishing_system/items/custom_items"; +import { Fisher } from "fishing_system/entities/fisher"; export class OceanCatch extends ParentCatchLoot { - static Loot (modifier: ModifierResult, upgrade: HookUpgrades, entityLoots: EntityLootResult, RAIN_INCREASE: number = 150): LootTableContent { - this.initializeAttributes(upgrade, RAIN_INCREASE, entityLoots); + static Loot (modifier: ModifierResult, fisher: Fisher, entityLoots: EntityLootResult, RAIN_INCREASE: number = 150): LootTableContent { + const upgrade: HookUpgrades = fisher.fishingRod.upgrade; + this.initializeAttributes(fisher, RAIN_INCREASE, entityLoots); const fishWeight = ((85 - (modifier.LoTSModifier * 0.15)) - (modifier.deepnessModifier / 1.5)) * (upgrade.has("Nautilus") ? 0 : 1); const junkWeight = ((10 - (modifier.LoTSModifier * 1.95)) + (modifier.deepnessModifier / 2)) + (upgrade.has("Nautilus") ? 50 : 0); const treasureWeight = ((5 + (modifier.LoTSModifier * 2.1)) + modifier.deepnessModifier) + (upgrade.has("Nautilus") ? 15 : 0); diff --git a/src/fishing_system/loot_tables/biomes/types.ts b/src/fishing_system/loot_tables/biomes/types.ts index c9e5736..477def6 100644 --- a/src/fishing_system/loot_tables/biomes/types.ts +++ b/src/fishing_system/loot_tables/biomes/types.ts @@ -9,4 +9,5 @@ export type EntityLootResult = { GeneralLoots: EntryContent[], SpecialRainLoots: EntryContent[], LuminousLoots: EntryContent[], + TacoFishLoots?: EntryContent[] } \ No newline at end of file diff --git a/src/fishing_system/loot_tables/compatible_loot_manager.ts b/src/fishing_system/loot_tables/compatible_loot_manager.ts new file mode 100644 index 0000000..af14ab0 --- /dev/null +++ b/src/fishing_system/loot_tables/compatible_loot_manager.ts @@ -0,0 +1,22 @@ +import { ItemTypes } from "@minecraft/server"; + +// Core items are used to check if certain addon exists. +class CompatibilityLootManager { + static get TacosFish() { + return ItemTypes.get('taco:catfish'); + } +} + +export class CompatibleAddonHandler { + private static getAll(): string[] { + const allAvailableCompatibleAddons = Object.getOwnPropertyNames(CompatibilityLootManager).filter((prop) => !(['length', 'name', 'prototype'].includes(prop))); + return allAvailableCompatibleAddons; + } + + // Check if other addon, which is compatible with this addon is installed in the current world. + static isInstalled(addonCompatibilityName: AvailableCompatibleAddon): boolean { + return CompatibilityLootManager[addonCompatibilityName] !== undefined; + } +} + +type AvailableCompatibleAddon = Exclude; \ No newline at end of file diff --git a/src/fishing_system/loot_tables/loot_tables.ts b/src/fishing_system/loot_tables/loot_tables.ts index 34b7de4..8fad2c1 100644 --- a/src/fishing_system/loot_tables/loot_tables.ts +++ b/src/fishing_system/loot_tables/loot_tables.ts @@ -3,7 +3,9 @@ import { JungleCatch, DefaultCatch } from "./index"; import { HookUpgrades } from "fishing_system/upgrades/upgrades"; import { MinecraftEntityTypes, MinecraftItemTypes } from "vanilla-types/index"; import { OceanCatch } from "./biomes/OceanCatch"; -import { MyCustomEntityTypes } from "fishing_system/entities/custom_mobs"; +import { CompatibleAddonHandler } from "./compatible_loot_manager"; +import { TacosFishEntityTypes } from "fishing_system/entities/compatibility/tacos_fish_mobs"; +import { Fisher } from "fishing_system/entities/fisher"; export class LootTable { @@ -12,8 +14,8 @@ export class LootTable { return {LoTSModifier: LoTSLevel, deepnessModifier: deepTreasureModifier}; } // 0 - static Anywhere(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Anywhere(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -49,8 +51,8 @@ export class LootTable { } // 1 - static Jungle(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return JungleCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Jungle(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return JungleCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -86,8 +88,8 @@ export class LootTable { } // 2 - static Ocean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Ocean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -128,8 +130,8 @@ export class LootTable { } // 3 - static DeepOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -170,8 +172,8 @@ export class LootTable { } // 4 - static FrozenOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static FrozenOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -212,8 +214,8 @@ export class LootTable { } // 5 - static DeepFrozenOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepFrozenOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -254,8 +256,8 @@ export class LootTable { } // 6 - static ColdOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static ColdOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -296,8 +298,8 @@ export class LootTable { } // 7 - static DeepColdOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepColdOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -333,8 +335,8 @@ export class LootTable { } // 8 - static Lukewarm(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static Lukewarm(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -380,8 +382,8 @@ export class LootTable { } // 9 - static DeepLukewarm(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static DeepLukewarm(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return OceanCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -432,8 +434,8 @@ export class LootTable { } // 10 - static WarmOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static WarmOcean(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Cod, @@ -479,8 +481,8 @@ export class LootTable { } // 11 - static MangroveSwamp(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static MangroveSwamp(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Air, @@ -516,8 +518,8 @@ export class LootTable { } // 12 - static LushCave(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, upgrade: HookUpgrades): LootTableContent { - return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), upgrade, { + static LushCave(level: RangeInternal<0, 4>, isDeeplySubmerged: boolean = false, fisher: Fisher): LootTableContent { + return DefaultCatch.Loot( this.fishingModifier(level, isDeeplySubmerged), fisher, { GeneralLoots: [ { "item": MinecraftItemTypes.Air, diff --git a/src/fishing_system/upgrades/upgrades.ts b/src/fishing_system/upgrades/upgrades.ts index 13e7671..20ea902 100644 --- a/src/fishing_system/upgrades/upgrades.ts +++ b/src/fishing_system/upgrades/upgrades.ts @@ -2,7 +2,7 @@ import { ItemEnchantableComponent, ItemStack } from "@minecraft/server"; -import { AvailableCustomEnchantments, FishingCustomEnchantmentType } from "custom_enchantment/custom_enchantment_types"; +import { AvailableCustomEnchantments, FishingCustomEnchantmentType } from "custom_enchantment/available_custom_enchantments"; import { overrideEverything } from "overrides/index"; overrideEverything() diff --git a/src/main.ts b/src/main.ts index 2982e09..36243ab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import { world, system, Player, ScriptEventCommandMessageAfterEvent, ScriptEventSource, WeatherType, EntityInventoryComponent, EquipmentSlot, ItemTypes, ItemStack} from "@minecraft/server"; -import { ADDON_IDENTIFIER, ADDON_NAME, db, fetchFisher, onCustomBlockInteractLogMap } from "./constant"; +import { ADDON_IDENTIFIER, ADDON_NAME, db, fetchFisher, onCustomBlockInteractLogMap} from "./constant"; import { onFishingHookCreated } from "./fishing_system/events/on_hook_created"; import { Fisher } from "./fishing_system/entities/fisher"; @@ -28,6 +28,30 @@ world.beforeEvents.worldInitialize.subscribe((e) => { world.afterEvents.playerSpawn.subscribe((e) => { if(!e.initialSpawn) return; + if(!db.has(`playerFirstJoined-${e.player.id}`)) { + db.set(`playerFirstJoined-${e.player.id}`, false); + } + if(!db.get(`playerFirstJoined-${e.player.id}`)) { + db.set(`playerFirstJoined-${e.player.id}`, true); + const addonConfigItemType = ItemTypes.get(MyCustomItemTypes.AddonConfiguration); + e.player.runCommandAsync(`testfor @s[hasItem={item=${addonConfigItemType.id}}]`).then((result) => { + if(!result.successCount) { + const inventory = (e.player.getComponent(EntityInventoryComponent.componentId) as EntityInventoryComponent).container.override(e.player); + inventory.giveItem(addonConfigItemType, 1, { + lore: [ + `§l${ADDON_NAME.toLowerCase().replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase())}` + ] + } as ItemStackOptions); + } else { + SendMessageTo(e.player, {rawtext: [ + { + translate: "yn:fishing_got_reel.already_has_item", + with: ["Angler's Desire Configuration"] + } + ]}); + } + }); + } if(!serverConfigurationCopy.ShowMessageUponJoin.defaultValue) return; SendMessageTo(e.player, { rawtext: [ @@ -36,24 +60,6 @@ world.afterEvents.playerSpawn.subscribe((e) => { } ] }); - const addonConfigItemType = ItemTypes.get(MyCustomItemTypes.AddonConfiguration); - e.player.runCommandAsync(`testfor @s[hasItem={item=${addonConfigItemType.id}}]`).then((result) => { - if(!result.successCount) { - const inventory = (e.player.getComponent(EntityInventoryComponent.componentId) as EntityInventoryComponent).container.override(e.player); - inventory.giveItem(addonConfigItemType, 1, { - lore: [ - `§l${ADDON_NAME.toLowerCase().replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase())}` - ] - } as ItemStackOptions); - } else { - SendMessageTo(e.player, {rawtext: [ - { - translate: "yn:fishing_got_reel.already_has_item", - with: ["Angler's Desire Configuration"] - } - ]}); - } - }); }); world.beforeEvents.itemUse.subscribe((event) => { @@ -90,16 +96,6 @@ world.beforeEvents.itemUse.subscribe((event) => { }, 0); }); -world.afterEvents.weatherChange.subscribe((e) => { - if([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather)) db.set("WorldIsRaining", true); - else if(!([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather))) db.set("WorldIsRaining", false); -}); - -world.beforeEvents.weatherChange.subscribe((e) => { - if([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather)) db.set("WorldIsRaining", true); - else if(!([WeatherType.Rain, WeatherType.Thunder].includes(e.newWeather))) db.set("WorldIsRaining", false); -}); - system.afterEvents.scriptEventReceive.subscribe((event: ScriptEventCommandMessageAfterEvent) => { if(event.sourceType !== ScriptEventSource.Entity) return; if(!(event.sourceEntity instanceof Player)) return; diff --git a/src/overrides/dimension_override.ts b/src/overrides/dimension_override.ts index 30325e5..cb402d6 100644 --- a/src/overrides/dimension_override.ts +++ b/src/overrides/dimension_override.ts @@ -216,9 +216,22 @@ OverTakes(Dimension.prototype, { } // check if it's summonable - if(entry?.toEntity && Boolean(EntityTypes.get(entry.toEntity) !== undefined)) { - item.asEntity = entry.toEntity; - } + if(entry?.toEntity) { + /* Plan: + !Not Implemented Yet: + - Make if it's missing something from all the entries, just make sure the total weight sums to 100 + Like if there are missing entry, from the total weights, since some entities are not existing + just make it sum the total weight to 100. + */ + + /** Current Implementation + Just create different fish loot tables for other compatibility stuffs. + In the long term, if the above is implemented, then just delete those temporary solution. + */ + + if(Boolean(EntityTypes.get(entry.toEntity) !== undefined)) item.asEntity = entry.toEntity; + else continue; + } // Spawns the item at the specified location. rollEntries.addEntry(item, entry.weight);