Skip to content

Instantly share code, notes, and snippets.

View FreezePhoenix's full-sized avatar
😓
Probably working on stuff. Maybe coding. Definitely tired.

FreezePhoenix

😓
Probably working on stuff. Maybe coding. Definitely tired.
View GitHub Profile
@FreezePhoenix
FreezePhoenix / XtraUtils.js
Last active May 19, 2018 15:45
Adds some extra utilities for Numbers, Arrays, and Strings.
/**
* Adds some utilities to the base classes.
* Note that this is modular and is able to modify any class it is given.
* @author FreezePhoenix
* @version 1.1.0
*/
/**
* @type {Object}
* @constant
*/
function convertBase(inNumber, inBase, outputBase) {
var result = [];
if (typeof inNumber !== "number" && typeof inNumber !== "string") {
throw new Error("You input is not a number or a string.");
}
var encodings = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
if (typeof inNumber === "number") {
inNumber = JSON.stringify(inNumber);
}
if (inBase === outputBase) {
const convertBase = (inputNumber, inputBase = 10, outputBase = 10) =>
parseInt(inputNumber, inputBase).toString(outputBase);
navigator.getBattery().then(function(battery) {
function updateAllBatteryInfo(){
updateChargeInfo();
updateLevelInfo();
updateChargingInfo();
updateDischargingInfo();
}
updateAllBatteryInfo();
battery.addEventListener('chargingchange', function(){
function rot13(str) {
var input = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var output = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
var index = x => input.indexOf(x);
var translate = x => index(x) > -1 ? output[index(x)] : x;
return str.split('').map(translate).join('');
}
game_log("---Script Start---");
//Put monsters you want to kill in here
//If your character has no target, it will travel to a spawn of the first monster in the list below.
let monster_targets = ["armadillo"],
state = "farm",
group = ["Wood", "Dirt"], // The group our character operates in. This generally forms a chain.
grey_list = [], // Characters we trust, but are willing to nullify if needed be (and are in PVP)
chain = [...group].reverse(), // How is the chain structured?
follow = group.indexOf(character.name) != 0, // Should we be following someone?
@FreezePhoenix
FreezePhoenix / sweepline.js
Created August 23, 2021 14:28
Implementation of Sweepline
function intersects(line_one, line_two) {
if(line_one.first.x == line_one.second.x) {
// line_one is vertical.
if(line_two.first.x == line_two.second.x) {
// line_two is also vertical? This isn't looking that good...
return line_two.first.x == line_one.first.x && line_one.first.y <= line_two.second.y && line_one.second.y >= line_two.first.y;
} else {
// line_two is horizontal.
return line_two.first.x <= line_one.first.x && line_two.second.x >= line_one.first.x && line_one.first.y <= line_two.first.y && line_one.second.y >= line_two.first.y;
}
package com.techteam.fabric.bettermod.util;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.vector.FloatVector;
import jdk.incubator.vector.IntVector;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.vector.VectorSupport;
import static jdk.internal.vm.vector.VectorSupport.*;
package com.techteam.fabric.bettermod.mixin;
import com.techteam.fabric.bettermod.util.VectorUtils;
import jdk.incubator.vector.FloatVector;
import jdk.incubator.vector.IntVector;
import jdk.incubator.vector.VectorOperators;
import net.minecraft.util.math.Vector4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

Source:

public final class MathUtilities {
    private MathUtilities() {
    }

    public static int floor(double d) {
        return (int) Math.floor(d);
    }