diff --git a/assets/behavior_pack/entities/terminator.json b/assets/behavior_pack/entities/terminator.json index b147104..a54d71b 100644 --- a/assets/behavior_pack/entities/terminator.json +++ b/assets/behavior_pack/entities/terminator.json @@ -45,6 +45,12 @@ "client_sync": true, "type": "bool", "default": false + }, + "terminator:cape": { + "client_sync": true, + "type": "int", + "default": 0, + "range": [0, 10] } } }, @@ -2594,6 +2600,9 @@ "minecraft:melee_attack", "terminator:break_blocks.v2" ] + }, + "set_property": { + "terminator:cape": "math.random_integer(0, 10)" } }, "minecraft:gain_bad_omen": { diff --git a/assets/resource_pack/attachables/elytra.json b/assets/resource_pack/attachables/elytra.json index afc0566..5492c8a 100644 --- a/assets/resource_pack/attachables/elytra.json +++ b/assets/resource_pack/attachables/elytra.json @@ -9,8 +9,18 @@ }, "textures": { "default": "textures/models/armor/elytra", - "cape": "textures/cape_custom", - "enchanted": "textures/misc/enchanted_item_glint" + "enchanted": "textures/misc/enchanted_item_glint", + "cape": "textures/entity/cape_invisible", + "cape_15th_anniv": "textures/entity/cape_15th_anniv", + "cape_cherry": "textures/entity/cape_cherry", + "cape_founder": "textures/entity/cape_founder", + "cape_migrator": "textures/entity/cape_migrator", + "cape_mojang_new": "textures/entity/cape_mojang_new", + "cape_pan": "textures/entity/cape_pan", + "cape_pride": "textures/entity/cape_pride", + "cape_tiktok": "textures/entity/cape_tiktok", + "cape_twitch": "textures/entity/cape_twitch", + "cape_vanilla": "textures/entity/cape_vanilla" }, "geometry": { "default": "geometry.elytra" @@ -25,11 +35,9 @@ }, "scripts": { "parent_setup": "variable.chest_layer_visible = 0.0;", - "animate": [ - "default_controller" - ] + "animate": ["default_controller"] }, - "render_controllers": [ "controller.render.elytra" ] + "render_controllers": ["controller.render.terminator.elytra"] } } } diff --git a/assets/resource_pack/entity/terminator.entity.json b/assets/resource_pack/entity/terminator.entity.json index 5b5dcea..c3d4031 100644 --- a/assets/resource_pack/entity/terminator.entity.json +++ b/assets/resource_pack/entity/terminator.entity.json @@ -22,8 +22,17 @@ "alex_xmas": "textures/entity/terminator/alex_xmas", "custom": "textures/entity/steve", "customSlim": "textures/entity/alex", - "cape_default": "textures/entity/cape_invisible", - "cape": "textures/entity/cape_custom" + "cape": "textures/entity/cape_invisible", + "cape_15th_anniv": "textures/entity/cape_15th_anniv", + "cape_cherry": "textures/entity/cape_cherry", + "cape_founder": "textures/entity/cape_founder", + "cape_migrator": "textures/entity/cape_migrator", + "cape_mojang_new": "textures/entity/cape_mojang_new", + "cape_pan": "textures/entity/cape_pan", + "cape_pride": "textures/entity/cape_pride", + "cape_tiktok": "textures/entity/cape_tiktok", + "cape_twitch": "textures/entity/cape_twitch", + "cape_vanilla": "textures/entity/cape_vanilla" }, "geometry": { "default": "geometry.terminator", @@ -127,7 +136,7 @@ }, "render_controllers": [ "controller.render.terminator", - "controller.render.player.cape" + "controller.render.terminator.cape" ], "enable_attachables": true } diff --git a/assets/resource_pack/render_controllers/cape.render_controllers.json b/assets/resource_pack/render_controllers/cape.render_controllers.json index 296e2d2..09a5595 100644 --- a/assets/resource_pack/render_controllers/cape.render_controllers.json +++ b/assets/resource_pack/render_controllers/cape.render_controllers.json @@ -1,13 +1,28 @@ { "format_version": "1.10.0", "render_controllers": { - "controller.render.player.cape": { + "controller.render.terminator.cape": { + "arrays": { + "textures": { + "Array.capes": [ + "Texture.cape", + "Texture.cape_15th_anniv", + "Texture.cape_cherry", + "Texture.cape_founder", + "Texture.cape_migrator", + "Texture.cape_mojang_new", + "Texture.cape_pan", + "Texture.cape_pride", + "Texture.cape_tiktok", + "Texture.cape_twitch", + "Texture.cape_vanilla" + ] + } + }, "geometry": "Geometry.cape", - "materials": [ { "*": "Material.cape" } ], - "textures": [ "Texture.cape" ], - "part_visibility": [ - { "cape": "query.armor_texture_slot(1) != 5" } - ] + "materials": [{ "*": "Material.cape" }], + "textures": ["Array.capes[query.property('terminator:cape')]"], + "part_visibility": [{ "cape": "query.armor_texture_slot(1) != 5" }] } } -} \ No newline at end of file +} diff --git a/assets/resource_pack/render_controllers/elytra.render_controllers.json b/assets/resource_pack/render_controllers/elytra.render_controllers.json index 062748f..9f90d82 100644 --- a/assets/resource_pack/render_controllers/elytra.render_controllers.json +++ b/assets/resource_pack/render_controllers/elytra.render_controllers.json @@ -1,13 +1,40 @@ { "format_version": "1.8.0", "render_controllers": { - "controller.render.elytra": { + "controller.render.terminator.elytra": { "geometry": "Geometry.default", - "materials": [ { "*": "variable.is_enchanted ? Material.enchanted : Material.default" } ], - "textures": [ "Texture.default", "Texture.cape", "Texture.enchanted" ], + "arrays": { + "textures": { + "Array.capes": [ + "Texture.cape", + "Texture.cape_15th_anniv", + "Texture.cape_cherry", + "Texture.cape_founder", + "Texture.cape_migrator", + "Texture.cape_mojang_new", + "Texture.cape_pan", + "Texture.cape_pride", + "Texture.cape_tiktok", + "Texture.cape_twitch", + "Texture.cape_vanilla" + ] + } + }, + "materials": [ + { "*": "variable.is_enchanted ? Material.enchanted : Material.default" } + ], + "textures": [ + "Texture.default", + "Array.capes[(query.has_property('terminator:cape') ? query.property('terminator:cape') : 0)]", + "Texture.enchanted" + ], "part_visibility": [ - { "cape": "query.armor_texture_slot(1) == 5 && query.has_cape" }, - { "default": "query.armor_texture_slot(1) == 5 && !query.has_cape" } + { + "cape": "query.armor_texture_slot(1) == 5 && (query.has_cape || query.property('terminator:cape') != 0)" + }, + { + "default": "query.armor_texture_slot(1) == 5 && (!query.has_cape || query.property('terminator:cape') == 0)" + } ] } } diff --git a/assets/resource_pack/textures/entity/cape_15th_anniv.png b/assets/resource_pack/textures/entity/cape_15th_anniv.png new file mode 100644 index 0000000..c9e0299 Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_15th_anniv.png differ diff --git a/assets/resource_pack/textures/entity/cape_cherry.png b/assets/resource_pack/textures/entity/cape_cherry.png new file mode 100644 index 0000000..647fbd9 Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_cherry.png differ diff --git a/assets/resource_pack/textures/entity/cape_founder.png b/assets/resource_pack/textures/entity/cape_founder.png new file mode 100644 index 0000000..21d8da5 Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_founder.png differ diff --git a/assets/resource_pack/textures/entity/cape_custom.png b/assets/resource_pack/textures/entity/cape_migrator.png similarity index 100% rename from assets/resource_pack/textures/entity/cape_custom.png rename to assets/resource_pack/textures/entity/cape_migrator.png diff --git a/assets/resource_pack/textures/entity/cape_mojang_new.png b/assets/resource_pack/textures/entity/cape_mojang_new.png new file mode 100644 index 0000000..4847f1d Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_mojang_new.png differ diff --git a/assets/resource_pack/textures/entity/cape_pan.png b/assets/resource_pack/textures/entity/cape_pan.png new file mode 100644 index 0000000..327d2ea Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_pan.png differ diff --git a/assets/resource_pack/textures/entity/cape_pride.png b/assets/resource_pack/textures/entity/cape_pride.png new file mode 100644 index 0000000..e139b72 Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_pride.png differ diff --git a/assets/resource_pack/textures/entity/cape_tiktok.png b/assets/resource_pack/textures/entity/cape_tiktok.png new file mode 100644 index 0000000..a420dca Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_tiktok.png differ diff --git a/assets/resource_pack/textures/entity/cape_twitch.png b/assets/resource_pack/textures/entity/cape_twitch.png new file mode 100644 index 0000000..c4f18a3 Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_twitch.png differ diff --git a/assets/resource_pack/textures/entity/cape_vanilla.png b/assets/resource_pack/textures/entity/cape_vanilla.png new file mode 100644 index 0000000..9a3c129 Binary files /dev/null and b/assets/resource_pack/textures/entity/cape_vanilla.png differ diff --git a/assets/resource_pack/textures/entity/terminator/alex_default.pdn b/assets/skins/alex_default.pdn similarity index 100% rename from assets/resource_pack/textures/entity/terminator/alex_default.pdn rename to assets/skins/alex_default.pdn diff --git a/assets/resource_pack/textures/entity/terminator/alex_xmas.pdn b/assets/skins/alex_xmas.pdn similarity index 100% rename from assets/resource_pack/textures/entity/terminator/alex_xmas.pdn rename to assets/skins/alex_xmas.pdn diff --git a/assets/resource_pack/textures/entity/terminator/steve_default.pdn b/assets/skins/steve_default.pdn similarity index 100% rename from assets/resource_pack/textures/entity/terminator/steve_default.pdn rename to assets/skins/steve_default.pdn diff --git a/assets/resource_pack/textures/entity/terminator/steve_xmas.pdn b/assets/skins/steve_xmas.pdn similarity index 100% rename from assets/resource_pack/textures/entity/terminator/steve_xmas.pdn rename to assets/skins/steve_xmas.pdn diff --git a/src/commands/index.ts b/src/commands/index.ts index 4f947e9..d4174c7 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -6,6 +6,7 @@ import { TerminatorSkinModel, } from "./summon.js"; import { debugEnabled } from "../config.js"; +import { CapeVariant, CapeVariants } from "../terminator/capeVariant.js"; function generateModalForm(settings: TerminatorInputParam) { let skinModelIndex = 0; @@ -40,7 +41,8 @@ function generateModalForm(settings: TerminatorInputParam) { .toggle("Enable Physics", settings.physics) .toggle("Enable Regeneration", settings.regeneration) .toggle("Enable Respawn", settings.respawn) - .toggle("Enable Breedability", settings.breedable); + .toggle("Enable Breedability", settings.breedable) + .dropdown("Cape", CapeVariants, settings.cape); } /** @@ -82,7 +84,8 @@ type TerminatorSpawnFormValues = [ boolean, // physics boolean, // regeneration boolean, // respawn - boolean // breedable + boolean, // breedable + number // cape ]; const getDefaultSpawnOptions = (player: Player): TerminatorInputParam => ({ @@ -97,6 +100,7 @@ const getDefaultSpawnOptions = (player: Player): TerminatorInputParam => ({ breedable: false, coords: player.location, skinmodel: TerminatorSkinModel.Steve, + cape: CapeVariant.None, }); function getPlayerSpawnOptions(player: Player): TerminatorInputParam { @@ -131,6 +135,7 @@ export function showSpawnTerminatorForm(player: Player) { regeneration, respawn, breedable, + cape, ] = result.formValues as TerminatorSpawnFormValues; let skinmodel: TerminatorSkinModel = TerminatorSkinModel.Steve; switch (skinModelIndex) { @@ -159,7 +164,8 @@ export function showSpawnTerminatorForm(player: Player) { respawn: respawn, breedable: breedable, coords: parseCoordinates(locationString, player.location), - skinmodel, + skinmodel: skinmodel, + cape: cape, }; spawnTerminator(jsonInput, player); }) diff --git a/src/commands/summon.ts b/src/commands/summon.ts index fe0f7a8..8f29036 100644 --- a/src/commands/summon.ts +++ b/src/commands/summon.ts @@ -1,5 +1,6 @@ import { Player, Vector3, system } from "@minecraft/server"; import { debugEnabled } from "../config"; +import { CapeVariant } from "../terminator/capeVariant"; export enum TerminatorSkinModel { Steve = "steve", @@ -20,6 +21,7 @@ export interface TerminatorInputParam { breedable: boolean; coords: Vector3; skinmodel: TerminatorSkinModel; + cape: CapeVariant; } export function spawnTerminator( @@ -38,7 +40,9 @@ export function spawnTerminator( * If the option is undefined in user_input * Script Engine will replace key values with 'default_nbt' variable */ - user_input.nametag = user_input.nametag.replace(/[^a-zA-Z0-9_ ]/g, '').substring(0, 15); + user_input.nametag = user_input.nametag + .replace(/[^a-zA-Z0-9_ ]/g, "") + .substring(0, 15); entity.nameTag = user_input.nametag; if (user_input.customskin == true) { @@ -72,6 +76,9 @@ export function spawnTerminator( } else if (user_input.skinmodel == TerminatorSkinModel.CustomSlim) { entity.triggerEvent("terminator:enable_customSlim_skin"); } + if (user_input.cape !== 0) { + entity.setProperty("terminator:cape", user_input.cape); + } const userInputString = JSON.stringify(user_input); if (debugEnabled) console.log("User input: " + userInputString); diff --git a/src/terminator/capeVariant.ts b/src/terminator/capeVariant.ts new file mode 100644 index 0000000..14b18dd --- /dev/null +++ b/src/terminator/capeVariant.ts @@ -0,0 +1,27 @@ +export enum CapeVariant { + None, + Fifteenth_anniv, + Cherry, + Founder, + Migrator, + Mojang_new, + Pan, + Pride, + Tiktok, + Twitch, + Vanilla, +} + +export const CapeVariants = [ + "None", + "15th Anniversary", + "Cherry Blossom", + "Founder", + "Migrator", + "Mojang New", + "Pan", + "Progress Pride", + "Follower (TikTok)", + "Purple Heart (Twitch)", + "One Vanilla", +]; diff --git a/src/terminator/ridingTransport.ts b/src/terminator/ridingTransport.ts index 2221fbe..980c80f 100644 --- a/src/terminator/ridingTransport.ts +++ b/src/terminator/ridingTransport.ts @@ -2,20 +2,17 @@ import { ItemStack, TicksPerSecond, system, world } from "@minecraft/server"; import { MinecraftEntityTypes } from "@minecraft/vanilla-data"; const overworld = world.getDimension("overworld"); +const rideableTransports = [ + MinecraftEntityTypes.Minecart, + MinecraftEntityTypes.ChestBoat, + MinecraftEntityTypes.Boat, +]; // Replacement of controller.animation.terminator.sitting system.runInterval(() => { const terminators = overworld.getEntities({ type: "entity:terminator" }); if (terminators.length === 0) return; - const boats = overworld.getEntities({ type: MinecraftEntityTypes.Boat }); - const chestBoats = overworld.getEntities({ - type: MinecraftEntityTypes.ChestBoat, - }); - const minecarts = overworld.getEntities({ - type: MinecraftEntityTypes.Minecart, - }); - for (const terminator of terminators) { let rideableCooldown = terminator.getDynamicProperty( "terminator:rideable_cooldown" @@ -40,29 +37,11 @@ system.runInterval(() => { // If the rideable cooldown is 0 and terminator is sitting, then leave the transport they're riding in // Note: Rideable component is not released to stable, kill the transport entity else if (rideableCooldown === 0) { - const nearbyBoats = boats.filter( - (boat) => - boat.matches({ maxDistance: 1, location: terminator.location }) && - boat.dimension === terminator.dimension - ); - const nearbyChestBoats = chestBoats.filter( - (chestBoat) => - chestBoat.matches({ - maxDistance: 1, - location: terminator.location, - }) && chestBoat.dimension === terminator.dimension - ); - const nearbyMinecarts = minecarts.filter( - (minecart) => - minecart.matches({ maxDistance: 1, location: terminator.location }) && - minecart.dimension === terminator.dimension + const nearbyTransport = terminator.dimension.getEntitiesAtBlockLocation( + terminator.location ); - const nearbyTransport = [ - ...nearbyBoats, - ...nearbyChestBoats, - ...nearbyMinecarts, - ]; for (const transport of nearbyTransport) { + if (rideableTransports.some((id) => transport.typeId !== id)) continue; transport.dimension.spawnItem( new ItemStack(transport.typeId, 1), transport.location