Skip to content

Instantly share code, notes, and snippets.

View onnowhere's full-sized avatar

onnowhere onnowhere

View GitHub Profile
@onnowhere
onnowhere / DiscordEmojiCopyBookmarklet.md
Last active November 2, 2023 14:47
Discord Emoji Copy Bookmarklet

Save emojiCopyBookmarklet.js as a bookmarklet in your browser by adding a new bookmark and pasting the script as the link. Clicking the bookmarklet will enable emoji copy in your browser. Alternatively, run the code in your browser or app console.

Usage

  • Left click on an emoji or sticker to write it into the textbox as a link to a resized 48x48 pixel version of the image
    • If the emoji or sticker can be used normally, it will be inserted as is instead of a link
  • Right click on any emoji or sticker to copy the resized image link to your clipboard
@onnowhere
onnowhere / replaceitem_converter.py
Last active November 12, 2020 10:03
Converts /replaceitem to 1.17 /item format. Put in datapack root folder and run. Searches all mcfunction files inside ./data/*
import os
import re
def convert_replaceitem(fread):
changed = False
for i,command in enumerate(fread):
if command.startswith("replaceitem"):
# Regex credit to Dieuwt on the MinecraftCommands Discord
fread[i] = re.sub(r'replaceitem (entity @.[^[]*? .*? |entity @.\[.*?\] .*? |block (.*? ){4})', r'item \1replace ', command)
changed = True
@onnowhere
onnowhere / prune_chunks.py
Last active July 13, 2020 10:02
Deletes all chunks that don't contain a specific block within a coordinate range. Files are read from `./region` and output to `./output`. Default scans for any glass block at y=255 in every chunk.
# Prune Chunks
# Deletes all chunks that don't contain a specific block within a coordinate range
# By Onnowhere
import os
import sys
import subprocess
import pkg_resources
import pathlib
@onnowhere
onnowhere / image_to_particles.py
Last active May 8, 2022 11:37
[Image to Particles] Quick tool that generates a function that displays particles for an input image using local coordinates. Drop images in the `images` folder in the same directory as the script. You'll also need to `pip install opencv-python`. Edit generation options at the bottom of the file.
import cv2
import os
class ImageToParticle:
def __init__(self, image_file, resolution=(40, 40), scale=0.25, max_size=5, replace_transparent=[], animation=0, commands=[], show_display=False):
self.image_file = image_file # Source file
self.resolution = resolution # Shrinks image to fit within x,y dimensions without changing aspect ratio (1 pixel = 1 particle)
self.scale = scale # Scale the size of image displayed in game
self.max_size = max_size # Maximum particle size, alpha scales this if replace_transparent is not defined
self.replace_transparent = replace_transparent # RGB value to replace 0 alpha with
@onnowhere
onnowhere / blit_util.vsh
Created June 2, 2020 12:29
20w22a Depth Shader Example
#version 110
attribute vec4 Position;
uniform mat4 ProjMat;
uniform vec2 InSize;
varying vec2 texCoord;
varying vec2 oneTexel;
@onnowhere
onnowhere / SecretWarp.java
Last active April 4, 2020 00:52
Secret Warp Decoded
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.spec.KeySpec;
import java.security.KeyFactory;
import java.util.Arrays;
import javax.crypto.SecretKey;
@onnowhere
onnowhere / calculate_mined_blocks.mcfunction
Last active October 29, 2019 05:21
Adds every single mined objective into mined_blocks (inefficient but runs quite well surprisingly). Execute the function from a player to calculate their mined_blocks.
scoreboard players set @s mined_blocks 0
scoreboard players operation @s mined_blocks += @s mined_1
scoreboard players operation @s mined_blocks += @s mined_2
scoreboard players operation @s mined_blocks += @s mined_3
scoreboard players operation @s mined_blocks += @s mined_4
scoreboard players operation @s mined_blocks += @s mined_5
scoreboard players operation @s mined_blocks += @s mined_6
scoreboard players operation @s mined_blocks += @s mined_7
scoreboard players operation @s mined_blocks += @s mined_8
scoreboard players operation @s mined_blocks += @s mined_9
@onnowhere
onnowhere / create_mined_objectives.mcfunction
Last active October 29, 2019 05:21
Creates an objective for mining every blocks as well as the mined_blocks objective. Run this once to initialize scoreboards.
scoreboard objectives add mined_blocks dummy
scoreboard objectives add mined_1 minecraft.mined:minecraft.acacia_button
scoreboard objectives add mined_2 minecraft.mined:minecraft.acacia_door
scoreboard objectives add mined_3 minecraft.mined:minecraft.acacia_fence
scoreboard objectives add mined_4 minecraft.mined:minecraft.acacia_fence_gate
scoreboard objectives add mined_5 minecraft.mined:minecraft.acacia_leaves
scoreboard objectives add mined_6 minecraft.mined:minecraft.acacia_log
scoreboard objectives add mined_7 minecraft.mined:minecraft.acacia_planks
scoreboard objectives add mined_8 minecraft.mined:minecraft.acacia_pressure_plate
scoreboard objectives add mined_9 minecraft.mined:minecraft.acacia_sapling