private static void SpawnIntoContainer_Implementation(long amount, SerializableDefinitionId item, long entityId, long playerId) { if (!MyEventContext.Current.IsLocallyInvoked && !MySession.Static.HasPlayerCreativeRights(MyEventContext.Current.Sender.Value)) { MyEventContext.ValidationFailed(); return; } MyEntity entity; if (!MyEntities.TryGetEntityById(entityId, out entity)) { return; } if (!entity.HasInventory || !((MyTerminalBlock)entity).HasPlayerAccess(playerId)) { return; } MyInventory inventory = entity.GetInventory(); if (!inventory.CheckConstraint(item)) { return; } MyFixedPoint itemAmt = (MyFixedPoint)Math.Min(amount, (decimal)inventory.ComputeAmountThatFits(item)); inventory.AddItems(itemAmt, (MyObjectBuilder_PhysicalObject)MyObjectBuilderSerializer.CreateNewObject(item)); }