Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" shutdownHook="disable">
<Appenders>
<Queue name="ServerGuiConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n" />
</Queue>
<TerminalConsole name="TerminalConsole">
<PatternLayout>
<LoggerNamePatternSelector defaultPattern="%highlightError{[%d{HH:mm:ss} %level]: [%logger] %msg%n%xEx{full}}">
<!-- Log root, Minecraft, Mojang and Bukkit loggers without prefix -->
@amaranth
amaranth / playground.rs
Created June 13, 2017 00:30 — forked from anonymous/playground.rs
Shared via Rust Playground
/*
This pattern was inspired by the following docs from the Rust SDL2 library.
https://docs.rs/sdl2/0.30.0/sdl2/render/struct.TextureCreator.html
> Any Texture created here can only be drawn onto the original Canvas.
> A Texture used in a Canvas must come from a TextureCreator coming
> from that same Canvas. Using a Texture to render to a Canvas not
> being the parent of the Texture's TextureCreator is undefined behavior.

Keybase proof

I hereby claim:

  • I am amaranth on github.
  • I am amaranth (https://keybase.io/amaranth) on keybase.
  • I have a public key whose fingerprint is B259 09E6 A5A6 606E 4887 1338 90BE F6C5 9A45 1675

To claim this, I am signing this object:

@amaranth
amaranth / TaskChain.java
Created June 23, 2016 19:24 — forked from aikar/TaskChain.java
TaskChain v2.3.2 - Java 8 Version - Released Open Source Under MIT - Pre Java8 version here: https://gist.github.com/aikar/9010136 - learn about TC: https://aikar.co/2015/07/26/async-development-java-control-flow-for-bukkit/
/*
* Copyright (c) 2015. Starlis LLC / dba Empire Minecraft
*
* MIT License:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
@amaranth
amaranth / SimpleFuture.java
Created June 8, 2016 20:49 — forked from klausbrunner/SimpleFuture.java
A very simple implementation of the Java Future interface, for passing a single value to some waiting thread. Uses a CountdownLatch to ensure thread safety and provide blocking-with-timeout functionality required by Future. Cancellation isn't supported.
public final class ResultFuture implements Future<Result> {
private final CountDownLatch latch = new CountDownLatch(1);
private Result value;
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
@Override
@amaranth
amaranth / perlin.py
Created June 4, 2016 15:21 — forked from eevee/perlin.py
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
use fixedbitset::FixedBitSet;
use std::any::{Any, TypeId};
use std::{mem, ptr};
/// How many instances are stored in each chunk of memory in the pool
const CHUNK_COUNT: usize = 1024;
// Methods of this are generic on T instead of the struct itself so we can
// store them in a Vec<ComponentTable> without trying to box a trait object and
// later downcast
@amaranth
amaranth / ecs.rs
Last active September 5, 2015 15:09
// TODO: Add systems, figure out parallelization
extern crate fixedbitset;
use self::fixedbitset::FixedBitSet;
use std::collections::HashMap;
use std::{mem, ptr};
pub const MAX_COMPONENTS: usize = 256;
const CHUNK_SIZE: usize = 8192;
// Based on the implementation from http://godsnotwheregodsnot.blogspot.com/2013/11/field-diamond-squared-fractal-terrain.html
use std::iter::range_step;
use std::rand::{IsaacRng, Rng};
pub struct FieldDiamondSquare {
x: int,
y: int,
width: uint,
height: uint,
import java.util.Arrays;
import java.util.HashSet;
public class BlockStorage {
private static final int DATA_SHIFT = 12;
private static final int EMITTEDLIGHT_SHIFT = DATA_SHIFT + 4;
private static final int SKYLIGHT_SHIFT = EMITTEDLIGHT_SHIFT + 4;
private static final int EMPTY_ENTRY = -1;
private byte[] index = new byte[2048];