Skip to content

Commit

Permalink
Add 9 bedrock capes to terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
JaylyDev committed Jun 1, 2024
1 parent bc2f500 commit 2a66515
Show file tree
Hide file tree
Showing 23 changed files with 141 additions and 54 deletions.
9 changes: 9 additions & 0 deletions assets/behavior_pack/entities/terminator.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
"client_sync": true,
"type": "bool",
"default": false
},
"terminator:cape": {
"client_sync": true,
"type": "int",
"default": 0,
"range": [0, 10]
}
}
},
Expand Down Expand Up @@ -2594,6 +2600,9 @@
"minecraft:melee_attack",
"terminator:break_blocks.v2"
]
},
"set_property": {
"terminator:cape": "math.random_integer(0, 10)"
}
},
"minecraft:gain_bad_omen": {
Expand Down
20 changes: 14 additions & 6 deletions assets/resource_pack/attachables/elytra.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
}
}
}
15 changes: 12 additions & 3 deletions assets/resource_pack/entity/terminator.entity.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -127,7 +136,7 @@
},
"render_controllers": [
"controller.render.terminator",
"controller.render.player.cape"
"controller.render.terminator.cape"
],
"enable_attachables": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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" }]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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)"
}
]
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/resource_pack/textures/entity/cape_cherry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/resource_pack/textures/entity/cape_pan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/resource_pack/textures/entity/cape_tiktok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 9 additions & 3 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -82,7 +84,8 @@ type TerminatorSpawnFormValues = [
boolean, // physics
boolean, // regeneration
boolean, // respawn
boolean // breedable
boolean, // breedable
number // cape
];

const getDefaultSpawnOptions = (player: Player): TerminatorInputParam => ({
Expand All @@ -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 {
Expand Down Expand Up @@ -131,6 +135,7 @@ export function showSpawnTerminatorForm(player: Player) {
regeneration,
respawn,
breedable,
cape,
] = result.formValues as TerminatorSpawnFormValues;
let skinmodel: TerminatorSkinModel = TerminatorSkinModel.Steve;
switch (skinModelIndex) {
Expand Down Expand Up @@ -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);
})
Expand Down
9 changes: 8 additions & 1 deletion src/commands/summon.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -20,6 +21,7 @@ export interface TerminatorInputParam {
breedable: boolean;
coords: Vector3;
skinmodel: TerminatorSkinModel;
cape: CapeVariant;
}

export function spawnTerminator(
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
27 changes: 27 additions & 0 deletions src/terminator/capeVariant.ts
Original file line number Diff line number Diff line change
@@ -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",
];
37 changes: 8 additions & 29 deletions src/terminator/ridingTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 2a66515

Please sign in to comment.