Skip to content

Instantly share code, notes, and snippets.

@RepComm
RepComm / mc.snippet02.js
Created March 6, 2020 01:06
Replace & with text format control char - Spigot/ScriptCraft plugin snippet
//Imports
//Aliases
var PlayerChatEvent = org.bukkit.event.player.PlayerChatEvent;
//Event listener
function onPlayerChat (evt) {
//Get the message
var msg = evt.getMessage();
@RepComm
RepComm / mc.snippet01.js
Created March 6, 2020 00:28
Random Color Concrete Tool - Spigot/ScriptCraft snippet
//Imports
//Aliases
var PlayerInteractEvent = org.bukkit.event.player.PlayerInteractEvent;
var Material = org.bukkit.Material;
//List of concrete colors
var concreteColors = [
Material.BLACK_CONCRETE,
@RepComm
RepComm / owotanim.js
Created January 11, 2020 23:24
OurWorldOfText Preservation Animation WIP
/**Get char from world coordinates
* @param {Integer} x world coordinate
* @param {Integer} y world coordinate
*/
let getCharFromXY = (x, y)=> {
return getChar(
Math.floor(x / 16),
Math.floor(y / 8),
x - Math.floor(x / 16) * 16,
y - Math.floor(y / 8) * 8
@RepComm
RepComm / math.js
Created January 30, 2019 19:51
Some math functions I need to stop copying
let pi = 3.141592653589793; //All the digits I could remember..
let radians = (degrees) => degrees * (pi / 180);
let degrees = (radians) => radians * (180 / pi);
let lerp = (a, b, c) => a + c * (b - a);
let dist = (x1, y1, x2, y2) => Math.sqrt(
Math.pow(x1 - x2, 2) +
Math.pow(y1 - y2, 2)
);
@RepComm
RepComm / owot_draw_lines.js
Last active January 12, 2020 04:18
A WIP (functional) script to draw lines by clicking (hold control and click), soon to come: Filling shapes. Click w/o ctrl key to reset shape drawing.
var ctrlIsDown = false;
var fillChar = "▓";
var points = [{x:undefined,y:undefined},{x:undefined,y:undefined}];
var lastPointModified = false; //false = 1, true = 2
var cursorCoordsGlobal = {x:0,y:0};
function onClick (evt) {
if (evt.button != 0) return;
@RepComm
RepComm / WinCursorParser.js
Last active March 26, 2024 05:41
Windows Cursor (*.CUR) | Icon (*.ICO) Parser in Node
/* Built using Matthew Sachin's documentation as reference
* https://github.com/MathewSachin/NIco/wiki/Ico,-Cur-and-PE-Formats
* See example function 'test'
*
* Abilities:
* Read a cursor or icon file and get it's image data (raw)
*
* Future plans:
* Read and then parse into different data sets for convenience like:
* 1d arrays of hex/web colors, or int colors