Skip to content

Instantly share code, notes, and snippets.

@NiclasOlofsson
Created March 23, 2015 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiclasOlofsson/c273a8f0f38f54723ea3 to your computer and use it in GitHub Desktop.
Save NiclasOlofsson/c273a8f0f38f54723ea3 to your computer and use it in GitHub Desktop.
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
{
public class CustomStandingSign : StandingSign
{
private static readonly Dictionary<string, Level> Worlds = new Dictionary<string, Level>();
public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face)
{
Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign;
if (signEntity == null) return false;
string world = signEntity.Text1;
if (player.Level.LevelId.Equals(world)) return true;
if (!Worlds.ContainsKey(player.Level.LevelId))
{
Worlds.Add(player.Level.LevelId, player.Level);
}
if (!Worlds.ContainsKey(world))
{
Worlds.Add(world, new MobHuntLevel(world, new FlatlandWorldProvider()));
}
Level level = Worlds[world];
new Task(() => player.SpawnLevel(level)).Start();
level.BroadcastTextMessage(string.Format("{0} teleported to world <{1}>.", player.Username, level.LevelId));
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment