Custom Heads
Custom Heads Download as ZIP Download as MCADDON
- custom_head_back_mers.tga
- custom_head_back.png
- custom_head_back.texture_set.json
- custom_head_bottom_mers.tga
- custom_head_bottom.png
- custom_head_bottom.texture_set.json
- custom_head_front_mers.tga
- custom_head_front.png
- custom_head_front.texture_set.json
- custom_head_left_mers.tga
- custom_head_left.png
- custom_head_left.texture_set.json
- custom_head_right_mers.tga
- custom_head_right.png
- custom_head_right.texture_set.json
- custom_head_top_mers.tga
- custom_head_top.png
- custom_head_top.texture_set.json
- custom_head_back_mers.tga
- terrain_texture.json
- textures_list.json
- blocks.json
- contents.json
- manifest.json
- pack_icon.png
BP/scripts/headDrops.js
js
import { world, system, ItemStack } from '@minecraft/server';
// Object where keys are entity types and values are the item to drop when exploded by a charged creeper
const heads = {
"minecraft:husk": "wiki:custom_head",
};
// Set containing the unique IDs of charged creepers that have exploded within the last tick
const explodingChargedCreepers = new Set();
world.beforeEvents.explosion.subscribe(({ source }) => {
if (!source)
return;
const isCreeper = source.typeId === "minecraft:creeper";
const isCharged = source.hasComponent("minecraft:is_charged");
if (isCreeper && isCharged) {
// Add the charged creeper's ID to the set
explodingChargedCreepers.add(source.id);
// Remove the ID after the next tick
system.runTimeout(() => explodingChargedCreepers.delete(source.id), 1);
}
});
world.afterEvents.entityDie.subscribe((event) => {
const { damagingEntity } = event.damageSource;
if (!damagingEntity || !world.gameRules.doMobLoot)
return;
// Check whether the damaging entity is one of the charged creepers that exploded within the last tick
const explodedByChargedCreeper = explodingChargedCreepers.has(damagingEntity.id);
if (explodedByChargedCreeper) {
const { dimension, location, typeId } = event.deadEntity;
const head = heads[typeId];
dimension.spawnItem(new ItemStack(head), location);
}
}, { entityTypes: Object.keys(heads) });Code samples on this page are licensed under the MIT License