From 4235ffd80ac8829266a7b9528c0205a0831686e2 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:34:15 +0800 Subject: update --- features/nether/index.js | 74 +++++++++++++++++++++++++++++++++++++++++++ features/nether/metadata.json | 8 +++++ 2 files changed, 82 insertions(+) create mode 100644 features/nether/index.js create mode 100644 features/nether/metadata.json (limited to 'features/nether') diff --git a/features/nether/index.js b/features/nether/index.js new file mode 100644 index 0000000..d0f29ac --- /dev/null +++ b/features/nether/index.js @@ -0,0 +1,74 @@ +/// +/// +import { m } from "../../../mappings/mappings"; +import Feature from "../../featureClass/class"; +import ToggleSetting from "../settings/settingThings/toggle"; +const MCBlock = Java.type("net.minecraft.block.Block"); + +class Nether extends Feature { + constructor() { + super(); + } + + onEnable() { + this.initVariables(); + + this.masteryTimer = new ToggleSetting("Mastery Timer", "Countdown untill a block will turn red", true, "nether_mastery_timer", this) + + this.registerCustom("packetReceived", this.packetReceived) + + this.registerStep(true, 1, this.step1S) + this.registerEvent("renderWorld", this.renderWorld) + + this.blocks = [] + } + + packetReceived(packet, event) { + let packetType = new String(packet.class.getSimpleName()).valueOf() + if (packetType !== "S23PacketBlockChange") return; + let position = new BlockPos(packet[m.getBlockPosition.S23PacketBlockChange]()) + let blockState = this.getBlockIdFromState(packet[m.getBlockState.S23PacketBlockChange]()) + let oldBlockState = this.getBlockIdFromState(World.getBlockStateAt(position)) + if (oldBlockState === 20515 && blockState === 16419) { + this.blocks.push({ loc: position, time: Date.now() + 3000 }) + } + if (blockState === 57379) { + this.blocks.filter(b => { + if (b.loc.x === position.x && b.loc.y === position.y && b.loc.z === position.z) { + return false + } + return true + }) + } + //air=0 + //green=20515 + //yellow=16419 + //red=57379 + } + + renderWorld(event) { + this.blocks.forEach(data => { + Tessellator.drawString(Math.max(0, (data.time - Date.now()) / 1000).toFixed(1) + "s", data.loc.getX() + 0.5, data.loc.getY() + 0.5, data.loc.getZ() + 0.5, 0, false, 0.05, false) + }) + } + + step1S() { + this.blocks = this.blocks.filter(state => Date.now() < state.time) + } + + getBlockIdFromState(state) { + return MCBlock[m.getStateId](state) + } + + initVariables() { + } + + onDisable() { + this.initVariables(); + } +} + +let nether = new Nether() +module.exports = { + class: nether, +}; \ No newline at end of file diff --git a/features/nether/metadata.json b/features/nether/metadata.json new file mode 100644 index 0000000..322c840 --- /dev/null +++ b/features/nether/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Nether", + "description": "Nether features", + "isHidden": false, + "isTogglable": true, + "defaultEnabled": true, + "sortA": 1 +} \ No newline at end of file -- cgit