示例#1
0
 public TeleportMsg(BlockPos pos, TeleportData data, bool doRemove = false, bool synced = false)
 {
     this.Pos      = pos;
     this.Data     = data;
     this.DoRemove = doRemove;
     this.Synced   = synced;
 }
示例#2
0
        internal static void SetTeleport(BlockPos pos, TeleportData data)
        {
            if (!Teleports.ContainsKey(pos))
            {
                AddTeleport(pos, data);
                return;
            }

            Teleports[pos] = data;

            if (sapi != null)
            {
                serverChannel.BroadcastPacket(new TeleportMsg(
                                                  pos,
                                                  data
                                                  ));
            }
            else if (capi != null)
            {
                clientChannel.SendPacket(new TeleportMsg(
                                             pos,
                                             data
                                             ));
            }

            string type = data.Available ? "normal" : "broken";

            api.World.Logger.ModNotification($"Modified teleport {data.Name} ({type}) at {pos}");
        }
示例#3
0
        private bool OnButtonSave()
        {
            GuiElementTextInput textInput = base.SingleComposer.GetTextInput("text");

            TeleportData data = TPNetManager.GetTeleport(blockEntityPos);

            data.Name = textInput.GetText();
            TPNetManager.SetTeleport(blockEntityPos, data);

            didSave = true;
            TryClose();
            return(true);
        }
示例#4
0
        internal static void TryCreateData(BlockPos pos, bool available = false)
        {
            if (pos == null)
            {
                throw new ArgumentNullException();
            }
            if (Teleports.ContainsKey(pos))
            {
                return;
            }

            TeleportData data = new TeleportData()
            {
                Available = available,
                Name      = defNames.ElementAt(api.World.Rand.Next(defNames.Count))
            };

            AddTeleport(pos.Copy(), data);
        }