Skip to content

Instantly share code, notes, and snippets.

Avatar

John Paul John-Paul-R

View GitHub Profile
@John-Paul-R
John-Paul-R / filter_props_by_type.ts
Last active May 7, 2022
Utility types for constructing a type from an existing type, including only properties that are of a specified type. Can be applied recursively to child objects.
View filter_props_by_type.ts
type FilteredKeys<T, U> = { [P in keyof T]: T[P] extends U ? P : never }[keyof T];
enum Color {
Red, Green, Blue,
}
type PropsOfType<T, U> = {
[K in FilteredKeys<T, U>]: T[K]
};
@John-Paul-R
John-Paul-R / Program.cs
Last active Feb 3, 2022
Updated Dictionary Benchmarks
View Program.cs
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
@John-Paul-R
John-Paul-R / Program.cs
Last active Jan 31, 2022
Comparison of `Dictionary`, `ConcurrentDictionary`, and `ImmutableDictionary` read performance at differing collection sizes.
View Program.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Running;
namespace Bench_Dictionaries
{
@John-Paul-R
John-Paul-R / TopCommand.java
Created Jan 9, 2022
Get the "top" block at a given position using world.raycast.
View TopCommand.java
public class TopCommand implements Command<ServerCommandSource> {
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
ServerPlayerEntity player = source.getPlayer();
World world = source.getWorld();
Vec3d playerPos = player.getPos();
int new_y;
double new_x = playerPos.x;
@John-Paul-R
John-Paul-R / InGameHudAccess.java
Last active Jan 9, 2022
Client Chat Listener Mixin
View InGameHudAccess.java
package com.packagename.access;
import net.minecraft.client.gui.ClientChatListener;
import net.minecraft.network.MessageType;
public interface InGameHudAccess {
void registerChatListener(MessageType messageType, ClientChatListener listener);
}
@John-Paul-R
John-Paul-R / GlowmorgificationMod.java
Created Jul 31, 2021
Glowmorgification Potion Assistance
View GlowmorgificationMod.java
package com.fibermc.essentialcommands;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffectType;
import net.minecraft.entity.passive.SquidEntity;
import net.minecraft.potion.Potion;
import net.minecraft.util.Identifier;
View CommandNodeMixin.java
package com.fibermc.essentialcommands.mixin;
import com.fibermc.essentialcommands.EssentialCommands;
import com.fibermc.essentialcommands.access.CommandNodeAccess;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import org.apache.log4j.LogManager;
@John-Paul-R
John-Paul-R / time_str_to_delta.py
Created Dec 7, 2020
Time String Parser (Python)
View time_str_to_delta.py
import re
def time_str_to_time_delta(stime: str):
match_days = re.search('([0-9]+)d', stime)
match_hrs = re.search('([0-9]+)h', stime)
match_mins = re.search('([0-9]+)m', stime)
match_secs = re.search('([0-9]+)s', stime)
def int_from_match(match) -> int:
out = 0
@John-Paul-R
John-Paul-R / FabricModList.md
Last active Jun 20, 2022
A list of (almost all) mods for Fabric
View FabricModList.md

Fabric Mod List

This page contains a list of the current Minecraft Fabric mods. (As of 2021-08-19 08:05:23 Timezone: UTC+0000 (GMT))

To search for mods by name, category, or download count, visit the website, fibermc.com!

Note: You can view a mod's source files by following the "Source" link on its CurseForge page, assuming that the mod's creator has made such files public.

There are currently 2954 mods in this list.