system.runInterval(() => {
for (const player of world.getPlayers()) {
const playerEquipment = player.getComponent(EntityEquippableComponent.componentId);
const mainHandItem = playerEquipment.getEquipment(EquipmentSlot.Mainhand);
const offHandItem = playerEquipment.getEquipment(EquipmentSlot.Offhand);
let player0Identity = world.getPlayers()[0].scoreboardIdentity;
let offhandFullObjective = world.scoreboard.getObjective("htc_offhand_full")
let offhandFullValue = offhandFullObjective.getScore(player0Identity)
let twoHandedObjective = world.scoreboard.getObjective("htc_two_handed")
let twoHandedValue = twoHandedObjective.getScore(player0Identity)
const offhandFullTest = ["shield","rocket","arrow","totem","map","nautilus_shell"];
if (offHandItem) {
if (offhandFullTest.some(typeId => offHandItem.typeId.includes(typeId)) && (offhandFullValue==0 || offhandFullValue == undefined)) {
offhandFullObjective.setScore(player0Identity, 1);
} else if (offhandFullTest.some(typeId => !offHandItem.typeId.includes(typeId)) && (offhandFullValue!=0)) {
offhandFullObjective.removeParticipant(player0Identity);
}
}
}
},4);