diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-04-21 18:34:15 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-04-21 18:34:15 +0800 |
commit | 4235ffd80ac8829266a7b9528c0205a0831686e2 (patch) | |
tree | f34bdeabbf1d681ea278274cf42925c28bc288cd /features/nether | |
parent | 64cff6227af6e5f1df9685c93a2672c00a1ac171 (diff) | |
download | SoopyV2-4235ffd80ac8829266a7b9528c0205a0831686e2.tar.gz SoopyV2-4235ffd80ac8829266a7b9528c0205a0831686e2.tar.bz2 SoopyV2-4235ffd80ac8829266a7b9528c0205a0831686e2.zip |
update
Diffstat (limited to 'features/nether')
-rw-r--r-- | features/nether/index.js | 74 | ||||
-rw-r--r-- | features/nether/metadata.json | 8 |
2 files changed, 82 insertions, 0 deletions
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 @@ +/// <reference types="../../../CTAutocomplete" /> +/// <reference lib="es2015" /> +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 |