mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-11-29 13:45:38 -05:00
Added a readme with a fucking warning because of Cofix's ass. added work in progress world module
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# FNFBoyfriendBot
|
||||
|
||||
do not use the latest commit in the main branch for now unless you know what you are doing and know how to fix the errors!
|
||||
it is not stable and my dumbass decided to pushed the unstable build to the main branch
|
||||
for a stable build please go to
|
||||
https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/src/commit/fcbd9f983c342e572c43f7fb3300476805f6084e%
|
||||
v8.0.0 Reignite is the current stable build
|
||||
@@ -13,36 +13,7 @@ export default class test extends CommandContext {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const args = context.arguments;
|
||||
const Item = require("prismarine-item")(bot.options.version);
|
||||
//console.log(Item)
|
||||
let position = { x: bot.position.x, y: bot.position.y - 1, z: bot.position.z }
|
||||
|
||||
console.log(Item.toNotch( new Item( bot.registry.itemsByName.oak_sign.id, 1, 0, ), ),)
|
||||
bot._client.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: Item.toNotch(
|
||||
new Item(
|
||||
bot.registry.itemsByName.oak_sign.id,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
),
|
||||
});
|
||||
|
||||
bot._client.write('block_dig', {
|
||||
status: 0,
|
||||
location: position,
|
||||
face: 0
|
||||
});
|
||||
|
||||
bot._client.write('block_place', {
|
||||
hand: 0,
|
||||
location: position,
|
||||
direction: 0,
|
||||
cursorX: 0.1,
|
||||
cursorY: 0,
|
||||
cursorZ: 0.1,
|
||||
insideBlock: false
|
||||
});
|
||||
bot.chat.send('meow :3')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ export default class Chat {
|
||||
message: parsed
|
||||
})
|
||||
|
||||
if (bot.debugEnabled) bot.emit("disguised", parsed);
|
||||
|
||||
parseMessage(parsed, { senderName: sender, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine, chatType: "minecraft:diguised_chat" })
|
||||
});
|
||||
|
||||
@@ -87,7 +85,6 @@ export default class Chat {
|
||||
chatType: "minecraft:player_chat"
|
||||
});
|
||||
|
||||
if (bot.debugEnabled) bot.emit("player", unsigned)
|
||||
});
|
||||
|
||||
bot.on("packet.system_chat", (packet: any) => {
|
||||
@@ -109,8 +106,6 @@ export default class Chat {
|
||||
message: message
|
||||
});
|
||||
|
||||
// if (bot.debugEnabled) bot.emit("system", message)
|
||||
|
||||
parseMessage(message, {
|
||||
players: bot.players,
|
||||
getMessageAsPrismarine: bot.getMessageAsPrismarine,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LoadCommands } from '../util/LoadCommands';
|
||||
import { CommandError } from '../command/CommandError';
|
||||
|
||||
export default class commandManager {
|
||||
export default class CommandManager {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
|
||||
+92
-5
@@ -1,17 +1,23 @@
|
||||
// i may or may not have used v4's command core for a base here
|
||||
|
||||
import { format } from 'util';
|
||||
//const Chunk = require('prismarine-chunk')
|
||||
export default class Core {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
|
||||
const Item = require("prismarine-item")(bot.options.version);
|
||||
|
||||
bot.core = {
|
||||
area: {
|
||||
start: options.core?.area.start ?? { x: 0, y: 0, z: 0 },
|
||||
end: options.core?.area.end ?? { x: 15, y: 0, z: 15 }
|
||||
},
|
||||
|
||||
position: null,
|
||||
|
||||
itemPosition: null,
|
||||
|
||||
currentBlockRelative: { x: 0, y: 0, z: 0 },
|
||||
|
||||
refill () {
|
||||
@@ -19,23 +25,76 @@ export default class Core {
|
||||
const { start, end } = bot.core.area
|
||||
|
||||
if (!pos) return
|
||||
|
||||
// {CustomName:${JSON.stringify(config.core.name)}
|
||||
bot.chat.command(`fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block`)
|
||||
},
|
||||
|
||||
itemRefill () {
|
||||
const pos = bot.core.itemPosition;
|
||||
//console.log(Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id, 1, 0, 0, 0,)))
|
||||
// console.log(Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id)))
|
||||
console.log(Item.toNotch(new Item(bot.registry.itemsByName.repeating_command_block.id), 1))
|
||||
bot._client.write("set_creative_slot", {
|
||||
slot: 36,
|
||||
//item: {}
|
||||
item: Item.toNotch(
|
||||
new Item(
|
||||
bot.registry.itemsByName.repeating_command_block.id,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
),
|
||||
});
|
||||
|
||||
bot._client.write("block_dig", {
|
||||
status: 0,
|
||||
location: pos,
|
||||
face: 0,
|
||||
});
|
||||
|
||||
bot._client.write("block_place", {
|
||||
hand: 0,
|
||||
location: pos,
|
||||
direction: 0,
|
||||
cursorX: 0,
|
||||
cursorY: 0,
|
||||
cursorZ: 0,
|
||||
insideBlock: false,
|
||||
});
|
||||
},
|
||||
|
||||
useCommandBlock (command: any, location: any, mode: any, flags: any) {
|
||||
bot._client.write("update_command_block", {
|
||||
command: command?.substring(0, 32767),
|
||||
location: location,
|
||||
mode: mode,
|
||||
flags: flags,
|
||||
});
|
||||
},
|
||||
|
||||
move (pos = bot.position) {
|
||||
bot.core.position = {
|
||||
x: Math.floor(pos.x / 16) * 16,
|
||||
y: 0,
|
||||
z: Math.floor(pos.z / 16) * 16
|
||||
}
|
||||
bot.core.refill()
|
||||
|
||||
bot.core.itemPosition = {
|
||||
x: Math.floor(pos.x),
|
||||
y: Math.floor(pos.y - 1),
|
||||
z: Math.floor(pos.z),
|
||||
};
|
||||
|
||||
bot.core.itemRefill();
|
||||
//bot.core.refill()
|
||||
},
|
||||
|
||||
commandBlockCoords: [],
|
||||
|
||||
needsFilling: false,
|
||||
|
||||
cantFill: false,
|
||||
|
||||
currentBlock () {
|
||||
const relativePosition = bot.core.currentBlockRelative
|
||||
const corePosition = bot.core.position
|
||||
@@ -78,6 +137,34 @@ export default class Core {
|
||||
|
||||
bot.on('move', () => {
|
||||
bot.core.move(bot.position)
|
||||
})
|
||||
});
|
||||
|
||||
bot.on('packet.multi_block_change', (packet: any) => {
|
||||
// used some code here from https://code.chipmunk.land/Yaode_owo/js-nmp-1.21.8-chunkparser/src/branch/main/chunkparser.js
|
||||
|
||||
const chunkCoord = packet.chunkCoordinates;
|
||||
|
||||
const findChunkColumn = bot.world.chunkColumns.find((column: any) => column.x === chunkCoord.x && column.z === chunkCoord.z);
|
||||
const baseX = chunkCoord.x << 4;
|
||||
const baseY = chunkCoord.y << 4;
|
||||
const baseZ = chunkCoord.z << 4;
|
||||
|
||||
for (const num of packet.records) {
|
||||
const x = baseX | ((num >> 8) & 15);
|
||||
const y = baseY | (num & 15);
|
||||
const z = baseZ | ((num >> 4) & 15);
|
||||
const getBlock = bot.world.getBlock(num >> 12);
|
||||
if (getBlock.name === "command_block") {
|
||||
bot.core.commandBlockCoords.push({ x: x, y: y, z: z });
|
||||
}
|
||||
const coreX = bot.core.commandBlockCoords.find((coord: any) => coord.x === x);
|
||||
const coreY = bot.core.commandBlockCoords.find((coord: any) => coord.y === y);
|
||||
const coreZ = bot.core.commandBlockCoords.find((coord: any) => coord.z === z)
|
||||
if (coreX && coreY && coreZ) {
|
||||
if (getBlock.name === "command_block" || getBlock.name === "repeating_command_block") return;
|
||||
else bot.core.refill()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
const convertNbtComponentToJson = require('../util/ConvertNbtComponentToJson');
|
||||
|
||||
export default class world {
|
||||
constructor (context: any) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = bot.options;
|
||||
bot.world = {
|
||||
dimensions: [],
|
||||
chunkColumns: [],
|
||||
currentDimension: undefined,
|
||||
getBlock (blockStateID: any) {
|
||||
const getBlocks = bot.registry.blocksByStateId;
|
||||
|
||||
return getBlocks[blockStateID];
|
||||
},
|
||||
chunk: undefined,
|
||||
|
||||
getBlockNBT (location: any) {
|
||||
const transactionId = Math.floor(Math.random() * 10000);
|
||||
|
||||
bot._client.write('query_block_nbt', { transactionId, location });
|
||||
|
||||
bot.on('packet.nbt_query_response', (packet: any) => {
|
||||
try {
|
||||
if (packet.transactionId == transactionId) {
|
||||
const parsed = convertNbtComponentToJson(null, packet.nbt);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('packet.login', (packet: any) => {
|
||||
|
||||
});
|
||||
|
||||
bot.on('packet.registry_data', (packet: any) => {
|
||||
let dimension;
|
||||
if (packet.id === "minecraft:dimension_type") {
|
||||
for (const dimensions of packet.entries) {
|
||||
const parseToJson = convertNbtComponentToJson(null, dimensions.value);
|
||||
const maxY = parseToJson.height;
|
||||
const minY = parseToJson.min_y;
|
||||
|
||||
if (dimensions.key === "minecraft:overworld_caves") dimension = "minecraft:world_flatlands";
|
||||
else dimension = dimensions.key
|
||||
bot.world.dimensions.push({ name: dimension, minY: minY, maxY: maxY });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('packet.map_chunk', (packet: any) => {
|
||||
const x = packet.x;
|
||||
const z = packet.z;
|
||||
|
||||
bot.world.chunkColumns.push({ x, z });
|
||||
});
|
||||
|
||||
bot.on('packet.unload_chunk', (packet: any) => {
|
||||
bot.world.chunkColumns = [];
|
||||
});
|
||||
|
||||
bot.on('packet.respawn', (packet: any) => {
|
||||
bot.world.currentDimension = packet.worldState.name;
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user