Skip to content
Permalink
Browse files

Allow doing gb/lb copy to a non-existent block ID.

  • Loading branch information...
UnknownShadow200 committed Nov 14, 2017
1 parent c4890d8 commit 0a79f4c83682b9d1bce3955cde9bd2c5a50352a4
Showing with 14 additions and 4 deletions.
  1. +11 −1 fCraft/Commands/CommandReader.cs
  2. +3 −3 fCraft/Commands/CpeCommands.cs
@@ -229,8 +229,18 @@ public sealed class CommandReader : ICloneable {
return ParseBlock(blockName, player, allowNoneBlock, ref block);
}

public bool NextRawBlock([CanBeNull] Player player, out Block block) {
string name = Next();
block = Block.None;
if (name == null) return false;

byte raw;
if (byte.TryParse(name, out raw)) { block = (Block)raw; return true; }

return ParseBlock(name, player, false, ref block);
}

bool ParseBlock(string blockName, [CanBeNull] Player player, bool allowNoneBlock, ref Block block) {
static bool ParseBlock(string blockName, [CanBeNull] Player player, bool allowNoneBlock, ref Block block) {
World world = player == null ? null : player.World;
if (Map.GetBlockByName(world, blockName, true, out block)) {
if (block != Block.None || allowNoneBlock) {
@@ -1659,8 +1659,8 @@ static class CpeCommands {
string scope = global ? "global" : "level";
string name = global ? "/gb" : "/lb";

if (!cmd.NextBlock(p, false, out srcBlock)) return;
if (!cmd.NextBlock(p, false, out dstBlock)) return;
if (!cmd.NextRawBlock(p, out srcBlock)) return;
if (!cmd.NextRawBlock(p, out dstBlock)) return;
if (dstBlock == Block.Air || dstBlock == Block.None) {
p.Message("Destination block cannot have 0 or 255 ID."); return;
}
@@ -1699,7 +1699,7 @@ static class CpeCommands {
string scope = global ? "global" : "level";
string name = global ? "/gb" : "/lb";

if (!cmd.NextBlock(p, false, out blockID)) return;
if (!cmd.NextRawBlock(p, out blockID)) return;

BlockDefinition def = GetCustomBlock(global, defs, (byte)blockID);
if (def == null) {

0 comments on commit 0a79f4c

Please sign in to comment.
You can’t perform that action at this time.