I'm making a modpack for me n' my friends, and I used this script–which is 90% made by desync–to change the default player size of an origin, but I don't want it to trigger every tick. to be overly specific I would like it to run once when the origin is selected and again every 20-60s just in case someone finds a way to change their size. I've tried using PlayerEvents.onInventoryClosed but the origin selection menu doesn't count as an inventory (probably obvious but it was worth a shot).
const $OriginLayer = Java.loadClass('io.github.apace100.origins.origin.OriginLayer');
const $OriginLayers = Java.loadClass('io.github.apace100.origins.origin.OriginLayers');
const $ModComponents = Java.loadClass('io.github.apace100.origins.registry.ModComponents');
const $Origin = Java.loadClass('io.github.apace100.origins.origin.Origin');
const SCALE_TYPES = Java.loadClass('virtuoel.pehkui.api.ScaleTypes')
const playerOrigins = {};
/**
* @param {Internal.Entity} entity
* @param {string} originLayerString
*/
function getOrigin(entity, originLayerString) {
let originLayer = $OriginLayers.getLayer(originLayerString ?? 'origins:origin');
let origin = $ModComponents.ORIGIN.get(entity).getOrigin(originLayer);
return origin.getIdentifier();
}
PlayerEvents.tick(event => {
const {player} = event;
//player.tell(getOrigin(player));
if(playerOrigins[player.uuid.toString()] = getOrigin(player) == 'icarae_origin:icarae') {
SCALE_TYPES.BASE.getScaleData(player).setScale(0.87)
} else {
SCALE_TYPES.BASE.getScaleData(player).setScale(1)
}
})```