Skip to content

Instantly share code, notes, and snippets.

View NiclasOlofsson's full-sized avatar

Niclas Olofsson NiclasOlofsson

View GitHub Profile
public class CountDownTimer
{
private Stopwatch _startTimer;
private TimeSpan _delay;
private long _currentTick;
private readonly int _skipTicks;
private readonly Action<TimeSpan> _tickAction;
private readonly Action _endAction;
FFFFFFFF ; ---------------------------------------------------------------------------
FFFFFFFF
FFFFFFFF ; enum CommandRegistry::HardNonTerminal, copyof_5669, width 4 bytes
FFFFFFFF Epsilon = 100000h
FFFFFFFF Int_0 = 100001h
FFFFFFFF Val = 100002h
FFFFFFFF RVal = 100003h
FFFFFFFF WildcardInt = 100004h
FFFFFFFF Operator_0 = 100005h
FFFFFFFF Selection = 100006h
@NiclasOlofsson
NiclasOlofsson / blockstates.json
Created January 14, 2020 17:05
Blockstates for 1.14+ including Item for each blockstate.
[
{"Id":0,"Data":0,"Name":"minecraft:air","RuntimeId":0,"States":[],"ItemInstance":null},
{"Id":1,"Data":0,"Name":"minecraft:stone","RuntimeId":1,"States":[{"Type":8,"Name":"stone_type","Value":"stone"}],"ItemInstance":{"Id":0,"Metadata":0,"WantNbt":false}},
{"Id":1,"Data":1,"Name":"minecraft:stone","RuntimeId":2,"States":[{"Type":8,"Name":"stone_type","Value":"granite"}],"ItemInstance":{"Id":1,"Metadata":0,"WantNbt":false}},
{"Id":1,"Data":2,"Name":"minecraft:stone","RuntimeId":3,"States":[{"Type":8,"Name":"stone_type","Value":"granite_smooth"}],"ItemInstance":{"Id":1,"Metadata":1,"WantNbt":false}},
{"Id":1,"Data":3,"Name":"minecraft:stone","RuntimeId":4,"States":[{"Type":8,"Name":"stone_type","Value":"diorite"}],"ItemInstance":{"Id":1,"Metadata":2,"WantNbt":false}},
{"Id":1,"Data":4,"Name":"minecraft:stone","RuntimeId":5,"States":[{"Type":8,"Name":"stone_type","Value":"diorite_smooth"}],"ItemInstance":{"Id":1,"Metadata":3,"WantNbt":false}},
{"Id":1,"Data":5,"Name":"minecraft:stone","RuntimeId":6,"States":[{
@NiclasOlofsson
NiclasOlofsson / blockstates.json
Created January 14, 2020 17:05
Blockstates for 1.14+ including Item for each blockstate.
[
{"Id":0,"Data":0,"Name":"minecraft:air","RuntimeId":0,"States":[],"ItemInstance":null},
{"Id":1,"Data":0,"Name":"minecraft:stone","RuntimeId":1,"States":[{"Type":8,"Name":"stone_type","Value":"stone"}],"ItemInstance":{"Id":0,"Metadata":0,"WantNbt":false}},
{"Id":1,"Data":1,"Name":"minecraft:stone","RuntimeId":2,"States":[{"Type":8,"Name":"stone_type","Value":"granite"}],"ItemInstance":{"Id":1,"Metadata":0,"WantNbt":false}},
{"Id":1,"Data":2,"Name":"minecraft:stone","RuntimeId":3,"States":[{"Type":8,"Name":"stone_type","Value":"granite_smooth"}],"ItemInstance":{"Id":1,"Metadata":1,"WantNbt":false}},
{"Id":1,"Data":3,"Name":"minecraft:stone","RuntimeId":4,"States":[{"Type":8,"Name":"stone_type","Value":"diorite"}],"ItemInstance":{"Id":1,"Metadata":2,"WantNbt":false}},
{"Id":1,"Data":4,"Name":"minecraft:stone","RuntimeId":5,"States":[{"Type":8,"Name":"stone_type","Value":"diorite_smooth"}],"ItemInstance":{"Id":1,"Metadata":3,"WantNbt":false}},
{"Id":1,"Data":5,"Name":"minecraft:stone","RuntimeId":6,"States":[{
@NiclasOlofsson
NiclasOlofsson / client_blob_cache.md
Created July 11, 2019 17:51 — forked from Tomcc/client_blob_cache.md
A description of the new Client Cache for server developers

Client Blob Cache

What's the Client Blob Cache

The Client Blob Cache is a new Bedrock optimization - it allows blocks and biomes to be cached on Clients to avoid resending identical chunks over and over. Chunks and biomes make up the vast majority of network traffic in a lot of common cases (eg. login, teleport or dimension switches) but at the same time, they rarely change. Allowing the Client to reuse chunks it has seen in the past can save a ton of traffic and latency!

The Client Cache is a Content Addressed Storage (a bit like git) that stores Blobs and retrieves them based on their full hashes (BlobIds). This means that the cache doesn't actually know about Chunks - in the future, we might start using it for more types of data, like skins or data driven entities.

A nice thing we get from the CAS approach is that the cache is persistent: returning players will be able to reuse content that was sent them in previous sessions or even previous sessions in different servers as long as tha

2019-06-06 22:00:12,632 [16] DEBUG MiNET.Client.BedrockTraceHandler - TAG_Compound: 1 entries {
TAG_List("idlist"): 103 entries {
TAG_Compound: 6 entries {
TAG_String("bid"): ":"
TAG_Byte("experimental"): 0
TAG_Byte("hasspawnegg"): 1
TAG_String("id"): "minecraft:villager_v2"
TAG_Int("rid"): 115
TAG_Byte("summonable"): 0
}
@NiclasOlofsson
NiclasOlofsson / commands.js
Created September 20, 2016 17:01
MCPE Commands JSON
2016-09-20 18:59:59,577 DEBUG MiNET.Client.MiNetClient - Command JSON:
{
"ability": {
"versions": [
{
"description": "commands.ability.description",
"overloads": {
"default": {
"input": {
"parameters": [
@NiclasOlofsson
NiclasOlofsson / enums.cs
Created December 13, 2017 19:35
All enums in bedrock 1.2
public enum GameMode{
creative,
survival,
adventure,
c,
s,
a,
}
public enum RValueParam{
@NiclasOlofsson
NiclasOlofsson / mobspawns.txt
Created December 13, 2017 18:32
All mob-spawns 1.2.6
Entity Type: 4874 - 0x130a
Entity Family: 19 - 0x13
Entity Type ID: 10 - 0x0a Chicken
Metadata:
MetadataDictionary metadata = new MetadataDictionary();
metadata[0] = new MetadataLong(105561706725376); // 11000000000001000000000000010000000000000000000; CanClimb, Breathing, HasCollision, AffectedByGravity19, 33, 45, 46,
metadata[1] = new MetadataInt(1);
metadata[2] = new MetadataInt(0);
metadata[3] = new MetadataByte(0);
metadata[4] = new MetadataString("");
@NiclasOlofsson
NiclasOlofsson / fireworks.cs
Created December 4, 2017 17:30
MiNET fireworks example - all configs
var fireworks = new ItemFireworks() {Count = 64};
fireworks.ExtraData = ItemFireworks.ToNbt(new ItemFireworks.FireworksData()
{
Explosions = new List<ItemFireworks.FireworksExplosion>()
{
new ItemFireworks.FireworksExplosion()
{
FireworkColor = new[] {(byte) 0},
FireworkFade = new[] {(byte) 1},
FireworkFlicker = true,