Skip to content

Commit

Permalink
added hopper counters, light level, mspt, and more
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestOfLight committed Jun 29, 2024
1 parent 32d8b11 commit c2aafd2
Show file tree
Hide file tree
Showing 20 changed files with 901 additions and 236 deletions.
58 changes: 58 additions & 0 deletions Info Display [BP]/entities/light_level.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"format_version": "1.20.40",
"minecraft:entity": {
"description": {
"identifier": "info:light_level",
"is_spawnable": false,
"is_summonable": true,
"is_experimental": false,
"properties":{"info:light":{"type": "int","range":[0, 15],"default":0}}
},
"components": {
"minecraft:damage_sensor": {"triggers": {"deals_damage": false}},
"minecraft:pushable": {"is_pushable": false,"is_pushable_by_piston": false},
"minecraft:collision_box": {"width": 0,"height": 0},
"minecraft:nameable": {"allow_name_tag_renaming": false},
"minecraft:breathable": {"breathes_air": true,"breathes_water": true},
"minecraft:physics": {"has_gravity": false,"has_collision": false},
"minecraft:environment_sensor": {
"triggers": [
{"filters": {"test": "light_level", "value": 0},"event": "light_0"},
{"filters": {"test": "light_level", "value": 1},"event": "light_1"},
{"filters": {"test": "light_level", "value": 2},"event": "light_2"},
{"filters": {"test": "light_level", "value": 3},"event": "light_3"},
{"filters": {"test": "light_level", "value": 4},"event": "light_4"},
{"filters": {"test": "light_level", "value": 5},"event": "light_5"},
{"filters": {"test": "light_level", "value": 6},"event": "light_6"},
{"filters": {"test": "light_level", "value": 7},"event": "light_7"},
{"filters": {"test": "light_level", "value": 8},"event": "light_8"},
{"filters": {"test": "light_level", "value": 9},"event": "light_9"},
{"filters": {"test": "light_level", "value": 10},"event": "light_10"},
{"filters": {"test": "light_level", "value": 11},"event": "light_11"},
{"filters": {"test": "light_level", "value": 12},"event": "light_12"},
{"filters": {"test": "light_level", "value": 13},"event": "light_13"},
{"filters": {"test": "light_level", "value": 14},"event": "light_14"},
{"filters": {"test": "light_level", "value": 15},"event": "light_15"}
]
}
},
"events":{
"light_0": {"set_property": {"info:light": 0}},
"light_1": {"set_property": {"info:light": 1}},
"light_2": {"set_property": {"info:light": 2}},
"light_3": {"set_property": {"info:light": 3}},
"light_4": {"set_property": {"info:light": 4}},
"light_5": {"set_property": {"info:light": 5}},
"light_6": {"set_property": {"info:light": 6}},
"light_7": {"set_property": {"info:light": 7}},
"light_8": {"set_property": {"info:light": 8}},
"light_9": {"set_property": {"info:light": 9}},
"light_10": {"set_property": {"info:light": 10}},
"light_11": {"set_property": {"info:light": 11}},
"light_12": {"set_property": {"info:light": 12}},
"light_13": {"set_property": {"info:light": 13}},
"light_14": {"set_property": {"info:light": 14}},
"light_15": {"set_property": {"info:light": 15}}
}
}
}
4 changes: 2 additions & 2 deletions Info Display [BP]/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"name": "Info Display [BP]",
"description": "Info Display by §uAlecs§r and largely expanded by §aForestOfLight§r for the §dAmelix Foundation§r.",
"uuid": "e9f3a30c-f040-4cb7-a146-e15e7088f2ff",
"min_engine_version": [1, 21, 0],
"version": [1, 2, 1]
"min_engine_version": [1, 21, 1],
"version": [1, 2, 2]
},
"modules": [
{
Expand Down
Binary file modified Info Display [BP]/pack_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 8 additions & 143 deletions Info Display [BP]/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as mc from '@minecraft/server'

// Config
import 'src/config/database'

// Commands
import 'src/commands/info'
import 'src/commands/help'
import 'src/commands/peek'
Expand All @@ -13,148 +14,12 @@ import 'src/commands/distance'
import 'src/commands/tntlog'
import 'src/commands/summontnt'
import 'src/commands/entitydensity'
import 'src/commands/tps'
import 'src/commands/health'
import 'src/commands/counter'
import 'src/commands/resetall'

// Features
import 'src/features/noExplosionBlockDamage'
import 'src/features/pickupOnMine'
import 'src/features/universalChunkLoading'

import Data from 'stickycore/data'
import Utils from 'stickycore/utils'
import { DataTPS } from 'src/tps'
import { Entities } from 'src/entities'

mc.system.runInterval(() => {
const Players = mc.world.getAllPlayers();
for (const player of Players) {
if (player.getDynamicProperty('showDisplay')) InfoDisplay(player);
}
});

let dayTime = 0;
mc.system.runInterval(() => {
dayTime = Utils.ticksToTime(Data.getTimeOfDay());
}, 20);

function InfoDisplay(player) {
let InfoText = '';

InfoText += parseCoordsAndFacing(player);
InfoText += parseTPSAndEntities(player);
InfoText += parseLightAndSlimeChunk(player);
InfoText += parseDayAndTime(player);
InfoText += parseMoonPhase(player);
InfoText += parseLookingAtAndPeek(player);

player.onScreenDisplay.setActionBar(InfoText.trim());
}

function parseCoordsAndFacing(player) {
const showCoords = player.getDynamicProperty('coords');
const showFacing = player.getDynamicProperty('facing');
let coords = player.location;
let facing;
let output = '';

if (showCoords) [ coords.x, coords.y, coords.z ] = [ coords.x.toFixed(2), coords.y.toFixed(2), coords.z.toFixed(2) ];
if (showFacing) facing = Data.getPlayerDirection(player);
if (showCoords && showFacing) output += `§r${coords.x} ${coords.y} ${coords.z}§r §7${facing}§r\n`;
else if (showCoords) output += `§r${coords.x} ${coords.y} ${coords.z}§r\n`;
else if (showFacing) output += `§rFacing: §7${facing}§r\n`;

return output;
}

function parseTPSAndEntities(player) {
const showTPS = player.getDynamicProperty('tps');
const showEntities = player.getDynamicProperty('entities');
let tps;
let fovEntities;
let simDistanceEntities;
let dimensionEntities;
let worldEntities;
let output = '';

if (showTPS) {
const _tps = DataTPS.tps.toFixed(1);
tps = _tps >= 20 ? `§a20.0` : `§c${_tps}`;
}
if (showEntities) {
fovEntities = Entities.getEntitiesOnScreenCount(player);
simDistanceEntities = Entities.getPlayerRadiusEntityCount(player, 96);
dimensionEntities = Entities.getDimensionEntityCount(player.dimension.id);
worldEntities = Entities.getWorldEntityCount();
}
if (showTPS && showEntities) output += `§rTPS: ${tps}§r §7${fovEntities}§r/${simDistanceEntities}/§d${dimensionEntities}§r/§a${worldEntities}§r\n`;
else if (showTPS) output += `§rTPS: ${tps}§r\n`;
else if (showEntities) output += `§rEntities: §8${fovEntities}§r/§7${simDistanceEntities}§r/§d${dimensionEntities}§r/§a${worldEntities}§r\n`;

return output;
}

function parseLightAndSlimeChunk(player) {
//const showLight = player.getDynamicProperty('light');
const showSlimeChunk = player.getDynamicProperty('slimeChunk');
//let Light;
let slimeChunk;
let output = '';

//if (showLight) Light = 0;
if (showSlimeChunk) slimeChunk = player.dimension.id == "minecraft:overworld" && Data.isSlime(player.location.x, player.location.z) ? '§7(§aSlime Chunk§7)§r' : '';
// if (showLight && showSlimeChunk) output += `§rLight: §e${Light} §r${SlimeChunk}\n`;
// else if (showLight) output += `§rLight: §e${Light}§r\n`;
// else if (showSlimeChunk) output += `§rChunk: ${SlimeChunk}\n`;
if (showSlimeChunk) output += `§rChunk: ${slimeChunk}\n`; // TEMP: while Light is broken

return output;
}

function parseDayAndTime(player) {
const showDay = player.getDynamicProperty('worldDay');
const showTimeOfDay = player.getDynamicProperty('timeOfDay');
let day;
let output = '';

if (showDay) day = Data.getDay();
if (showDay && showTimeOfDay) output += `Day: §7${day}§r §7${dayTime}§r\n`;
else if (showDay) output += `§rDay: §7${day}§r\n`;
else if (showTimeOfDay) output += `§rTime: §7${dayTime}§r\n`;

return output;
}

function parseMoonPhase(player) {
const showMoonPhase = player.getDynamicProperty('moonPhase');
let moonPhase;
let output = '';

if (showMoonPhase) {
moonPhase = Data.getMoonPhase();
output = `§rMoon: §7${moonPhase}§r\n`;
}

return output;
}

function parseLookingAtAndPeek(player) {
const showLookingAt = player.getDynamicProperty('lookingAt');
const showPeekInventory = player.getDynamicProperty('peekInventory');
let blockRayResult;
let entityRayResult;
let lookingAtName;
let peekInventory;
let output = '';

if (!showLookingAt && !showPeekInventory) return '';
({ blockRayResult, entityRayResult } = Data.getRaycastResults(player, 7));
if (showLookingAt) {
lookingAtName = Utils.parseLookingAtEntity(entityRayResult).LookingAtName || Utils.parseLookingAtBlock(blockRayResult).LookingAtName;
output += `${lookingAtName}`;
}
if (showPeekInventory) {
peekInventory = Data.peekInventory(player, blockRayResult, entityRayResult);
output += `${peekInventory}`;
}

return output;
}
import 'src/features/InfoDisplay'
Loading

0 comments on commit c2aafd2

Please sign in to comment.