Skip to content

Instantly share code, notes, and snippets.

View NiclasOlofsson's full-sized avatar

Niclas Olofsson NiclasOlofsson

View GitHub Profile
@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 / pokemon.json
Last active July 17, 2016 11:27
Pokemon GO protocol
Result: 1
Items {
TemplateId: "BADGE_BATTLE_ATTACK_WON"
Badge {
BadgeType: BADGE_BATTLE_ATTACK_WON
BadgeRanks: 4
Targets: "\nd\350\007"
}
}
Items {
@NiclasOlofsson
NiclasOlofsson / Hologram.cs
Last active July 2, 2016 16:26
Hologram class based on invisible players.
public class Hologram : Mob
{
public UUID Uuid { get; private set; }
public string Name { get; private set; }
public bool Silent { get; set; }
public bool HideNameTag { get; set; }
public bool NoAi { get; set; }
public Hologram(Level level) : base(63, level)
{
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;
@NiclasOlofsson
NiclasOlofsson / ecdh.cs
Last active April 20, 2016 15:37
ECDH key import
var clientKey = CreateEcDiffieHellmanPublicKey("MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDEKneqEvcqUqqFMM1HM1A4zWjJC+I8Y+aKzG5dl+6wNOHHQ4NmG2PEXRJYhujyodFH+wO0dEr4GM1WoaWog8xsYQ6mQJAC0eVpBM96spUB1eMN56+BwlJ4H3Qx4TAvAs");
private ECDiffieHellmanPublicKey CreateEcDiffieHellmanPublicKey(string clientPubKeyString)
{
byte[] clientPublicKeyBlob = Base64Url.Decode(clientPubKeyString);
clientPublicKeyBlob = FixPublicKey(clientPublicKeyBlob.Skip(23).ToArray());
ECDiffieHellmanPublicKey clientKey = ECDiffieHellmanCngPublicKey.FromByteArray(clientPublicKeyBlob, CngKeyBlobFormat.EccPublicBlob);
return clientKey;
}
public class TextEntity : Entity
{
public TextEntity(Level level, string text, Vector3 pos) : base(64, level)
{
NameTag = text;
KnownPosition = new PlayerLocation(pos);
HealthManager = new NoDamageHealthManager(this);
}
public override void OnTick()
@NiclasOlofsson
NiclasOlofsson / server.conf
Created June 16, 2015 14:20
Example server.conf
#DO NOT REMOVE THIS LINE - MiNET Config
#WorldProvider=anvil
WorldProvider=flat
ViewDistance=250
#PCWorldFolder=D:\Downloads\KingsLanding1\KingsLanding1
#PCWaterOffset=30
#PCWorldFolder=D:\Development\Worlds\MiniGames\Capture the flag
#PCWorldFolder=D:\Development\Worlds\MiniGames\Castle Wars
#PCWorldFolder=D:\Development\Worlds\MiniGames\King of the hill
using System.Collections.Generic;
using System.Threading.Tasks;
using MiNET;
using MiNET.BlockEntities;
using MiNET.Blocks;
using MiNET.Utils;
using MiNET.Worlds;
namespace TestPlugin.MobHunt
{
[Plugin]
public class PlayerLoginPlugin
{
private static readonly ILog Log = LogManager.GetLogger(typeof (PlayerLoginPlugin));
[PacketHandler]
public Package OnLogin(McpeLogin packet, Player newPlayer)
{
Log.InfoFormat("Player {0} connected from {1}", newPlayer.Username, newPlayer.EndPoint.Address);
@NiclasOlofsson
NiclasOlofsson / Plugin.cs
Last active December 26, 2015 19:08
MiNET configuration using JSON
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Xml.Serialization;
using log4net;
using MiNET.Plugins;