Skip to content

Instantly share code, notes, and snippets.

@amaranth
amaranth / gist:5198788
Last active December 15, 2015 03:59
Possible bukkit.yml alias expansion

bukkit.yml Aliases

You can disable a command entirely by aliasing it to an empty result.

aliases:
  version: []

/version

package org.bukkit.craftbukkit;
import net.minecraft.server.Block;
import net.minecraft.server.ChunkSection;
import net.minecraft.server.NibbleArray;
import org.bukkit.craftbukkit.util.Palette;
public class CraftChunkSection extends ChunkSection {
private int yPos;
package org.bukkit.craftbukkit.util;
import org.apache.commons.lang.Validate;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.AbstractSet;
Time: 8.487481, Key: KeyLeftAlt, ScanCode: 58, Action: Press, Modifiers: [Alt]
Time: 9.295514, Key: KeyGraveAccent, ScanCode: 50, Action: Press, Modifiers: [Alt]
Time: 9.391414, Key: KeyGraveAccent, ScanCode: 50, Action: Release, Modifiers: [Alt]
Time: 11.511525, Key: KeyLeftAlt, ScanCode: 58, Action: Release, Modifiers: []
Time: 12.119616, Key: KeyA, ScanCode: 0, Action: Press, Modifiers: []
Time: 12.119618, Character: a
Time: 12.215541, Key: KeyA, ScanCode: 0, Action: Release, Modifiers: []
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];
// 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,
@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;
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 / 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.
@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