Example #1
0
 public BlockExistsAtCondition(Coordinates location, string block, int dataValue = -1, NBTObject NBT = null)
 {
     this.block       = block;
     this.NBT         = NBT == null ? new NBTObject() : NBT;
     this.dataValue   = dataValue;
     this.coordinates = location;
 }
Example #2
0
 public void ReplaceBlockItem(Coordinates location, string slot, string item, int amount = 1, int dataValue = 0, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("replaceitem block " + location.ToString() + " " + slot + " " + item + " " + amount + " " + dataValue + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #3
0
 public void ReplaceEntityItem(Entities entities, string slot, string item, int amount = 1, int dataValue = 0, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("replaceitem entity " + entities.GetSelectorString() + " " + slot + " " + item + " " + amount + " " + dataValue + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #4
0
 public void SetBlock(Coordinates location, string block, int dataValue = 0, string mode = "replace", NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("setblock " + location.ToString() + " " + block + " " + dataValue + " " + mode + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #5
0
 public void TestForEntity(Entities entities, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("testfor " + entities.GetSelectorString() + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #6
0
 public void RemoveTag(string tag, Entities entities, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     EntityCommand(new Command("scoreboard players tag " + entities.GetSelectorString() + " remove " + tag + " " + NBT.ToString(), CurrentType(ifPrevious)), entities);
 }
Example #7
0
 public void TestForBlock(Coordinates location, string block, int dataValue = -1, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("testforblock " + location.ToString() + " " + block + " " + dataValue + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #8
0
 public void GiveItem(Entities players, string item, int amount = 1, int dataValue = 0, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     EntityCommand(new Command("give " + players.GetSelectorString() + " " + item + " " + amount + " " + dataValue + " " + NBT.ToString(), CurrentType(ifPrevious)), players);
 }
Example #9
0
        public EntityCanBeFoundCondition(Entities entities, NBTObject NBT = null, string detectBlock = null, Coordinates detectCoords = null, int?detectDataValue = null)
        {
            this.entities = entities;
            this.NBT      = NBT == null ? new NBTObject() : NBT;

            this.detectBlock     = detectBlock;
            this.detectCoords    = detectCoords;
            this.detectDataValue = detectDataValue;
        }
Example #10
0
 public void FillArea(Area area, string block, int dataValue = 0, string mode = "keep", NBTObject NBT = null, bool ifPrevious = false)
 {
     if (mode == "replace")
     {
         throw new ArgumentException("Cannot use mode \"replace\". Use ReplaceArea() instead.");
     }
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("fill " + area.ToString() + " " + block + " " + dataValue + " " + mode + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #11
0
 public void Kill(Entities entities, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (NBT == null)
     {
         EntityCommand(new Command("kill " + entities.GetSelectorString(), CurrentType(ifPrevious)), entities);
     }
     else
     {
         AddTag("MCGL_KILL", entities, NBT);
         Kill(entities.WithTag("MCGL_KILL"));
     }
 }
Example #12
0
 public void SummonEntity(EntityType type, Coordinates location, NBTObject NBT = null, bool ifPrevious = false)
 {
     if (type == EntityType.ANY)
     {
         throw new ArgumentException("Cannot summon an entity with type ANY.");
     }
     if (NBT == null)
     {
         NBT = new NBTObject();
     }
     CombineCommand(new Command("summon " + type.ToString() + " " + location.ToString() + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #13
0
        public static NBTObject Combine(params NBTObject[] objects)
        {
            NBTObject NBT = new NBTObject();

            foreach (var part in objects)
            {
                foreach (var data in part.data)
                {
                    NBT.SetCustom(data.Key, data.Value);
                }
            }

            return(NBT);
        }
Example #14
0
        public Chain(CommandType type = CommandType.IMPULSE, bool hideBaseEntity = false)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator = ".";

            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            next = type;
            var id = Entities.RandomString(32);

            baseEntity = Entities.GetSingle(EntityType.ArmorStand).WithName(id);
            baseNBT    = new NBTObject().Set("CustomName", id);
            if (hideBaseEntity)
            {
                baseNBT = baseNBT.Set("Invisible", true);
            }

            SummonEntity(EntityType.ArmorStand, new RelativeCoordinates(0, 0, 0), baseNBT);
        }
Example #15
0
        public void PushExecutionAs(Entities entities, NBTObject NBT = null, Coordinates coordinates = null, string detectBlock = null, Coordinates detectCoordinates = null, int?detectDataValue = null)
        {
            string detect = null;

            if (detectBlock != null && (detectCoordinates == null || detectDataValue == null))
            {
                throw new ArgumentNullException("All of the detect parameters have to be set.");
            }

            if (detectBlock != null)
            {
                detect = "detect " + detectCoordinates.ToString() + " " + detectBlock + " " + detectDataValue;
            }

            if (coordinates == null)
            {
                coordinates = RelativeCoordinates.Zero;
            }

            if (NBT == null)
            {
                NBT = new NBTObject();
            }

            if (execution != null)
            {
                RemoveTag("MCGL_EXECUTING", executionWithout);
                execution = null;
                var cond = new EntityCanBeFoundCondition(executionWithout, executionNBT);
                cond.Init(this);
                executions.Push(cond);
            }

            AddTag("MCGL_EXECUTING", entities, NBT);
            executionWithout = entities;
            execution        = entities.WithTag("MCGL_EXECUTING");
            executionNBT     = NBT;
            executionCoords.Push(coordinates);
            detects.Push(detect);
        }
Example #16
0
 public void SetEntityData(Entities entities, NBTObject NBT, bool ifPrevious = false)
 {
     EntityCommand(new Command("entitydata " + entities.GetSelectorString() + " " + NBT.ToString(), CurrentType(ifPrevious)), entities);
 }
Example #17
0
 public Condition EntityCanBeFound(Entities entities, NBTObject NBT = null, string detectBlock = null, Coordinates detectCoords = null, int?detectDataValue = null)
 {
     return(new EntityCanBeFoundCondition(entities, NBT, detectBlock, detectCoords, detectDataValue));
 }
Example #18
0
 public Condition BlockExistsAt(Coordinates location, string block, int dataValue = -1, NBTObject NBT = null)
 {
     return(new BlockExistsAtCondition(location, block, dataValue, NBT));
 }
Example #19
0
 public Chain ExecuteAs(Entities entities, NBTObject NBT = null, Coordinates coordinates = null, string detectBlock = null, Coordinates detectCoordinates = null, int?detectDataValue = null)
 {
     PushExecutionAs(entities, NBT, coordinates, detectBlock, detectCoordinates, detectDataValue);
     singleExecution++;
     return(this);
 }
Example #20
0
 public NBTObject Set(string key, NBTObject value)
 {
     data[key] = value.ToString();
     return(this);
 }
Example #21
0
        // Players

        public void SetScore(Entities entities, string objective, int score, NBTObject NBT = null, bool ifPrevious = false)
        {
            EntityCommand(new Command("scoreboard players set " + entities.GetSelectorString() + " " + objective + " " + score + " " + NBT.ToString(), CurrentType(ifPrevious)), entities);
        }
Example #22
0
 public void SetBlockData(Coordinates coordinates, NBTObject NBT, bool ifPrevious = false)
 {
     CombineCommand(new Command("blockdata " + coordinates.ToString() + " " + NBT.ToString(), CurrentType(ifPrevious)));
 }
Example #23
0
 public void RemoveFromScore(Entities entities, string objective, int amount, NBTObject NBT = null, bool ifPrevious = false)
 {
     EntityCommand(new Command("scoreboard players remove " + entities.GetSelectorString() + " " + objective + " " + amount + " " + NBT.ToString(), CurrentType(ifPrevious)), entities);
 }
Example #24
0
 public NBTArray Add(NBTObject value)
 {
     data.Add(value.ToString());
     return(this);
 }